summaryrefslogtreecommitdiff
path: root/python/openvino/runtime/common/demo_utils/include/utils/images_capture.h
diff options
context:
space:
mode:
authorEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
committerEric Dao <eric@erickhangdao.com>2025-03-10 17:54:31 -0400
commitab224e2e6ba65f5a369ec392f99cd8845ad06c98 (patch)
treea1e757e9341863ed52b8ad4c5a1c45933aab9da4 /python/openvino/runtime/common/demo_utils/include/utils/images_capture.h
parent40da1752f2c8639186b72f6838aa415e854d0b1d (diff)
downloadthesis-master.tar.gz
thesis-master.tar.bz2
thesis-master.zip
completed thesisHEADmaster
Diffstat (limited to 'python/openvino/runtime/common/demo_utils/include/utils/images_capture.h')
-rw-r--r--python/openvino/runtime/common/demo_utils/include/utils/images_capture.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/python/openvino/runtime/common/demo_utils/include/utils/images_capture.h b/python/openvino/runtime/common/demo_utils/include/utils/images_capture.h
new file mode 100644
index 0000000..f2afdfc
--- /dev/null
+++ b/python/openvino/runtime/common/demo_utils/include/utils/images_capture.h
@@ -0,0 +1,53 @@
+// Copyright (C) 2020-2022 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+#include <stddef.h>
+
+#include <limits>
+#include <memory>
+#include <string>
+
+#include <opencv2/core.hpp>
+
+#include "utils/performance_metrics.hpp"
+
+enum class read_type { efficient, safe };
+
+class ImagesCapture {
+public:
+ const bool loop;
+
+ ImagesCapture(bool loop) : loop{loop} {}
+ virtual double fps() const = 0;
+ virtual cv::Mat read() = 0;
+ virtual std::string getType() const = 0;
+ const PerformanceMetrics& getMetrics() {
+ return readerMetrics;
+ }
+ virtual ~ImagesCapture() = default;
+
+protected:
+ PerformanceMetrics readerMetrics;
+};
+
+// An advanced version of
+// try {
+// return cv::VideoCapture(std::stoi(input));
+// } catch (const std::invalid_argument&) {
+// return cv::VideoCapture(input);
+// } catch (const std::out_of_range&) {
+// return cv::VideoCapture(input);
+// }
+// Some VideoCapture backends continue owning the video buffer under cv::Mat. safe_copy forses to return a copy from
+// read()
+// https://github.com/opencv/opencv/blob/46e1560678dba83d25d309d8fbce01c40f21b7be/modules/gapi/include/opencv2/gapi/streaming/cap.hpp#L72-L76
+std::unique_ptr<ImagesCapture> openImagesCapture(
+ const std::string& input,
+ bool loop,
+ read_type type = read_type::efficient,
+ size_t initialImageId = 0,
+ size_t readLengthLimit = std::numeric_limits<size_t>::max(), // General option
+ cv::Size cameraResolution = {1280, 720}
+ );