diff --git a/doc/3d_reconstruction_demo.md b/doc/3d_reconstruction_demo.md index ecb80697c3319ad14e314c33845ee0bbc941d3d8..9131252d1b41b8c435f0ab70ac4f33603d927169 100644 --- a/doc/3d_reconstruction_demo.md +++ b/doc/3d_reconstruction_demo.md @@ -43,9 +43,10 @@ This demo assumes n arbitrary stereo cameras from the FLIR company (formerly Poi - (Ubuntu-only) Open your USB ports following section `Configuring USBFS` in [http://www.ptgrey.com/KB/10685](http://www.ptgrey.com/KB/10685). - Install the Spinnaker SDK for your operating system: [https://www.ptgrey.com/support/downloads](https://www.ptgrey.com/support/downloads). 2. Fujinon 3 MP Varifocal Lens (3.8-13mm, 3.4x Zoom) for each camera. - - E.g. [https://www.bhphotovideo.com/c/product/736855-REG/Fujinon_DV3_4X3_8SA_1_3_MP_Varifocal_Lens.html](https://www.bhphotovideo.com/c/product/736855-REG/Fujinon_DV3_4X3_8SA_1_3_MP_Varifocal_Lens.html). + - E.g., [https://www.bhphotovideo.com/c/product/736855-REG/Fujinon_DV3_4X3_8SA_1_3_MP_Varifocal_Lens.html](https://www.bhphotovideo.com/c/product/736855-REG/Fujinon_DV3_4X3_8SA_1_3_MP_Varifocal_Lens.html). 3. 4-Port PCI Express (PCIe) USB 3.0 Card Adapter with 4 dedicated channels. - - E.g. [https://www.startech.com/Cards-Adapters/USB-3.0/Cards/PCI-Express-USB-3-Card-4-Dedicated-Channels-4-Port~PEXUSB3S44V](https://www.startech.com/Cards-Adapters/USB-3.0/Cards/PCI-Express-USB-3-Card-4-Dedicated-Channels-4-Port~PEXUSB3S44V). + - E.g., the 4 Ext Quad Bus version, PCI Express, from: [https://www.amazon.com/Express-SuperSpeed-Adapter-Dedicated-Channels/dp/B00HJZEA2S/ref=sr_1_1?ie=UTF8&qid=1492197599&sr=8-1&keywords=4%2BPort%2BPCI%2BExpress%2B(PCIe)%2Bdedicated%2Bports&th=1](https://www.amazon.com/Express-SuperSpeed-Adapter-Dedicated-Channels/dp/B00HJZEA2S/ref=sr_1_1?ie=UTF8&qid=1492197599&sr=8-1&keywords=4%2BPort%2BPCI%2BExpress%2B(PCIe)%2Bdedicated%2Bports&th=1). + - Alternative: [https://www.startech.com/Cards-Adapters/USB-3.0/Cards/PCI-Express-USB-3-Card-4-Dedicated-Channels-4-Port~PEXUSB3S44V](https://www.startech.com/Cards-Adapters/USB-3.0/Cards/PCI-Express-USB-3-Card-4-Dedicated-Channels-4-Port~PEXUSB3S44V). 4. USB 3.0 cable for each FLIR camera. - From their official website: [https://www.ptgrey.com/5-meter-type-a-to-micro-b-locking-usb-30-cable](https://www.ptgrey.com/5-meter-type-a-to-micro-b-locking-usb-30-cable). @@ -73,7 +74,7 @@ In order to verify that the camera parameters introduced by the user are sorted ## Installing the OpenPose 3-D Reconstruction Module -Check the [doc/installation.md#openpose-3d-reconstruction-module](./quick_start.md#openpose-3d-reconstruction-module) for installation steps. +Check the [doc/installation.md#3d-reconstruction-module](./quick_start.md#3d-reconstruction-module) for installation steps. diff --git a/doc/demo_overview.md b/doc/demo_overview.md index a5550fe377f11ae2096f7c78d5d16497b68b1457..e96306eee0af058dda610badfd489667db2623f0 100644 --- a/doc/demo_overview.md +++ b/doc/demo_overview.md @@ -136,7 +136,7 @@ Each flag is divided into flag name, default value, and description. - DEFINE_int32(profile_speed, 1000, "If PROFILER_ENABLED was set in CMake or Makefile.config files, OpenPose will show some runtime statistics at this frame number."); 2. Producer - DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative number (by default), to auto-detect and open the first available camera."); -- DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +- DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the default 1280x720 for `--camera`, or the maximum flir camera resolution available for `--flir_camera`"); - DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the minimum value between the OpenPose displayed speed and the webcam real frame rate."); - DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default example video."); - DEFINE_string(image_dir, "", "Process a directory of images. Use `examples/media/` for our default example folder with 20 images. Read all standard formats (jpg, png, bmp, etc.)."); diff --git a/doc/faq.md b/doc/faq.md index ad6b1604e3cbdad009d0b5011f62ff2d30a2ac0b..d40b92fa7d7d929711d2ed43b74b657021c9ad84 100644 --- a/doc/faq.md +++ b/doc/faq.md @@ -9,6 +9,7 @@ OpenPose - Frequently Asked Question (FAQ) 4. [Vide/Webcam Not Working](#video-webcam-not-working) 5. [Cannot Find OpenPose.dll Error](#cannot-find-openpose.dll-error-windows) 6. [Free Invalid Pointer Error](#free-invalid-pointer-error) + 7. [Source Directory does not Contain CMakeLists.txt (Windows)](#source-directory-does-not-contain-cmakelists.txt-windows) @@ -66,3 +67,10 @@ Note: OpenPose library is not an executable, but a library. So instead clicking **Q: I am getting an error of the type: munmap_chunk()/free/invalid pointer.** **A**: In order to run OpenCV 3.X and Caffe simultaneously, [OpenCV must be compiled without `WITH_GTK` and with `WITH_QT` flags](https://github.com/BVLC/caffe/issues/5282#issuecomment-306063718). On Ubuntu 16.04 the qt5 package is "qt5-default" and the OpenCV cmake option is WITH_QT. + + + +### Source Directory does not Contain CMakeLists.txt (Windows) +**Q: I am getting an error of the type: `The source directory {path to file} does not contain a CMakeLists.txt file.`.** + +**A**: You might not have writing access to that folder. If you are in Windows, you should not try to install it in `Program Files`. diff --git a/doc/installation.md b/doc/installation.md index f0dd3e0e304f19572fb5967da674c60c780084d8..8f6f0ad0bdccea3b920fb792166d7f0a73865c18 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -12,7 +12,7 @@ OpenPose - Installation 8. [Uninstallation](#uninstallation) 9. [Optional Settings](#optional-settings) 1. [MPI Model](#mpi-model) - 2. [OpenPose 3D Reconstruction Module](#openpose-3d-reconstruction-module) + 2. [3D Reconstruction Module](#3d-reconstruction-module) 3. [Compiling without cuDNN](#compiling-without-cudnn) 4. [Custom Caffe (Ubuntu Only)](#custom-caffe-ubuntu-only) 5. [Custom OpenCV (Ubuntu Only)](#custom-opencv-ubuntu-only) @@ -214,7 +214,7 @@ By default, the body MPI model is not downloaded. You can download it by turning -#### OpenPose 3D Reconstruction Module +#### 3D Reconstruction Module You can include the 3D reconstruction module by: 1. Install the FLIR camera software, Spinnaker SDK. It is a propietary software, so we cannot provide direct download link. Note: You might skip this step if you intend to use the 3-D OpenPose module with a different camera brand. diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index 889f164352c6ff5a88d867f07a6404101ce1fe54..93861e3d4af971e129be4aa17ae414f4e128d538 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -45,7 +45,9 @@ DEFINE_int32(profile_speed, 1000, "If PROFILER_ENABLED was // Producer DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" " number (by default), to auto-detect and open the first available camera."); -DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" + " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" + " `--flir_camera`"); DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" " minimum value between the OpenPose displayed speed and the webcam real frame rate."); DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" @@ -266,7 +268,8 @@ int openPoseDemo() // Pose configuration (use WrapperStructPose{} for default and recommended configuration) const op::WrapperStructPose wrapperStructPose{!FLAGS_body_disable, netInputSize, outputSize, keypointScale, FLAGS_num_gpu, FLAGS_num_gpu_start, FLAGS_scale_number, - (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose), + (float)FLAGS_scale_gap, + op::flagsToRenderMode(FLAGS_render_pose, FLAGS_3d, FLAGS_render_pose), poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, @@ -274,13 +277,13 @@ int openPoseDemo() enableGoogleLogging, FLAGS_3d, FLAGS_identification}; // Face configuration (use op::WrapperStructFace{} to disable it) const op::WrapperStructFace wrapperStructFace{FLAGS_face, faceNetInputSize, - op::flagsToRenderMode(FLAGS_face_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_face_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_face_alpha_pose, (float)FLAGS_face_alpha_heatmap, (float)FLAGS_face_render_threshold}; // Hand configuration (use op::WrapperStructHand{} to disable it) const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number, (float)FLAGS_hand_scale_range, FLAGS_hand_tracking, - op::flagsToRenderMode(FLAGS_hand_render, FLAGS_render_pose), + op::flagsToRenderMode(FLAGS_hand_render, FLAGS_3d, FLAGS_render_pose), (float)FLAGS_hand_alpha_pose, (float)FLAGS_hand_alpha_heatmap, (float)FLAGS_hand_render_threshold}; // Producer (use default to disable any input) diff --git a/examples/tutorial_add_module/1_custom_post_processing.cpp b/examples/tutorial_add_module/1_custom_post_processing.cpp index 8acd4211c65aa9b571b826696480fff175bfdaec..887d3641578dfbe8660d6d8e9a513149974bb3bd 100644 --- a/examples/tutorial_add_module/1_custom_post_processing.cpp +++ b/examples/tutorial_add_module/1_custom_post_processing.cpp @@ -54,7 +54,9 @@ DEFINE_int32(profile_speed, 1000, "If PROFILER_ENABLED was // Producer DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" " number (by default), to auto-detect and open the first available camera."); -DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" + " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" + " `--flir_camera`"); DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" " minimum value between the OpenPose displayed speed and the webcam real frame rate."); DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" diff --git a/examples/tutorial_thread/1_openpose_read_and_display.cpp b/examples/tutorial_thread/1_openpose_read_and_display.cpp index 284a87283932063289b0c4f3b15489e496ae86c8..a9707260ad0942876b1682e5941d26b2467de4b5 100644 --- a/examples/tutorial_thread/1_openpose_read_and_display.cpp +++ b/examples/tutorial_thread/1_openpose_read_and_display.cpp @@ -31,7 +31,9 @@ DEFINE_int32(logging_level, 3, "The logging level. Inte // Producer DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" " number (by default), to auto-detect and open the first available camera."); -DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" + " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" + " `--flir_camera`"); DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" " minimum value between the OpenPose displayed speed and the webcam real frame rate."); DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" diff --git a/examples/tutorial_thread/2_user_processing_function.cpp b/examples/tutorial_thread/2_user_processing_function.cpp index ecf38ad1ca7844e0e7accfe3973891063a8f6083..a751c2fd8004015e46e110717155e281a846bcb0 100644 --- a/examples/tutorial_thread/2_user_processing_function.cpp +++ b/examples/tutorial_thread/2_user_processing_function.cpp @@ -32,7 +32,9 @@ DEFINE_int32(logging_level, 3, "The logging level. Inte // Producer DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" " number (by default), to auto-detect and open the first available camera."); -DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" + " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" + " `--flir_camera`"); DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" " minimum value between the OpenPose displayed speed and the webcam real frame rate."); DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" diff --git a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp index 2158b7cff27d5dd7549ca29c832eb3d5793f7521..64830ec606931c35b85cf7f524220f82d03b00bf 100644 --- a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp +++ b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp @@ -44,7 +44,9 @@ DEFINE_int32(profile_speed, 1000, "If PROFILER_ENABLED was // Producer DEFINE_int32(camera, -1, "The camera index for cv::VideoCapture. Integer in the range [0, 9]. Select a negative" " number (by default), to auto-detect and open the first available camera."); -DEFINE_string(camera_resolution, "1280x720", "Size of the camera frames to ask for."); +DEFINE_string(camera_resolution, "-1x-1", "Set the camera resolution (either `--camera` or `--flir_camera`). `-1x-1` will use the" + " default 1280x720 for `--camera`, or the maximum flir camera resolution available for" + " `--flir_camera`"); DEFINE_double(camera_fps, 30.0, "Frame rate for the webcam (only used when saving video from webcam). Set this value to the" " minimum value between the OpenPose displayed speed and the webcam real frame rate."); DEFINE_string(video, "", "Use a video file instead of the camera. Use `examples/media/video.avi` for our default" diff --git a/include/openpose/producer/flirReader.hpp b/include/openpose/producer/flirReader.hpp index 500d7925707b24cbed27abe9edc3faa3f470a8b8..27a20e3af3195e49d920c2655825e83084f67908 100644 --- a/include/openpose/producer/flirReader.hpp +++ b/include/openpose/producer/flirReader.hpp @@ -18,7 +18,7 @@ namespace op /** * Constructor of FlirReader. It opens all the available FLIR cameras */ - explicit FlirReader(const std::string& cameraParametersPath); + explicit FlirReader(const std::string& cameraParametersPath, const Point& cameraResolution); ~FlirReader(); diff --git a/include/openpose/producer/spinnakerWrapper.hpp b/include/openpose/producer/spinnakerWrapper.hpp index d5bab50dc9faf9f670b8b8e1d07b358b3b2fdc88..9e4a9d8b1eb4079deb400b50b33227198215cd89 100644 --- a/include/openpose/producer/spinnakerWrapper.hpp +++ b/include/openpose/producer/spinnakerWrapper.hpp @@ -15,7 +15,7 @@ namespace op /** * Constructor of SpinnakerWrapper. It opens all the available FLIR cameras */ - explicit SpinnakerWrapper(const std::string& cameraParameterPath); + explicit SpinnakerWrapper(const std::string& cameraParameterPath, const Point& cameraResolution); ~SpinnakerWrapper(); diff --git a/include/openpose/utilities/flagsToOpenPose.hpp b/include/openpose/utilities/flagsToOpenPose.hpp index 84acfdbe97aafb50fd4bc57b6e2f33b7a48aff3d..233d018452154917de9be3c319fabb4fe29eb688 100644 --- a/include/openpose/utilities/flagsToOpenPose.hpp +++ b/include/openpose/utilities/flagsToOpenPose.hpp @@ -23,7 +23,7 @@ namespace op OP_API std::shared_ptr flagsToProducer(const std::string& imageDirectory, const std::string& videoPath, const std::string& ipCameraPath, const int webcamIndex, const bool flirCamera = false, - const std::string& webcamResolution = "1280x720", + const std::string& cameraResolution = "-1x-1", const double webcamFps = 30., const std::string& cameraParameterPath = "models/cameraParameters/", const unsigned int imageDirectoryStereo = 1); @@ -32,7 +32,8 @@ namespace op const bool heatMapsAddBkg = false, const bool heatMapsAddPAFs = false); - OP_API RenderMode flagsToRenderMode(const int renderFlag, const int renderPoseFlag = -2); + OP_API RenderMode flagsToRenderMode(const int renderFlag, const bool gpuBuggy = false, + const int renderPoseFlag = -2); OP_API DisplayMode flagsToDisplayMode(const int display, const bool enabled3d); diff --git a/src/openpose/core/nmsCaffe.cpp b/src/openpose/core/nmsCaffe.cpp index e7402bb8c93a1b6c792c9abc2269a023b46b7e19..6d74c29a041497247477e1dcd7b5095485e2cfec 100644 --- a/src/openpose/core/nmsCaffe.cpp +++ b/src/openpose/core/nmsCaffe.cpp @@ -95,7 +95,7 @@ namespace op // GPU ID mGpuID = gpuID; #else - UNUSED(mGpuID); + UNUSED(gpuID); #endif // Array sizes upImpl->mTopSize = std::array{topBlob->shape(0), topBlob->shape(1), diff --git a/src/openpose/core/resizeAndMergeCaffe.cpp b/src/openpose/core/resizeAndMergeCaffe.cpp index 927890f9e584f9933d35fae96afb8f3365ede5d8..4072c17bd8ada0869707f12c2d8c625ca70c1775 100644 --- a/src/openpose/core/resizeAndMergeCaffe.cpp +++ b/src/openpose/core/resizeAndMergeCaffe.cpp @@ -86,7 +86,7 @@ namespace op // GPU ID mGpuID = gpuID; #else - UNUSED(mGpuID); + UNUSED(gpuID); #endif #else UNUSED(bottom); diff --git a/src/openpose/gui/gui3D.cpp b/src/openpose/gui/gui3D.cpp index 0a296eab861287e2df3665ae678547f182cfd6d5..83b712b8c641642e2d6016ce2776ce2ac7bfb93a 100644 --- a/src/openpose/gui/gui3D.cpp +++ b/src/openpose/gui/gui3D.cpp @@ -275,7 +275,7 @@ namespace op glTranslatef(-gMouseXPan, gMouseYPan, -gMouseZPan); - renderFloor(); + // renderFloor(); // Disabled, how to know where the floor is? std::unique_lock lock{gKeypoints3D.mutex}; if (gKeypoints3D.validKeypoints) { diff --git a/src/openpose/producer/flirReader.cpp b/src/openpose/producer/flirReader.cpp index fd2301b63e013b2e690a204ab882cc630c129b25..6c98c21113753746592915558953ebd5ae253be9 100644 --- a/src/openpose/producer/flirReader.cpp +++ b/src/openpose/producer/flirReader.cpp @@ -4,14 +4,16 @@ namespace op { - FlirReader::FlirReader(const std::string& cameraParametersPath) : + FlirReader::FlirReader(const std::string& cameraParametersPath, const Point& cameraResolution) : Producer{ProducerType::FlirCamera}, - mSpinnakerWrapper{cameraParametersPath}, + mSpinnakerWrapper{cameraParametersPath, cameraResolution}, mFrameNameCounter{0} { try { + // Get resolution const auto resolution = mSpinnakerWrapper.getResolution(); + // Set resolution set(CV_CAP_PROP_FRAME_WIDTH, resolution.x); set(CV_CAP_PROP_FRAME_HEIGHT, resolution.y); } @@ -140,7 +142,7 @@ namespace op return -1.; else { - log("Unknown property", Priority::Max, __LINE__, __FUNCTION__, __FILE__); + log("Unknown property.", Priority::Max, __LINE__, __FUNCTION__, __FILE__); return -1.; } } @@ -164,7 +166,7 @@ namespace op else if (capProperty == CV_CAP_PROP_FRAME_COUNT || capProperty == CV_CAP_PROP_FPS) log("This property is read-only.", Priority::Max, __LINE__, __FUNCTION__, __FILE__); else - log("Unknown property", Priority::Max, __LINE__, __FUNCTION__, __FILE__); + log("Unknown property.", Priority::Max, __LINE__, __FUNCTION__, __FILE__); } catch (const std::exception& e) { diff --git a/src/openpose/producer/spinnakerWrapper.cpp b/src/openpose/producer/spinnakerWrapper.cpp index 48985f21eae46642a0ed3924b6737d762cfed896..4f66108b122ee0d1ff2587e8d6086cc380051beb 100644 --- a/src/openpose/producer/spinnakerWrapper.cpp +++ b/src/openpose/producer/spinnakerWrapper.cpp @@ -334,7 +334,7 @@ namespace op #endif }; - SpinnakerWrapper::SpinnakerWrapper(const std::string& cameraParameterPath) + SpinnakerWrapper::SpinnakerWrapper(const std::string& cameraParameterPath, const Point& resolution) #ifdef WITH_FLIR_CAMERA : upImpl{new ImplSpinnakerWrapper{}} #endif @@ -342,6 +342,9 @@ namespace op #ifdef WITH_FLIR_CAMERA try { + // Clean previous unclosed builds (e.g. if core dumped in the previous code using the cameras) + release(); + upImpl->mInitialized = true; // Print application build information @@ -485,6 +488,44 @@ namespace op log("Camera " + std::to_string(i) + " acquisition mode set to continuous...", Priority::High); + // Set camera resolution + // Retrieve GenICam nodemap + auto& iNodeMap = cameraPtr->GetNodeMap(); + // Set offset + Spinnaker::GenApi::CIntegerPtr ptrOffsetX = iNodeMap.GetNode("OffsetX"); + ptrOffsetX->SetValue(0); + Spinnaker::GenApi::CIntegerPtr ptrOffsetY = iNodeMap.GetNode("OffsetY"); + ptrOffsetY->SetValue(0); + // Set resolution + if (resolution.x > 0 && resolution.y > 0) + { + // WARNING: setting the obset would require auto-change in the camera matrix parameters + // Set offset + // const Spinnaker::GenApi::CIntegerPtr ptrWidthMax = iNodeMap.GetNode("WidthMax"); + // const Spinnaker::GenApi::CIntegerPtr ptrHeightMax = iNodeMap.GetNode("HeightMax"); + // ptrOffsetX->SetValue((ptrWidthMax->GetValue() - resolution.x) / 2); + // ptrOffsetY->SetValue((ptrHeightMax->GetValue() - resolution.y) / 2); + // Set Width + Spinnaker::GenApi::CIntegerPtr ptrWidth = iNodeMap.GetNode("Width"); + ptrWidth->SetValue(resolution.x); + // Set width + Spinnaker::GenApi::CIntegerPtr ptrHeight = iNodeMap.GetNode("Height"); + ptrHeight->SetValue(resolution.y); + } + else + { + const Spinnaker::GenApi::CIntegerPtr ptrWidthMax = iNodeMap.GetNode("WidthMax"); + const Spinnaker::GenApi::CIntegerPtr ptrHeightMax = iNodeMap.GetNode("HeightMax"); + // Set Width + Spinnaker::GenApi::CIntegerPtr ptrWidth = iNodeMap.GetNode("Width"); + ptrWidth->SetValue(ptrWidthMax->GetValue()); + // Set width + Spinnaker::GenApi::CIntegerPtr ptrHeight = iNodeMap.GetNode("Height"); + ptrHeight->SetValue(ptrHeightMax->GetValue()); + log("Choosing maximum resolution for flir camera (" + std::to_string(ptrWidth->GetValue()) + + " x " + std::to_string(ptrHeight->GetValue()) + ").", Priority::High); + } + // Begin acquiring images cameraPtr->BeginAcquisition(); @@ -523,6 +564,7 @@ namespace op upImpl->mResolution = Point{cvMats[0].cols, cvMats[0].rows}; log("\nRunning for all cameras...\n\n*** IMAGE ACQUISITION ***\n", Priority::High); + } catch (const Spinnaker::Exception& e) { @@ -649,14 +691,13 @@ namespace op // GetByIndex(); this is an alternative to retrieving cameras as // Spinnaker::CameraPtr objects that can be quick and easy for small tasks. // - for (auto i = 0; i < upImpl->mCameraList.GetSize(); i++) - upImpl->mCameraList.GetByIndex(i)->EndAcquisition(); - for (auto i = 0; i < upImpl->mCameraList.GetSize(); i++) { // Select camera auto cameraPtr = upImpl->mCameraList.GetByIndex(i); + cameraPtr->EndAcquisition(); + // Retrieve GenICam nodemap auto& iNodeMap = cameraPtr->GetNodeMap(); @@ -689,6 +730,29 @@ namespace op log("Cameras released! Exiting program.", Priority::High); } + else + { + // Open general system + auto systemPtr = Spinnaker::System::GetInstance(); + auto cameraList = systemPtr->GetCameras(); + if (cameraList.GetSize() > 0) + { + + for (int i = 0; i < cameraList.GetSize(); i++) + { + // Select camera + auto cameraPtr = cameraList.GetByIndex(i); + // Begin + cameraPtr->Init(); + cameraPtr->BeginAcquisition(); + // End + cameraPtr->EndAcquisition(); + cameraPtr->DeInit(); + } + } + cameraList.Clear(); + systemPtr->ReleaseInstance(); + } } catch (const Spinnaker::Exception& e) { diff --git a/src/openpose/utilities/flagsToOpenPose.cpp b/src/openpose/utilities/flagsToOpenPose.cpp index f4bebd70514a5b63177f4142e3b0b1879aff124e..db687708cebfe3a47a565975c53a93d0bbf7c9ba 100644 --- a/src/openpose/utilities/flagsToOpenPose.cpp +++ b/src/openpose/utilities/flagsToOpenPose.cpp @@ -136,7 +136,7 @@ namespace op std::shared_ptr flagsToProducer(const std::string& imageDirectory, const std::string& videoPath, const std::string& ipCameraPath, const int webcamIndex, - const bool flirCamera, const std::string& webcamResolution, + const bool flirCamera, const std::string& cameraResolution, const double webcamFps, const std::string& cameraParameterPath, const unsigned int imageDirectoryStereo) { @@ -152,16 +152,22 @@ namespace op return std::make_shared(videoPath); else if (type == ProducerType::IPCamera) return std::make_shared(ipCameraPath); - else if (type == ProducerType::FlirCamera) - return std::make_shared(cameraParameterPath); - else if (type == ProducerType::Webcam) + // Flir camera + if (type == ProducerType::FlirCamera) { // cameraFrameSize - const auto webcamFrameSize = op::flagsToPoint(webcamResolution, "1280x720"); + const auto cameraFrameSize = op::flagsToPoint(cameraResolution, "-1x-1"); + return std::make_shared(cameraParameterPath, cameraFrameSize); + } + // Webcam + if (type == ProducerType::Webcam) + { + // cameraFrameSize + const auto cameraFrameSize = op::flagsToPoint(cameraResolution, "1280x720"); if (webcamIndex >= 0) { const auto throwExceptionIfNoOpened = true; - return std::make_shared(webcamIndex, webcamFrameSize, webcamFps, + return std::make_shared(webcamIndex, cameraFrameSize, webcamFps, throwExceptionIfNoOpened); } else @@ -170,7 +176,7 @@ namespace op std::shared_ptr webcamReader; for (auto index = 0 ; index < 10 ; index++) { - webcamReader = std::make_shared(index, webcamFrameSize, webcamFps, + webcamReader = std::make_shared(index, cameraFrameSize, webcamFps, throwExceptionIfNoOpened); if (webcamReader->isOpened()) { @@ -214,7 +220,7 @@ namespace op } } - RenderMode flagsToRenderMode(const int renderFlag, const int renderPoseFlag) + RenderMode flagsToRenderMode(const int renderFlag, const bool gpuBuggy, const int renderPoseFlag) { try { @@ -222,7 +228,7 @@ namespace op if (renderFlag == -1 && renderPoseFlag == -2) { #ifdef USE_CUDA - return RenderMode::Gpu; + return (gpuBuggy ? RenderMode::Cpu : RenderMode::Gpu); #else return RenderMode::Cpu; #endif