diff --git a/doc/modules/python_module.md b/doc/modules/python_module.md index ee6db4e5023269d446fc460f27c1895b9a47d9e9..80422a7e228856f4eb94b1766b2270415a772e28 100644 --- a/doc/modules/python_module.md +++ b/doc/modules/python_module.md @@ -106,6 +106,11 @@ Windows: ## Common Issues +### Do not use PIL +In order to read images in Python, make sure to use OpenCV (do not use PIL). We found that feeding a PIL image format to OpenPose results in the input image appearing in grey and duplicated 9 times (so the output skeleton appear 3 times smaller than they should be, and duplicated 9 times). + + +### Cannot Import Name PyOpenPose The error in general is that PyOpenPose cannot be found (an error similar to: `ImportError: cannot import name pyopenpose`). Ensure first that `BUILD_PYTHON` flag is set to ON. If the error persists, check the following: In the script you are running, check for the following line, and run the following command in the same location as where the file is diff --git a/doc/release_notes.md b/doc/release_notes.md index e3fc91270ab8681ee27a91831a42402f4dbb4103..f3c105f89f9763703fbcdfbd262679930025d387 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -419,6 +419,7 @@ OpenPose Library - Release Notes 2. Functions or parameters renamed: 3. Main bugs fixed: 1. 90 and 270-degree rotations working again. + 2. C++ tutorial API demos only try to cv::imshow the image if it is not empty (avoding the assert that it would trigger otherwise). 4. Changes/additions that affect the compatibility with the OpenPose Unity Plugin: diff --git a/examples/tutorial_api_cpp/01_body_from_image_default.cpp b/examples/tutorial_api_cpp/01_body_from_image_default.cpp index 20863d2c22e056a6c7485f9c38ce80dd50cc6eec..dc6b09753cb3280b6d7eefcb5dff97f456122abc 100644 --- a/examples/tutorial_api_cpp/01_body_from_image_default.cpp +++ b/examples/tutorial_api_cpp/01_body_from_image_default.cpp @@ -29,8 +29,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/02_whole_body_from_image_default.cpp b/examples/tutorial_api_cpp/02_whole_body_from_image_default.cpp index 8e04ae89a4cf0f92e73b7b824e94bb783ed4e4d3..a8fd67063bb38aa70236f6189069008a9abfa450 100644 --- a/examples/tutorial_api_cpp/02_whole_body_from_image_default.cpp +++ b/examples/tutorial_api_cpp/02_whole_body_from_image_default.cpp @@ -29,8 +29,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/03_keypoints_from_image.cpp b/examples/tutorial_api_cpp/03_keypoints_from_image.cpp index d5eec836cb295a3cbbae73e8eb0f2a3430872a05..1dcacc349c1920afb635eb5316153c84139da19d 100644 --- a/examples/tutorial_api_cpp/03_keypoints_from_image.cpp +++ b/examples/tutorial_api_cpp/03_keypoints_from_image.cpp @@ -31,8 +31,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/04_keypoints_from_images.cpp b/examples/tutorial_api_cpp/04_keypoints_from_images.cpp index 80b80296de9909afe761c23d0e2fe57597c943e3..67ea5d6a4c5cc16d42d5429325ce1d7f94c23929 100644 --- a/examples/tutorial_api_cpp/04_keypoints_from_images.cpp +++ b/examples/tutorial_api_cpp/04_keypoints_from_images.cpp @@ -31,7 +31,10 @@ bool display(const std::shared_ptr>>& dat { // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + if (!cvMat.empty()) + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/05_keypoints_from_images_multi_gpu.cpp b/examples/tutorial_api_cpp/05_keypoints_from_images_multi_gpu.cpp index 20442a54e6030425302011f8b80c3620853f7e05..aa7537ac71f54f3d0b5d0a6551c3d7cb39882a20 100644 --- a/examples/tutorial_api_cpp/05_keypoints_from_images_multi_gpu.cpp +++ b/examples/tutorial_api_cpp/05_keypoints_from_images_multi_gpu.cpp @@ -37,7 +37,10 @@ bool display(const std::shared_ptr>>& dat { // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + if (!cvMat.empty()) + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/06_face_from_image.cpp b/examples/tutorial_api_cpp/06_face_from_image.cpp index 273a50835ca7ae02986ece11408a0da3547848b1..c094021622021babfc62d9db9a34058283d174cd 100644 --- a/examples/tutorial_api_cpp/06_face_from_image.cpp +++ b/examples/tutorial_api_cpp/06_face_from_image.cpp @@ -34,8 +34,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/07_hand_from_image.cpp b/examples/tutorial_api_cpp/07_hand_from_image.cpp index b2d67a471fc11c096b81178939311ac9cd42dbdb..d114e6ce56724fa08d8328b0b67befe949178f79 100644 --- a/examples/tutorial_api_cpp/07_hand_from_image.cpp +++ b/examples/tutorial_api_cpp/07_hand_from_image.cpp @@ -34,8 +34,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/08_heatmaps_from_image.cpp b/examples/tutorial_api_cpp/08_heatmaps_from_image.cpp index e1b5c45185b2aa31ad230603f198d986bdbd7543..b5dc52eed661a534d0c8b49f24cec48a5e5a4a31 100644 --- a/examples/tutorial_api_cpp/08_heatmaps_from_image.cpp +++ b/examples/tutorial_api_cpp/08_heatmaps_from_image.cpp @@ -57,7 +57,10 @@ bool display( cv::applyColorMap(desiredChannelHeatMapUint8, desiredChannelHeatMapUint8, cv::COLORMAP_JET); cv::addWeighted(netInputImageUint8, 0.5, desiredChannelHeatMapUint8, 0.5, 0., imageToRender); // Display image - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", imageToRender); + if (!imageToRender.empty()) + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", imageToRender); + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/09_keypoints_from_heatmaps.cpp b/examples/tutorial_api_cpp/09_keypoints_from_heatmaps.cpp index 152bf3f144adad21b81e973c203192218b7c7355..11e63f69cfe7c211ac736fb2b6f501e04b9cc70a 100644 --- a/examples/tutorial_api_cpp/09_keypoints_from_heatmaps.cpp +++ b/examples/tutorial_api_cpp/09_keypoints_from_heatmaps.cpp @@ -34,8 +34,13 @@ void display(const std::shared_ptr>>& dat { // Display image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - cv::waitKey(0); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + cv::waitKey(0); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/12_asynchronous_custom_output.cpp b/examples/tutorial_api_cpp/12_asynchronous_custom_output.cpp index ee16e363cfd1d4756d8ca9e3cccd6f73afcfa9e2..5aa7276e97f3c4d76e8e35d941f8d3fad7266022 100644 --- a/examples/tutorial_api_cpp/12_asynchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/12_asynchronous_custom_output.cpp @@ -28,7 +28,10 @@ public: { // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + if (!cvMat.empty()) + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/13_asynchronous_custom_input_output_and_datum.cpp b/examples/tutorial_api_cpp/13_asynchronous_custom_input_output_and_datum.cpp index e823f288198cb68711c44a647bb1cd2231039b75..4e086794b6ee0555233434aff7474fb8a6fb34a9 100644 --- a/examples/tutorial_api_cpp/13_asynchronous_custom_input_output_and_datum.cpp +++ b/examples/tutorial_api_cpp/13_asynchronous_custom_input_output_and_datum.cpp @@ -110,7 +110,10 @@ public: { // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + if (!cvMat.empty()) + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + else + op::opLog("Empty cv::Mat as output.", op::Priority::High); } else op::opLog("Nullptr or empty datumsPtr found.", op::Priority::High); diff --git a/examples/tutorial_api_cpp/17_synchronous_custom_output.cpp b/examples/tutorial_api_cpp/17_synchronous_custom_output.cpp index 114fe446dd0b6dd2a7c65604d07d677ba43c9d15..68e3c42a6b44357227a93ba916b5916094db4431 100644 --- a/examples/tutorial_api_cpp/17_synchronous_custom_output.cpp +++ b/examples/tutorial_api_cpp/17_synchronous_custom_output.cpp @@ -82,11 +82,16 @@ public: { // Display rendered output image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) - const char key = (char)cv::waitKey(1); - if (key == 27) - this->stop(); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) + const char key = (char)cv::waitKey(1); + if (key == 27) + this->stop(); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } } } diff --git a/examples/tutorial_api_cpp/18_synchronous_custom_all_and_datum.cpp b/examples/tutorial_api_cpp/18_synchronous_custom_all_and_datum.cpp index 1bb264129377a5889301d89f49a28422fa445b0d..76d4efea22c4582178d9d46b2184b2348e1d80e2 100644 --- a/examples/tutorial_api_cpp/18_synchronous_custom_all_and_datum.cpp +++ b/examples/tutorial_api_cpp/18_synchronous_custom_all_and_datum.cpp @@ -204,11 +204,16 @@ public: { // Display rendered output image const cv::Mat cvMat = OP_OP2CVCONSTMAT(datumsPtr->at(0)->cvOutputData); - cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); - // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) - const char key = (char)cv::waitKey(1); - if (key == 27) - this->stop(); + if (!cvMat.empty()) + { + cv::imshow(OPEN_POSE_NAME_AND_VERSION + " - Tutorial C++ API", cvMat); + // Display image and sleeps at least 1 ms (it usually sleeps ~5-10 msec to display the image) + const char key = (char)cv::waitKey(1); + if (key == 27) + this->stop(); + } + else + op::opLog("Empty cv::Mat as output.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__); } } }