Skip to content

Commit 393d2ea

Browse files
authored
smart_classroom_demo: clarify -ad, fix bbox coordinates (#3626)
Ticket 97205
1 parent 5107ce2 commit 393d2ea

File tree

9 files changed

+47
-21
lines changed

9 files changed

+47
-21
lines changed

demos/smart_classroom_demo/cpp/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Options:
8484
-d_reid '<device>' Optional. Specify the target device for Face Reidentification 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.
8585
-greedy_reid_matching Optional. Use faster greedy matching algorithm in face reid.
8686
-r Optional. Output Inference results as raw values.
87-
-ad Optional. Output file name to save per-person action statistics in.
87+
-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
8888
-t_ad Optional. Probability threshold for person/action detection.
8989
-t_ar Optional. Probability threshold for action recognition.
9090
-t_fd Optional. Probability threshold for face detections.

demos/smart_classroom_demo/cpp/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,16 @@ int main(int argc, char* argv[]) {
544544
const auto actions_type = FLAGS_teacher_id.empty() ?
545545
(FLAGS_a_top > 0 ? TOP_K : STUDENT) :
546546
TEACHER;
547+
if (!FLAGS_ad.empty()) {
548+
if (actions_type != STUDENT) {
549+
slog::err << "-ad requires -teacher_id and -a_top to be unset" << slog::endl;
550+
return 1;
551+
}
552+
if (FLAGS_fg.empty()) {
553+
slog::err << "-ad requires -fg to be set" << slog::endl;
554+
return 1;
555+
}
556+
}
547557
const auto actions_map = actions_type == STUDENT ?
548558
split(FLAGS_student_ac, ',') : actions_type == TOP_K ?
549559
split(FLAGS_top_ac, ',') :

demos/smart_classroom_demo/cpp/smart_classroom_demo.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ static const char help_message[] = "Print a usage message.";
1818
static const char read_limit_message[] = "Optional. Read length limit before stopping or restarting reading the input.";
1919
static const char person_action_detection_model_message[] = "Required. Path to the Person/Action Detection Retail model (.xml) file.";
2020
static const char face_detection_model_message[] = "Required. Path to the Face Detection model (.xml) file.";
21-
static const char facial_landmarks_model_message[] = "Required. Path to the Facial Landmarks Regression Retail model (.xml) file.";
22-
static const char face_reid_model_message[] = "Required. Path to the Face Reidentification Retail model (.xml) file.";
21+
static const char facial_landmarks_model_message[] = "Optional. Path to the Facial Landmarks Regression Retail model (.xml) file.";
22+
static const char face_reid_model_message[] = "Optional. Path to the Face Reidentification Retail model (.xml) file.";
2323
static const char target_device_message_action_detection[] = "Optional. Specify the target device for Person/Action Detection Retail "
2424
"(the list of available devices is shown below). Default value is CPU. "
2525
"Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. "
@@ -42,7 +42,7 @@ static const char person_threshold_output_message[] = "Optional. Probability thr
4242
static const char action_threshold_output_message[] = "Optional. Probability threshold for action recognition.";
4343
static const char threshold_output_message_face_reid[] = "Optional. Cosine distance threshold between two vectors for face reidentification.";
4444
static const char reid_gallery_path_message[] = "Optional. Path to a faces gallery in .json format.";
45-
static const char act_stat_output_message[] = "Optional. Output file name to save per-person action statistics in.";
45+
static const char act_stat_output_message[] = "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";
4646
static const char raw_output_message[] = "Optional. Output Inference results as raw values.";
4747
static const char no_show_message[] = "Optional. Don't show output.";
4848
static const char input_image_height_output_message[] = "Optional. Input image height for face detector.";

demos/smart_classroom_demo/cpp/src/reid_gallery.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ size_t EmbeddingsGallery::size() const {
139139
return identities.size();
140140
}
141141

142-
std::vector<std::string> EmbeddingsGallery::GetIDToLabelMap() const {
142+
std::vector<std::string> EmbeddingsGallery::GetIDToLabelMap() const {
143143
std::vector<std::string> map;
144144
map.reserve(identities.size());
145-
for (const auto& item : identities) {
145+
for (const auto& item : identities) {
146146
map.emplace_back(item.label);
147147
}
148148
return map;

demos/smart_classroom_demo/cpp_gapi/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,20 @@ Options:
7272
-i Required. An input to process. The input must be a single image, a folder of images, video file or camera id.
7373
-loop Optional. Enable reading the input in a loop.
7474
-read_limit Optional. Read length limit before stopping or restarting reading the input.
75-
-o "<path>" Optional. Name of output to save.
75+
-o "<path>" Optional. Name of the output file(s) to save.
7676
-limit "<num>" Optional. Number of frames to store in output. If 0 is set, all frames are stored.
7777
-m_act '<path>' Required. Path to the Person/Action Detection Retail model (.xml) file.
7878
-m_fd '<path>' Required. Path to the Face Detection model (.xml) file.
7979
-m_lm '<path>' Required. Path to the Facial Landmarks Regression Retail model (.xml) file.
8080
-m_reid '<path>' Required. Path to the Face Reidentification Retail model (.xml) file.
81-
-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.
82-
-d_fd '<device>' Optional. Specify the target device for Face Detection Retail (the list of available devices is shown below). Default value is CPU.
83-
-d_lm '<device>' Optional. Specify the target device for Landmarks Regression Retail (the list of available devices is shown below). Default value is CPU.
84-
-d_reid '<device>' Optional. Specify the target device for Face Reidentification Retail (the list of available devices is shown below). Default value is CPU.
81+
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.
8586
-greedy_reid_matching Optional. Use faster greedy matching algorithm in face reid.
8687
-r Optional. Output Inference results as raw values.
87-
-ad Optional. Output file name to save per-person action statistics in.
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
8889
-t_ad Optional. Probability threshold for person/action detection.
8990
-t_ar Optional. Probability threshold for action recognition.
9091
-t_fd Optional. Probability threshold for face detections.

demos/smart_classroom_demo/cpp_gapi/include/initialize.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ bool isNetForSixActions(const std::string& model_path) {
7474
return model_path.at(model_path.size() - 5) == '6';
7575
}
7676

77-
std::shared_ptr<ActionDetection> createActDetPtr(const bool net_with_six_actions,
77+
std::shared_ptr<ActionDetection> createActDetPtr(const std::string& ad_model_path,
7878
const cv::Size frame_size,
7979
const size_t actions_map_size,
8080
const double t_ad,
8181
const double t_ar) {
8282
// Load action detector
8383
ActionDetectorConfig action_config;
84-
action_config.net_with_six_actions = net_with_six_actions;
84+
action_config.net_with_six_actions = config::isNetForSixActions(ad_model_path);
8585
action_config.detection_confidence_threshold = static_cast<float>(t_ad);
8686
action_config.action_confidence_threshold = static_cast<float>(t_ar);
8787
action_config.num_action_classes = actions_map_size;
@@ -188,7 +188,7 @@ void printInfo(const NetsFlagsPack& flags, std::string& teacher_id, std::string&
188188
}
189189
}
190190

191-
void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv::Scalar& reid_net_in_size) {
191+
void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv::Size& act_net_in_size, cv::Scalar& reid_net_in_size) {
192192
if (!flags.m_act.empty()) {
193193
const std::array<std::string, 7> action_detector_5 = {"mbox_loc1/out/conv/flat",
194194
"mbox_main_conf/out/conv/flat/softmax/flat",
@@ -217,6 +217,10 @@ void configNets(const NetsFlagsPack& flags, cv::gapi::GNetPackage& networks, cv:
217217
// clang-format on
218218

219219
networks += cv::gapi::networks(action_net);
220+
InferenceEngine::Core core;
221+
const auto layerData = core.ReadNetwork(flags.m_act).getInputsInfo().begin()->second;
222+
auto layerDims = layerData->getTensorDesc().getDims();
223+
act_net_in_size = {int(layerDims[3]), int(layerDims[2])};
220224
slog::info << "The Person/Action Detection model " << flags.m_act << " is loaded to " << flags.d_act
221225
<< " device." << slog::endl;
222226
} else {

demos/smart_classroom_demo/cpp_gapi/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,15 @@ int main(int argc, char* argv[]) {
149149
cv::gapi::GNetPackage networks;
150150

151151
/** Configure nets **/
152+
cv::Size act_net_in_size;
152153
cv::Scalar reid_net_in_size;
153-
config::configNets(netsFlags, networks, reid_net_in_size);
154+
config::configNets(netsFlags, networks, act_net_in_size, reid_net_in_size);
154155

155156
/** Configure and create action detector **/
156157
std::shared_ptr<ActionDetection> act_det_ptr;
157158
if (!ad_model_path.empty()) {
158-
act_det_ptr = config::createActDetPtr(config::isNetForSixActions(ad_model_path),
159-
frame_size,
159+
act_det_ptr = config::createActDetPtr(ad_model_path,
160+
act_net_in_size,
160161
const_params.actions_map.size(),
161162
FLAGS_t_ad,
162163
FLAGS_t_ar);
@@ -185,6 +186,16 @@ int main(int argc, char* argv[]) {
185186
slog::err << "Teacher id does not exist in the gallery!" << slog::endl;
186187
return 1;
187188
}
189+
if (!FLAGS_ad.empty()) {
190+
if (const_params.actions_type != STUDENT) {
191+
slog::err << "-ad requires -teacher_id and -a_top to be unset" << slog::endl;
192+
return 1;
193+
}
194+
if (FLAGS_fg.empty()) {
195+
slog::err << "-ad requires -fg to be set" << slog::endl;
196+
return 1;
197+
}
198+
}
188199

189200
/** ---------------- Main graph of demo ---------------- **/
190201
cv::GMat in;

demos/smart_classroom_demo/cpp_gapi/smart_classroom_demo_gapi.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static const char action_threshold_output_message[] = "Optional. Probability thr
4545
static const char threshold_output_message_face_reid[] =
4646
"Optional. Cosine distance threshold between two vectors for face reidentification.";
4747
static const char reid_gallery_path_message[] = "Optional. Path to a faces gallery in .json format.";
48-
static const char act_stat_output_message[] = "Optional. Output file name to save per-person action statistics in.";
48+
static const char act_stat_output_message[] = "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";
4949
static const char raw_output_message[] = "Optional. Output Inference results as raw values.";
5050
static const char no_show_message[] = "Optional. Don't show output.";
5151
static const char input_image_height_output_message[] = "Optional. Input image height for face detector.";

demos/smart_classroom_demo/cpp_gapi/src/action_detector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ inline ActionDetection::NormalizedBBox ActionDetection::GeneratePriorBox(int pos
8787
int step,
8888
const cv::Size2f& anchor,
8989
const cv::Size& blob_size) const {
90-
const float row = static_cast<float>(pos / blob_size.width);
91-
const float col = static_cast<float>(pos % blob_size.width);
90+
const int row = pos / blob_size.width;
91+
const int col = pos % blob_size.width;
9292

9393
const float center_x = (col + 0.5f) * static_cast<float>(step);
9494
const float center_y = (row + 0.5f) * static_cast<float>(step);

0 commit comments

Comments
 (0)