Skip to content

Commit 9203199

Browse files
Fix G-API smart classroom demo (#3881)
* Fix G-API smart classroom demo by converting to OV 2.0 backend * Remove layout config * Disable cpp_gapi test with low OpenCV version outside github-actions tests * Update demos/tests/cases.py --------- Co-authored-by: Zlobin Vladimir <[email protected]>
1 parent f7b5e2c commit 9203199

File tree

8 files changed

+136
-133
lines changed

8 files changed

+136
-133
lines changed

.github/workflows/cpp_gapi-demos.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ jobs:
1313
- name: Download OpenVINO
1414
run: |
1515
mkdir ov
16-
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.1/linux/l_openvino_toolkit_ubuntu20_2023.1.0.12185.47b736f63ed_x86_64.tgz | tar --directory ov --strip-components 1 -xz
16+
curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2023.2/linux/l_openvino_toolkit_ubuntu20_2023.2.0.13089.cfd42bd2cb0_x86_64.tgz | tar --directory ov --strip-components 1 -xz
1717
sudo ov/install_dependencies/install_openvino_dependencies.sh
1818
sudo apt install libgtk2.0-dev pkg-config # smart_classroom_demo_gapi's OpenCV error asks to install them
1919
- uses: hendrikmuhs/[email protected]
2020
with:
21-
key: ubuntu20_2023.1.0.12185.47b736f63ed # This action prepends and appends its strings to the key
21+
key: ubuntu20_2023.2.0.13089.cfd42bd2cb0 # This action prepends and appends its strings to the key
2222
restore: ${{ github.event_name == 'pull_request'}}
2323
- if: ${{ github.event_name == 'pull_request'}}
2424
uses: actions/cache/restore@v3
2525
id: cache
2626
with:
2727
path: ${{ github.workspace }}/cache
2828
key: unused
29-
restore-keys: ubuntu20_2023.1.0.12185.47b736f63ed-
29+
restore-keys: ubuntu20_2023.2.0.13089.cfd42bd2cb0-
3030
- if: ${{ !steps.cache.outputs.cache-hit }}
3131
uses: actions/checkout@v3
3232
with:

demos/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ if(NOT OpenCV_FOUND)
149149
message(WARNING "No suitable OpenCV version detected, GAPI demos skipped")
150150
set(GAPI_DEMO_DISABLED ON)
151151
else()
152-
add_subdirectory(common/cpp_gapi)
152+
if(OpenCV_VERSION VERSION_LESS "4.8")
153+
message(WARNING "OpenCV version lower than 4.8 detected, GAPI demos skipped")
154+
set(GAPI_DEMO_DISABLED ON)
155+
else()
156+
add_subdirectory(common/cpp_gapi)
157+
endif()
153158
endif()
154159

155160
add_subdirectory(multi_channel_common/cpp)

demos/smart_classroom_demo/cpp_gapi/README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -68,47 +68,47 @@ Running the application with the `-h` option yields the following usage message:
6868
smart_classroom_demo_gapi [OPTION]
6969
Options:
7070
71-
-h Print a usage message.
72-
-i Required. An input to process. The input must be a single image, a folder of images, video file or camera id.
73-
-loop Optional. Enable reading the input in a loop.
74-
-read_limit Optional. Read length limit before stopping or restarting reading the input.
75-
-o "<path>" Optional. Name of the output file(s) to save. Frames of odd width or height can be truncated. See https://github.com/opencv/opencv/pull/24086
76-
-limit "<num>" Optional. Number of frames to store in output. If 0 is set, all frames are stored.
77-
-m_act '<path>' Required. Path to the Person/Action Detection Retail model (.xml) file.
78-
-m_fd '<path>' Required. Path to the Face Detection model (.xml) file.
79-
-m_lm '<path>' Required. Path to the Facial Landmarks Regression Retail model (.xml) file.
80-
-m_reid '<path>' Required. Path to the Face Reidentification Retail model (.xml) file.
71+
-h Print a usage message.
72+
-i Required. An input to process. The input must be a single image, a folder of images, video file or camera id.
73+
-loop Optional. Enable reading the input in a loop.
74+
-read_limit Optional. Read length limit before stopping or restarting reading the input.
75+
-o "<path>" Optional. Name of the output file(s) to save. Frames of odd width or height can be truncated. See https://github.com/opencv/opencv/pull/24086
76+
-limit "<num>" Optional. Number of frames to store in output. If 0 is set, all frames are stored.
77+
-m_act '<path>' Required. Path to the Person/Action Detection Retail model (.xml) file.
78+
-m_fd '<path>' Required. Path to the Face Detection model (.xml) file.
79+
-m_lm '<path>' Required. Path to the Facial Landmarks Regression Retail model (.xml) file.
80+
-m_reid '<path>' Required. Path to the Face Reidentification Retail model (.xml) file.
8181
Or
82-
-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. The application looks for a suitable plugin for the specified device.
83-
-d_fd '<device>' Optional. Specify the target device for Face Detection Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
84-
-d_lm '<device>' Optional. Specify the target device for Landmarks Regression Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
85-
-d_reid '<device>' Optional. Specify the target device for Face Reidentification Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
86-
-greedy_reid_matching Optional. Use faster greedy matching algorithm in face reid.
87-
-r Optional. Output Inference results as raw values.
88-
-ad Optional. Output file name to save per-person action statistics in. Requires -teacher_id and -a_top to be unset and -fg to be set
89-
-t_ad Optional. Probability threshold for person/action detection.
90-
-t_ar Optional. Probability threshold for action recognition.
91-
-t_fd Optional. Probability threshold for face detections.
92-
-inh_fd Optional. Input image height for face detector.
93-
-inw_fd Optional. Input image width for face detector.
94-
-exp_r_fd Optional. Expand ratio for bbox before face recognition.
95-
-t_reid Optional. Cosine distance threshold between two vectors for face reidentification.
96-
-fg Optional. Path to a faces gallery in .json format.
97-
-teacher_id Optional. ID of a teacher. You must also set a faces gallery parameter (-fg) to use it.
98-
-no_show Optional. Don't show output.
99-
-min_ad Optional. Minimum action duration in seconds.
100-
-d_ad Optional. Maximum time difference between actions in seconds.
101-
-student_ac Optional. List of student actions separated by a comma.
102-
-top_ac Optional. List of student actions (for top-k mode) separated by a comma.
103-
-teacher_ac Optional. List of teacher actions separated by a comma.
104-
-top_id Optional. Target action name.
105-
-a_top Optional. Number of first K students. If this parameter is positive, the demo detects first K persons with the action, pointed by the parameter 'top_id'
106-
-crop_gallery Optional. Crop images during faces gallery creation.
107-
-t_reg_fd Optional. Probability threshold for face detections during database registration.
108-
-min_size_fr Optional. Minimum input size for faces during database registration.
109-
-al Optional. Output file name to save per-person action detections in.
110-
-ss_t Optional. Number of frames to smooth actions.
111-
-u Optional. List of monitors to show initially.
82+
-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. The application looks for a suitable plugin for the specified device.
83+
-d_fd '<device>' Optional. Specify the target device for Face Detection Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
84+
-d_lm '<device>' Optional. Specify the target device for Landmarks Regression Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
85+
-d_reid '<device>' Optional. Specify the target device for Face Reidentification Retail (the list of available devices is shown below). Default value is CPU. The application looks for a suitable plugin for the specified device.
86+
-greedy_reid_matching Optional. Use faster greedy matching algorithm in face reid.
87+
-r Optional. Output Inference results as raw values.
88+
-ad Optional. Output file name to save per-person action statistics in. Requires -teacher_id and -a_top to be unset and -fg to be set
89+
-t_ad Optional. Probability threshold for person/action detection.
90+
-t_ar Optional. Probability threshold for action recognition.
91+
-t_fd Optional. Probability threshold for face detections.
92+
-inh_fd Optional. Input image height for face detector.
93+
-inw_fd Optional. Input image width for face detector.
94+
-exp_r_fd Optional. Expand ratio for bbox before face recognition.
95+
-t_reid Optional. Cosine distance threshold between two vectors for face reidentification.
96+
-fg Optional. Path to a faces gallery in .json format.
97+
-teacher_id Optional. ID of a teacher. You must also set a faces gallery parameter (-fg) to use it.
98+
-no_show Optional. Don't show output.
99+
-min_ad Optional. Minimum action duration in seconds.
100+
-d_ad Optional. Maximum time difference between actions in seconds.
101+
-student_ac Optional. List of student actions separated by a comma.
102+
-top_ac Optional. List of student actions (for top-k mode) separated by a comma.
103+
-teacher_ac Optional. List of teacher actions separated by a comma.
104+
-top_id Optional. Target action name.
105+
-a_top Optional. Number of first K students. If this parameter is positive, the demo detects first K persons with the action, pointed by the parameter 'top_id'
106+
-crop_gallery Optional. Crop images during faces gallery creation.
107+
-t_reg_fd Optional. Probability threshold for face detections during database registration.
108+
-min_size_fr Optional. Minimum input size for faces during database registration.
109+
-al Optional. Output file name to save per-person action detections in.
110+
-ss_t Optional. Number of frames to smooth actions.
111+
-u Optional. List of monitors to show initially.
112112
```
113113

114114
Running the application with the empty list of options yields an error message.

demos/smart_classroom_demo/cpp_gapi/include/initialize.hpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <vector>
1313

1414
#include <opencv2/gapi/infer/ie.hpp>
15+
#include <opencv2/gapi/infer/ov.hpp>
1516
#include <opencv2/gapi/infer/parsers.hpp>
1617
#include <openvino/openvino.hpp>
1718

@@ -188,26 +189,26 @@ void printInfo(const NetsFlagsPack& flags, std::string& teacher_id, std::string&
188189

189190
void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv::Size& act_net_in_size, cv::Scalar& reid_net_in_size) {
190191
if (!flags.m_act.empty()) {
191-
const std::array<std::string, 7> action_detector_5 = {"mbox_loc1/out/conv/flat",
192-
"mbox_main_conf/out/conv/flat/softmax/flat",
193-
"mbox/priorbox",
194-
"out/anchor1",
195-
"out/anchor2",
196-
"out/anchor3",
197-
"out/anchor4"};
198-
const std::array<std::string, 7> action_detector_6 = {"ActionNet/out_detection_loc",
199-
"ActionNet/out_detection_conf",
200-
"ActionNet/action_heads/out_head_1_anchor_1",
201-
"ActionNet/action_heads/out_head_2_anchor_1",
202-
"ActionNet/action_heads/out_head_2_anchor_2",
203-
"ActionNet/action_heads/out_head_2_anchor_3",
204-
"ActionNet/action_heads/out_head_2_anchor_4"};
192+
const std::vector<std::string> action_detector_5 = {"mbox_loc1/out/conv/flat",
193+
"mbox_main_conf/out/conv/flat/softmax/flat",
194+
"mbox/priorbox",
195+
"out/anchor1",
196+
"out/anchor2",
197+
"out/anchor3",
198+
"out/anchor4"};
199+
const std::vector<std::string> action_detector_6 = {"ActionNet/out_detection_loc",
200+
"ActionNet/out_detection_conf",
201+
"ActionNet/action_heads/out_head_1_anchor_1",
202+
"ActionNet/action_heads/out_head_2_anchor_1",
203+
"ActionNet/action_heads/out_head_2_anchor_2",
204+
"ActionNet/action_heads/out_head_2_anchor_3",
205+
"ActionNet/action_heads/out_head_2_anchor_4"};
205206
/** Create action detector net's parameters **/
206-
std::array<std::string, 7> outputBlobList =
207+
std::vector<std::string> outputBlobList =
207208
isNetForSixActions(flags.m_act) ? action_detector_6 : action_detector_5;
208209
// clang-format off
209210
auto action_net =
210-
cv::gapi::ie::Params<nets::PersonDetActionRec>{
211+
cv::gapi::ov::Params<nets::PersonDetActionRec>{
211212
flags.m_act,
212213
fileNameNoExt(flags.m_act) + ".bin",
213214
flags.d_act,
@@ -228,12 +229,11 @@ void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv:
228229
/** Create face detector net's parameters **/
229230
// clang-format off
230231
auto det_net =
231-
cv::gapi::ie::Params<nets::FaceDetector>{
232+
cv::gapi::ov::Params<nets::FaceDetector>{
232233
flags.m_fd,
233234
fileNameNoExt(flags.m_fd) + ".bin",
234235
flags.d_fd,
235-
}.cfgInputReshape("data",
236-
{1u, 3u, static_cast<size_t>(flags.inh_fd), static_cast<size_t>(flags.inw_fd)});
236+
}.cfgReshape({1u, 3u, static_cast<size_t>(flags.inh_fd), static_cast<size_t>(flags.inw_fd)});
237237
// clang-format on
238238

239239
networks += cv::gapi::networks(det_net);
@@ -245,7 +245,7 @@ void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv:
245245

246246
if (!flags.m_fd.empty() && !flags.m_reid.empty() && !flags.m_lm.empty()) {
247247
/** Create landmarks detector net's parameters **/
248-
auto landm_net = cv::gapi::ie::Params<nets::LandmarksDetector>{
248+
auto landm_net = cv::gapi::ov::Params<nets::LandmarksDetector>{
249249
flags.m_lm,
250250
fileNameNoExt(flags.m_lm) + ".bin",
251251
flags.d_lm,
@@ -257,7 +257,7 @@ void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv:
257257
slog::info << "Facial Landmarks Regression DISABLED." << slog::endl;
258258
}
259259
/** Create reidentification net's parameters **/
260-
auto reident_net = cv::gapi::ie::Params<nets::FaceReidentificator>{
260+
auto reident_net = cv::gapi::ov::Params<nets::FaceReidentificator>{
261261
flags.m_reid,
262262
fileNameNoExt(flags.m_reid) + ".bin",
263263
flags.d_reid,

demos/smart_classroom_demo/cpp_gapi/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ int main(int argc, char* argv[]) {
117117
}
118118

119119
/** Prepare parameters **/
120-
const std::string video_path = FLAGS_i;
121-
const auto ad_model_path = FLAGS_m_act;
122-
const auto fd_model_path = FLAGS_m_fd;
123-
const auto fr_model_path = FLAGS_m_reid;
124-
const auto lm_model_path = FLAGS_m_lm;
120+
const std::string video_path = FLAGS_i;
121+
const auto ad_model_path = FLAGS_m_act;
122+
const auto fd_model_path = FLAGS_m_fd;
123+
const auto fr_model_path = FLAGS_m_reid;
124+
const auto lm_model_path = FLAGS_m_lm;
125125

126126
/** Pack demo flags to appropriate unions **/
127127
config::NetsFlagsPack netsFlags;

0 commit comments

Comments
 (0)