Skip to content

Commit c5037f3

Browse files
committed
fix 1 part of remaining demos
1 parent a9bef2a commit c5037f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1702
-1316
lines changed

demos/crossroad_camera_demo/cpp/crossroad_camera_demo.hpp

+38-28
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,50 @@
44

55
///////////////////////////////////////////////////////////////////////////////////////////////////
66
#pragma once
7+
#include <iostream>
78

8-
#include "gflags/gflags.h"
9-
#include "utils/default_flags.hpp"
9+
#include <gflags/gflags.h>
10+
11+
#include <utils/default_flags.hpp>
1012

1113
DEFINE_INPUT_FLAGS
1214
DEFINE_OUTPUT_FLAGS
1315

1416
static const char help_message[] = "Print a usage message.";
15-
static const char person_vehicle_bike_detection_model_message[] = "Required. Path to the Person/Vehicle/Bike Detection Crossroad model (.xml) file.";
16-
static const char person_attribs_model_message[] = "Optional. Path to the Person Attributes Recognition Crossroad model (.xml) file.";
17-
static const char person_reid_model_message[] = "Optional. Path to the Person Reidentification Retail model (.xml) file.";
18-
static const char target_device_message[] = "Optional. Specify the target device for Person/Vehicle/Bike Detection. "
19-
"The list of available devices is shown below. Default value is CPU. "
20-
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
21-
"The application looks for a suitable plugin for the specified device.";
22-
static const char target_device_message_person_attribs[] = "Optional. Specify the target device for Person Attributes Recognition. "
23-
"The list of available devices is shown below. Default value is CPU. "
24-
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
25-
"The application looks for a suitable plugin for the specified device.";
26-
static const char target_device_message_person_reid[] = "Optional. Specify the target device for Person Reidentification Retail. "
27-
"The list of available devices is shown below. Default value is CPU. "
28-
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
29-
"The application looks for a suitable plugin for the specified device.";
30-
static const char threshold_output_message[] = "Optional. Probability threshold for person/vehicle/bike crossroad detections.";
31-
static const char threshold_output_message_person_reid[] = "Optional. Cosine similarity threshold between two vectors for person reidentification.";
17+
static const char person_vehicle_bike_detection_model_message[] =
18+
"Required. Path to the Person/Vehicle/Bike Detection Crossroad model (.xml) file.";
19+
static const char person_attribs_model_message[] =
20+
"Optional. Path to the Person Attributes Recognition Crossroad model (.xml) file.";
21+
static const char person_reid_model_message[] =
22+
"Optional. Path to the Person Reidentification Retail model (.xml) file.";
23+
static const char target_device_message[] =
24+
"Optional. Specify the target device for Person/Vehicle/Bike Detection. "
25+
"The list of available devices is shown below. Default value is CPU. "
26+
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
27+
"The application looks for a suitable plugin for the specified device.";
28+
static const char target_device_message_person_attribs[] =
29+
"Optional. Specify the target device for Person Attributes Recognition. "
30+
"The list of available devices is shown below. Default value is CPU. "
31+
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
32+
"The application looks for a suitable plugin for the specified device.";
33+
static const char target_device_message_person_reid[] =
34+
"Optional. Specify the target device for Person Reidentification Retail. "
35+
"The list of available devices is shown below. Default value is CPU. "
36+
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
37+
"The application looks for a suitable plugin for the specified device.";
38+
static const char threshold_output_message[] =
39+
"Optional. Probability threshold for person/vehicle/bike crossroad detections.";
40+
static const char threshold_output_message_person_reid[] =
41+
"Optional. Cosine similarity threshold between two vectors for person reidentification.";
3242
static const char raw_output_message[] = "Optional. Output Inference results as raw values.";
3343
static const char no_show_message[] = "Optional. Don't show output.";
34-
static const char input_resizable_message[] = "Optional. Enables resizable input with support of ROI crop & auto resize.";
44+
static const char input_resizable_message[] =
45+
"Optional. Enables resizable input with support of ROI crop & auto resize.";
3546
static const char utilization_monitors_message[] = "Optional. List of monitors to show initially.";
36-
static const char person_label_message[] = "Optional. The integer index of the objects' category corresponding to persons "
37-
"(as it is returned from the detection network, may vary from one network to another). "
38-
"The default value is 1.";
39-
47+
static const char person_label_message[] =
48+
"Optional. The integer index of the objects' category corresponding to persons "
49+
"(as it is returned from the detection network, may vary from one network to another). "
50+
"The default value is 1.";
4051

4152
DEFINE_bool(h, false, help_message);
4253
DEFINE_string(m, "", person_vehicle_bike_detection_model_message);
@@ -53,10 +64,9 @@ DEFINE_bool(auto_resize, false, input_resizable_message);
5364
DEFINE_string(u, "", utilization_monitors_message);
5465
DEFINE_int32(person_label, 1, person_label_message);
5566

56-
5767
/**
58-
* @brief This function show a help message
59-
*/
68+
* @brief This function show a help message
69+
*/
6070
static void showUsage() {
6171
std::cout << std::endl;
6272
std::cout << "crossroad_camera_demo [OPTION]" << std::endl;
@@ -67,7 +77,7 @@ static void showUsage() {
6777
std::cout << " -loop " << loop_message << std::endl;
6878
std::cout << " -o \"<path>\" " << output_message << std::endl;
6979
std::cout << " -limit \"<num>\" " << limit_message << std::endl;
70-
std::cout << " -m \"<path>\" " << person_vehicle_bike_detection_model_message<< std::endl;
80+
std::cout << " -m \"<path>\" " << person_vehicle_bike_detection_model_message << std::endl;
7181
std::cout << " -m_pa \"<path>\" " << person_attribs_model_message << std::endl;
7282
std::cout << " -m_reid \"<path>\" " << person_reid_model_message << std::endl;
7383
std::cout << " -d \"<device>\" " << target_device_message << std::endl;

demos/crossroad_camera_demo/cpp/detection_base.hpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5+
#include <memory>
56
#include <string>
6-
#include "openvino/openvino.hpp"
7-
#include "utils/slog.hpp"
7+
8+
#include <opencv2/core/types.hpp>
9+
#include <openvino/openvino.hpp>
10+
11+
#include <utils/ocv_common.hpp>
12+
#include <utils/slog.hpp>
813

914
#pragma once
1015

@@ -17,8 +22,9 @@ struct BaseDetection {
1722
std::string m_inputName;
1823
std::string m_outputName;
1924

20-
BaseDetection(std::string& commandLineFlag, const std::string& detectorName) :
21-
m_commandLineFlag(commandLineFlag), m_detectorName(detectorName) {}
25+
BaseDetection(std::string& commandLineFlag, const std::string& detectorName)
26+
: m_commandLineFlag(commandLineFlag),
27+
m_detectorName(detectorName) {}
2228

2329
ov::CompiledModel* operator->() {
2430
return &m_compiled_model;
@@ -53,7 +59,7 @@ struct BaseDetection {
5359
}
5460

5561
virtual void wait() {
56-
if (!enabled()|| !m_infer_request)
62+
if (!enabled() || !m_infer_request)
5763
return;
5864

5965
m_infer_request.wait();
@@ -62,11 +68,12 @@ struct BaseDetection {
6268
mutable bool m_enablingChecked = false;
6369
mutable bool m_enabled = false;
6470

65-
bool enabled() const {
71+
bool enabled() const {
6672
if (!m_enablingChecked) {
6773
m_enabled = !m_commandLineFlag.empty();
6874
if (!m_enabled) {
6975
slog::info << m_detectorName << " detection DISABLED" << slog::endl;
76+
} else {
7077
}
7178
m_enablingChecked = true;
7279
}
@@ -81,7 +88,10 @@ struct Load {
8188
void into(ov::Core& core, const std::string& deviceName) const {
8289
if (m_detector.enabled()) {
8390
m_detector.m_compiled_model = core.compile_model(m_detector.read(core), deviceName);
84-
logCompiledModelInfo(m_detector.m_compiled_model, m_detector.m_commandLineFlag, deviceName, m_detector.m_detectorName);
91+
logCompiledModelInfo(m_detector.m_compiled_model,
92+
m_detector.m_commandLineFlag,
93+
deviceName,
94+
m_detector.m_detectorName);
8595
}
8696
}
8797
};

demos/crossroad_camera_demo/cpp/detection_person.hpp

+24-22
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
// SPDX-License-Identifier: Apache-2.0
33
//
44

5+
#include <memory>
56
#include <string>
7+
#include <vector>
68

7-
#include "openvino/openvino.hpp"
9+
#include <gflags/gflags.h>
10+
#include <openvino/openvino.hpp>
11+
12+
#include <utils/slog.hpp>
813

9-
#include "gflags/gflags.h"
10-
#include "utils/slog.hpp"
11-
#include "detection_base.hpp"
1214
#include "crossroad_camera_demo.hpp"
15+
#include "detection_base.hpp"
1316

1417
struct PersonDetection : BaseDetection {
1518
size_t maxProposalCount;
@@ -86,25 +89,25 @@ struct PersonDetection : BaseDetection {
8689
throw std::logic_error("Incorrect output dimensions for SSD");
8790
}
8891

89-
const ov::Layout tensor_layout{ "NHWC" };
92+
const ov::Layout tensor_layout{"NHWC"};
9093

9194
ov::preprocess::PrePostProcessor ppp = ov::preprocess::PrePostProcessor(model);
9295

9396
if (FLAGS_auto_resize) {
94-
ppp.input().tensor().
95-
set_element_type(ov::element::u8).
96-
set_spatial_dynamic_shape().
97-
set_layout(tensor_layout);
98-
ppp.input().preprocess().
99-
convert_element_type(ov::element::f32).
100-
convert_layout("NCHW").
101-
resize(ov::preprocess::ResizeAlgorithm::RESIZE_LINEAR);
97+
ppp.input()
98+
.tensor()
99+
.set_element_type(ov::element::u8)
100+
.set_spatial_dynamic_shape()
101+
.set_layout(tensor_layout);
102+
ppp.input()
103+
.preprocess()
104+
.convert_element_type(ov::element::f32)
105+
.convert_layout("NCHW")
106+
.resize(ov::preprocess::ResizeAlgorithm::RESIZE_LINEAR);
102107
ppp.input().model().set_layout("NCHW");
103108
ppp.output().tensor().set_element_type(ov::element::f32);
104109
} else {
105-
ppp.input().tensor().
106-
set_element_type(ov::element::u8).
107-
set_layout({ "NCHW" });
110+
ppp.input().tensor().set_element_type(ov::element::u8).set_layout({"NCHW"});
108111
}
109112

110113
model = ppp.build();
@@ -125,7 +128,7 @@ struct PersonDetection : BaseDetection {
125128
const float* detections = m_infer_request.get_output_tensor().data<float>();
126129
// pretty much regular SSD post-processing
127130
for (size_t i = 0; i < maxProposalCount; i++) {
128-
float image_id = detections[i * objectSize + 0]; // in case of batch
131+
float image_id = detections[i * objectSize + 0]; // in case of batch
129132
if (image_id < 0) {
130133
// end of detections
131134
break;
@@ -145,11 +148,10 @@ struct PersonDetection : BaseDetection {
145148
}
146149

147150
if (FLAGS_r) {
148-
slog::debug <<
149-
"[" << i << "," << r.label << "] element, prob = " << r.confidence <<
150-
" (" << r.location.x << "," << r.location.y <<
151-
")-(" << r.location.width << "," << r.location.height << ")" <<
152-
((r.confidence > FLAGS_t) ? " WILL BE RENDERED!" : "") << slog::endl;
151+
slog::debug << "[" << i << "," << r.label << "] element, prob = " << r.confidence << " ("
152+
<< r.location.x << "," << r.location.y << ")-(" << r.location.width << ","
153+
<< r.location.height << ")" << ((r.confidence > FLAGS_t) ? " WILL BE RENDERED!" : "")
154+
<< slog::endl;
153155
}
154156
results.push_back(r);
155157
}

0 commit comments

Comments
 (0)