17 {
18 try {
19
20 op::checkBool(
21 0 <= FLAGS_logging_level && FLAGS_logging_level <= 255, "Wrong logging_level value.",
22 __LINE__, __FUNCTION__, __FILE__);
23 op::ConfigureLog::setPriorityThreshold((op::Priority)FLAGS_logging_level);
24 op::Profiler::setDefaultX(FLAGS_profile_speed);
25
26
27
28 const auto outputSize = op::flagsToPoint(op::String(FLAGS_output_resolution), "-1x-1");
29
30 const auto netInputSize = op::flagsToPoint(op::String(FLAGS_net_resolution), "-1x368");
31
32 const auto faceNetInputSize = op::flagsToPoint(op::String(FLAGS_face_net_resolution), "368x368 (multiples of 16)");
33
34 const auto handNetInputSize = op::flagsToPoint(op::String(FLAGS_hand_net_resolution), "368x368 (multiples of 16)");
35
36 const auto poseMode = op::flagsToPoseMode(FLAGS_body);
37
38 const auto poseModel = op::flagsToPoseModel(op::String(FLAGS_model_pose));
39
40 if (!FLAGS_write_keypoint.empty()) {
41 op::opLog("Flag 'write_keypoint' is deprecated and will eventually be removed. Please, use 'write_json'"
42 " instead.", op::Priority::Max);
43 }
44
45 const auto keypointScaleMode = op::flagsToScaleMode(FLAGS_keypoint_scale);
46
47 const auto heatMapTypes = op::flagsToHeatMaps(FLAGS_heatmaps_add_parts, FLAGS_heatmaps_add_bkg,
48 FLAGS_heatmaps_add_PAFs);
49 const auto heatMapScaleMode = op::flagsToHeatMapScaleMode(FLAGS_heatmaps_scale);
50
51 const auto multipleView = (FLAGS_3d || FLAGS_3d_views > 1);
52
53 const auto faceDetector = op::flagsToDetector(FLAGS_face_detector);
54 const auto handDetector = op::flagsToDetector(FLAGS_hand_detector);
55
56 const bool enableGoogleLogging = true;
57
58
59 const op::WrapperStructPose wrapperStructPose{
60 poseMode, netInputSize, FLAGS_net_resolution_dynamic, outputSize, keypointScaleMode, FLAGS_num_gpu,
61 FLAGS_num_gpu_start, FLAGS_scale_number, (float)FLAGS_scale_gap,
62 op::flagsToRenderMode(FLAGS_render_pose, multipleView), poseModel, !FLAGS_disable_blending,
63 (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, op::String(FLAGS_model_folder),
64 heatMapTypes, heatMapScaleMode, FLAGS_part_candidates, (float)FLAGS_render_threshold,
65 FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, op::String(FLAGS_prototxt_path),
66 op::String(FLAGS_caffemodel_path), (float)FLAGS_upsampling_ratio, enableGoogleLogging};
67 opWrapper.configure(wrapperStructPose);
68
69 const op::WrapperStructFace wrapperStructFace{
70 FLAGS_face, faceDetector, faceNetInputSize,
71 op::flagsToRenderMode(FLAGS_face_render, multipleView, FLAGS_render_pose),
72 (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold};
73 opWrapper.configure(wrapperStructFace);
74
75 const op::WrapperStructHand wrapperStructHand{
76 FLAGS_hand, handDetector, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range,
77 op::flagsToRenderMode(FLAGS_hand_render, multipleView, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose,
78 (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold};
79 opWrapper.configure(wrapperStructHand);
80
81 const op::WrapperStructExtra wrapperStructExtra{
82 FLAGS_3d, FLAGS_3d_min_views, FLAGS_identification, FLAGS_tracking, FLAGS_ik_threads};
83 opWrapper.configure(wrapperStructExtra);
84
85 const op::WrapperStructOutput wrapperStructOutput{
86 FLAGS_cli_verbose, op::String(FLAGS_write_keypoint), op::stringToDataFormat(FLAGS_write_keypoint_format),
87 op::String(FLAGS_write_json), op::String(FLAGS_write_coco_json), FLAGS_write_coco_json_variants,
88 FLAGS_write_coco_json_variant, op::String(FLAGS_write_images), op::String(FLAGS_write_images_format),
89 op::String(FLAGS_write_video), FLAGS_write_video_fps, FLAGS_write_video_with_audio,
90 op::String(FLAGS_write_heatmaps), op::String(FLAGS_write_heatmaps_format), op::String(FLAGS_write_video_3d),
91 op::String(FLAGS_write_video_adam), op::String(FLAGS_write_bvh), op::String(FLAGS_udp_host),
92 op::String(FLAGS_udp_port)};
93 opWrapper.configure(wrapperStructOutput);
94
95
96 if (FLAGS_disable_multi_thread)
97 opWrapper.disableMultiThreading();
98 } catch (const std::exception & e) {
99 op::error(e.what(), __LINE__, __FUNCTION__, __FILE__);
100 }
101}