MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / setGlobalParametersFromFlags

Function setGlobalParametersFromFlags

rtpose_wrapper/apps/rtpose.cpp:2337–2405  ·  view source on GitHub ↗

The global parameters must be assign after the main has started, not statically before. Otherwise, they will take the default values, not the user-introduced values.

Source from the content-addressed store, hash-verified

2335// not statically before. Otherwise, they will take the default values,
2336// not the user-introduced values.
2337int setGlobalParametersFromFlags() {
2338 if (DISPLAY_RESOLUTION_WIDTH==-1 && !_video.empty()) {
2339 cv::VideoCapture cap;
2340 CHECK(cap.open(_video)) << "Couldn't open video " << _video;
2341 DISPLAY_RESOLUTION_WIDTH = cap.get(CV_CAP_PROP_FRAME_WIDTH);
2342 DISPLAY_RESOLUTION_HEIGHT = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
2343 LOG(INFO) << "Setting display resolution from video: "
2344 << DISPLAY_RESOLUTION_WIDTH << "x" << DISPLAY_RESOLUTION_HEIGHT;
2345 } else if (DISPLAY_RESOLUTION_WIDTH==-1 && !_image_dir.empty()) {
2346 cv::Mat image_uchar_orig = cv::imread(global.image_list[0].c_str(),
2347 CV_LOAD_IMAGE_COLOR);
2348 DISPLAY_RESOLUTION_WIDTH = image_uchar_orig.cols;
2349 DISPLAY_RESOLUTION_HEIGHT = image_uchar_orig.rows;
2350 LOG(INFO) << "Setting display resolution from first image: "
2351 << DISPLAY_RESOLUTION_WIDTH << "x" << DISPLAY_RESOLUTION_HEIGHT;
2352 } else if (DISPLAY_RESOLUTION_WIDTH==-1) {
2353 LOG(ERROR) << "Invalid resolution without video/images: "
2354 << DISPLAY_RESOLUTION_WIDTH << "x" << DISPLAY_RESOLUTION_HEIGHT;
2355 exit(1);
2356 } else {
2357 LOG(INFO) << "Display resolution: " << DISPLAY_RESOLUTION_WIDTH
2358 << "x" << DISPLAY_RESOLUTION_HEIGHT;
2359 }
2360 // nRead = sscanf(_camera_resolution.c_str(), "%dx%d",
2361 // &CAMERA_FRAME_WIDTH, &CAMERA_FRAME_HEIGHT);
2362 // CHECK_EQ(nRead,2) << "Error, camera resolution format ("
2363 // << _camera_resolution
2364 // << ") invalid, should be e.g., 1280x720";
2365 int nRead = sscanf(_net_resolution.c_str(), "%dx%d",
2366 &NET_RESOLUTION_WIDTH, &NET_RESOLUTION_HEIGHT);
2367 CHECK_EQ(nRead,2) << "Error, net resolution format ("
2368 << _net_resolution
2369 << ") invalid, should be e.g., 656x368 (multiples of 16)";
2370 LOG(INFO) << "Net resolution: " << NET_RESOLUTION_WIDTH
2371 << "x" << NET_RESOLUTION_HEIGHT;
2372
2373 if (!_write_frames.empty()) {
2374 // Create folder if it does not exist
2375 boost::filesystem::path dir(_write_frames);
2376 if (!boost::filesystem::is_directory(dir) &&
2377 !boost::filesystem::create_directory(dir)) {
2378 LOG(ERROR) << "Could not write to or create directory " << dir;
2379 return 1;
2380 }
2381 }
2382
2383 if (!_write_json.empty()) {
2384 // Create folder if it does not exist
2385 boost::filesystem::path dir(_write_json);
2386 if (!boost::filesystem::is_directory(dir) &&
2387 !boost::filesystem::create_directory(dir)) {
2388 LOG(ERROR) << "Could not write to or create directory " << dir;
2389 return 1;
2390 }
2391 }
2392
2393 BATCH_SIZE = {_num_scales};
2394 SCALE_GAP = {_scale_gap};

Callers 1

mainFunction · 0.85

Calls 2

openMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected