Skip to content

Commit 26a2216

Browse files
authored
Merge branch 'openvinotoolkit:master' into master
2 parents 0523957 + b2cb975 commit 26a2216

File tree

23 files changed

+912
-913
lines changed

23 files changed

+912
-913
lines changed

demos/common/cpp/utils/include/utils/kuhn_munkres.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class KuhnMunkres {
3131
/// \return Optimal column index for each row. -1 means that there is no
3232
/// column for row.
3333
///
34-
std::vector<size_t> Solve(const cv::Mat &dissimilarity_matrix);
34+
std::vector<int> Solve(const cv::Mat &dissimilarity_matrix);
3535

3636
private:
3737
static constexpr int kStar = 1;

demos/common/cpp/utils/src/kuhn_munkres.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
KuhnMunkres::KuhnMunkres(bool greedy) : n_(), greedy_(greedy) {}
1212

13-
std::vector<size_t> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
13+
std::vector<int> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
1414
CV_Assert(dissimilarity_matrix.type() == CV_32F);
1515
double min_val;
1616
cv::minMaxLoc(dissimilarity_matrix, &min_val);
@@ -28,7 +28,7 @@ std::vector<size_t> KuhnMunkres::Solve(const cv::Mat& dissimilarity_matrix) {
2828

2929
Run();
3030

31-
std::vector<size_t> results(dissimilarity_matrix.rows, -1);
31+
std::vector<int> results(dissimilarity_matrix.rows, -1);
3232
for (int i = 0; i < dissimilarity_matrix.rows; i++) {
3333
const auto ptr = marked_.ptr<char>(i);
3434
for (int j = 0; j < dissimilarity_matrix.cols; j++) {

demos/smart_classroom_demo/cpp/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ Options:
8282
-m_fd '<path>' Required. Path to the Face Detection model (.xml) file.
8383
-m_lm '<path>' Optional. Path to the Facial Landmarks Regression Retail model (.xml) file.
8484
-m_reid '<path>' Optional. Path to the Face Reidentification Retail model (.xml) file.
85-
-l '<absolute_path>' Optional. For CPU custom layers, if any. Absolute path to a shared library with the kernels implementation.
86-
Or
87-
-c '<absolute_path>' Optional. For GPU custom kernels, if any. Absolute path to an .xml file with the kernels description.
8885
-d_act '<device>' Optional. Specify the target device for Person/Action Detection Retail (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device.
8986
-d_fd '<device>' Optional. Specify the target device for Face Detection Retail (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device.
9087
-d_lm '<device>' Optional. Specify the target device for Landmarks Regression Retail (the list of available devices is shown below). Default value is CPU. Use "-d HETERO:<comma-separated_devices_list>" format to specify HETERO plugin. The application looks for a suitable plugin for the specified device.

demos/smart_classroom_demo/cpp/include/action_detector.hpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2018-2019 Intel Corporation
1+
// Copyright (C) 2018-2022 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

@@ -12,6 +12,8 @@
1212

1313
#include "cnn.hpp"
1414

15+
#include "openvino/openvino.hpp"
16+
1517
/**
1618
* @brief Class for detection with action info
1719
*/
@@ -113,29 +115,30 @@ class ActionDetection : public AsyncDetection<DetectedAction>, public BaseCnnDet
113115
explicit ActionDetection(const ActionDetectorConfig& config);
114116

115117
void submitRequest() override;
116-
void enqueue(const cv::Mat &frame) override;
118+
void enqueue(const cv::Mat& frame) override;
117119
void wait() override { BaseCnnDetection::wait(); }
118120
DetectedActions fetchResults() override;
119121

120122
private:
121-
ActionDetectorConfig config_;
122-
InferenceEngine::ExecutableNetwork net_;
123-
std::string input_name_;
124-
InferenceEngine::BlobMap outputs_;
125-
126-
int enqueued_frames_ = 0;
127-
float width_ = 0;
128-
float height_ = 0;
129-
bool new_network_ = false;
130-
std::vector<int> head_ranges_;
131-
std::vector<int> head_step_sizes_;
132-
std::vector<cv::Size> head_blob_sizes_;
133-
std::vector<std::vector<int>> glob_anchor_map_;
134-
std::vector<std::string> glob_anchor_names_;
135-
int num_glob_anchors_ = 0;
136-
cv::Size network_input_size_;
137-
int num_candidates_;
138-
bool binary_task_;
123+
ActionDetectorConfig m_config;
124+
ov::CompiledModel m_model;
125+
ov::Layout m_modelLayout;
126+
std::string m_input_name;
127+
std::map<std::string, ov::Tensor> m_outputs;
128+
129+
int m_enqueued_frames = 0;
130+
float m_width = 0;
131+
float m_height = 0;
132+
bool m_new_model = false;
133+
std::vector<int> m_head_ranges;
134+
std::vector<int> m_head_step_sizes;
135+
std::vector<cv::Size> m_head_blob_sizes;
136+
std::vector<std::vector<int>> m_glob_anchor_map;
137+
std::vector<std::string> m_glob_anchor_names;
138+
int m_num_glob_anchors = 0;
139+
cv::Size m_network_input_size;
140+
int m_num_candidates;
141+
bool m_binary_task;
139142

140143
/**
141144
* @brief BBox in normalized form (each coordinate is in range [0;1]).
Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2018-2019 Intel Corporation
1+
// Copyright (C) 2018-2022 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

@@ -10,31 +10,31 @@
1010
#include <vector>
1111
#include <functional>
1212

13-
#include <utils/ocv_common.hpp>
13+
#include "openvino/openvino.hpp"
1414

15-
#include <inference_engine.hpp>
15+
#include "utils/ocv_common.hpp"
1616

1717
/**
1818
* @brief Base class of config for network
1919
*/
2020
struct CnnConfig {
21-
explicit CnnConfig(const std::string& path_to_model, const std::string& model_type = "")
22-
: path_to_model(path_to_model), model_type(model_type) {}
21+
explicit CnnConfig(const std::string& path_to_model, const std::string& model_type = "") :
22+
m_path_to_model(path_to_model), m_model_type(model_type) {}
2323
/** @brief Path to model description */
24-
std::string path_to_model;
24+
std::string m_path_to_model;
2525
/** @brief Model type*/
26-
std::string model_type;
26+
std::string m_model_type;
2727
/** @brief Maximal size of batch */
28-
int max_batch_size{1};
28+
int m_max_batch_size{1};
2929

3030
/** @brief Inference Engine */
31-
InferenceEngine::Core ie;
31+
ov::Core m_core;
3232
/** @brief Device name */
33-
std::string deviceName;
33+
std::string m_deviceName;
3434
};
3535

3636
/**
37-
* @brief Base class of network
37+
* @brief Base class of model
3838
*/
3939
class CnnDLSDKBase {
4040
public:
@@ -57,37 +57,32 @@ class CnnDLSDKBase {
5757

5858
protected:
5959
/**
60-
* @brief Run network
61-
*
62-
* @param frame Input image
63-
* @param results_fetcher Callback to fetch inference results
64-
*/
65-
void Infer(const cv::Mat& frame,
66-
const std::function<void(const InferenceEngine::BlobMap&, size_t)>& results_fetcher) const;
67-
68-
/**
69-
* @brief Run network in batch mode
60+
* @brief Run model in batch mode
7061
*
7162
* @param frames Vector of input images
7263
* @param results_fetcher Callback to fetch inference results
7364
*/
7465
void InferBatch(const std::vector<cv::Mat>& frames,
75-
const std::function<void(const InferenceEngine::BlobMap&, size_t)>& results_fetcher) const;
66+
const std::function<void(const std::map<std::string, ov::Tensor>&, size_t)>& results_fetcher) const;
7667

7768
/** @brief Config */
78-
Config config_;
79-
/** @brief Net inputs info */
80-
InferenceEngine::InputsDataMap inInfo_;
81-
/** @brief Net outputs info */
82-
InferenceEngine::OutputsDataMap outInfo_;
83-
/** @brief IE network */
84-
InferenceEngine::ExecutableNetwork executable_network_;
85-
/** @brief IE InferRequest */
86-
mutable InferenceEngine::InferRequest infer_request_;
87-
/** @brief Name of the input blob input blob */
88-
std::string input_blob_name_;
89-
/** @brief Names of output blobs */
90-
std::vector<std::string> output_blobs_names_;
69+
Config m_config;
70+
/** @brief Model inputs info */
71+
ov::OutputVector m_inInfo;
72+
/** @brief Model outputs info */
73+
ov::OutputVector m_outInfo_;
74+
/** @brief Model layout */
75+
ov::Layout m_modelLayout;
76+
/** @brief Model input shape */
77+
ov::Shape m_modelShape;
78+
/** @brief Compled model */
79+
ov::CompiledModel m_compiled_model;
80+
/** @brief Inference request */
81+
mutable ov::InferRequest m_infer_request;
82+
/** @brief Name of the input tensor */
83+
std::string m_input_tensor_name;
84+
/** @brief Names of output tensors */
85+
std::vector<std::string> m_output_tensors_names;
9186
};
9287

9388
class VectorCNN : public CnnDLSDKBase {
@@ -98,12 +93,13 @@ class VectorCNN : public CnnDLSDKBase {
9893
cv::Mat* vector, cv::Size outp_shape = cv::Size()) const;
9994
void Compute(const std::vector<cv::Mat>& images,
10095
std::vector<cv::Mat>* vectors, cv::Size outp_shape = cv::Size()) const;
96+
int maxBatchSize() const;
10197
};
10298

10399
class AsyncAlgorithm {
104100
public:
105101
virtual ~AsyncAlgorithm() {}
106-
virtual void enqueue(const cv::Mat &frame) = 0;
102+
virtual void enqueue(const cv::Mat& frame) = 0;
107103
virtual void submitRequest() = 0;
108104
virtual void wait() = 0;
109105
};
@@ -117,33 +113,34 @@ class AsyncDetection : public AsyncAlgorithm {
117113
template <typename T>
118114
class NullDetection : public AsyncDetection<T> {
119115
public:
120-
void enqueue(const cv::Mat &) override {}
116+
void enqueue(const cv::Mat&) override {}
121117
void submitRequest() override {}
122118
void wait() override {}
123119
std::vector<T> fetchResults() override { return {}; }
124120
};
125121

126122
class BaseCnnDetection : public AsyncAlgorithm {
127123
protected:
128-
InferenceEngine::InferRequest::Ptr request;
129-
const bool isAsync;
130-
std::string topoName;
124+
std::shared_ptr<ov::InferRequest> m_request;
125+
const bool m_isAsync;
126+
std::string m_detectorName;
131127

132128
public:
133-
explicit BaseCnnDetection(bool isAsync = false) :
134-
isAsync(isAsync) {}
129+
explicit BaseCnnDetection(bool isAsync = false) : m_isAsync(isAsync) {}
135130

136131
void submitRequest() override {
137-
if (request == nullptr) return;
138-
if (isAsync) {
139-
request->StartAsync();
132+
if (m_request == nullptr)
133+
return;
134+
if (m_isAsync) {
135+
m_request->start_async();
140136
} else {
141-
request->Infer();
137+
m_request->infer();
142138
}
143139
}
144140

145141
void wait() override {
146-
if (!request || !isAsync) return;
147-
request->Wait(InferenceEngine::InferRequest::WaitMode::RESULT_READY);
142+
if (!m_request || !m_isAsync)
143+
return;
144+
m_request->wait();
148145
}
149146
};

demos/smart_classroom_demo/cpp/include/detector.hpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2018-2019 Intel Corporation
1+
// Copyright (C) 2018-2022 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

@@ -10,6 +10,8 @@
1010

1111
#include <opencv2/core/core.hpp>
1212

13+
#include "openvino/openvino.hpp"
14+
1315
#include "cnn.hpp"
1416

1517
namespace detection {
@@ -18,15 +20,15 @@ struct DetectedObject {
1820
cv::Rect rect;
1921
float confidence;
2022

21-
explicit DetectedObject(const cv::Rect& rect = cv::Rect(), float confidence = -1.0f)
22-
: rect(rect), confidence(confidence) {}
23+
explicit DetectedObject(const cv::Rect& rect = cv::Rect(), float confidence = -1.0f) :
24+
rect(rect), confidence(confidence) {}
2325
};
2426

2527
using DetectedObjects = std::vector<DetectedObject>;
2628

2729
struct DetectorConfig : public CnnConfig {
28-
explicit DetectorConfig(const std::string& path_to_model)
29-
: CnnConfig(path_to_model) {}
30+
explicit DetectorConfig(const std::string& path_to_model) :
31+
CnnConfig(path_to_model) {}
3032

3133
float confidence_threshold{0.6f};
3234
float increase_scale_x{1.15f};
@@ -38,21 +40,21 @@ struct DetectorConfig : public CnnConfig {
3840

3941
class FaceDetection : public AsyncDetection<DetectedObject>, public BaseCnnDetection {
4042
private:
41-
DetectorConfig config_;
42-
InferenceEngine::ExecutableNetwork net_;
43-
std::string input_name_;
44-
std::string output_name_;
45-
int max_detections_count_ = 0;
46-
int object_size_ = 0;
47-
int enqueued_frames_ = 0;
48-
float width_ = 0;
49-
float height_ = 0;
43+
DetectorConfig m_config;
44+
ov::CompiledModel m_model;
45+
std::string m_input_name;
46+
std::string m_output_name;
47+
int m_max_detections_count = 0;
48+
int m_object_size = 0;
49+
int m_enqueued_frames = 0;
50+
float m_width = 0;
51+
float m_height = 0;
5052

5153
public:
5254
explicit FaceDetection(const DetectorConfig& config);
5355

5456
void submitRequest() override;
55-
void enqueue(const cv::Mat &frame) override;
57+
void enqueue(const cv::Mat& frame) override;
5658
void wait() override { BaseCnnDetection::wait(); }
5759

5860
DetectedObjects fetchResults() override;

demos/smart_classroom_demo/cpp/include/face_reid.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2018-2019 Intel Corporation
1+
// Copyright (C) 2018-2022 Intel Corporation
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

@@ -25,16 +25,16 @@ struct GalleryObject {
2525
int id;
2626

2727
GalleryObject(const std::vector<cv::Mat>& embeddings,
28-
const std::string& label, int id)
29-
: embeddings(embeddings), label(label), id(id) {}
28+
const std::string& label, int id) :
29+
embeddings(embeddings), label(label), id(id) {}
3030
};
3131

3232
class EmbeddingsGallery {
3333
public:
3434
static const char unknown_label[];
3535
static const int unknown_id;
3636
EmbeddingsGallery(const std::string& ids_list, double threshold, int min_size_fr,
37-
bool crop_gallery, const detection::DetectorConfig &detector_config,
37+
bool crop_gallery, const detection::DetectorConfig& detector_config,
3838
const VectorCNN& landmarks_det,
3939
const VectorCNN& image_reid,
4040
bool use_greedy_matcher=false);
@@ -52,7 +52,7 @@ class EmbeddingsGallery {
5252
detection::FaceDetection& detector,
5353
const VectorCNN& landmarks_det,
5454
const VectorCNN& image_reid,
55-
cv::Mat & embedding);
55+
cv::Mat& embedding);
5656
std::vector<int> idx_to_id;
5757
double reid_threshold;
5858
std::vector<GalleryObject> identities;

0 commit comments

Comments
 (0)