提交 b365f48e 编写于 作者: G Gines Hidalgo

C++ tutorial API only cv::imshow if not empty

上级 9827ab75
......@@ -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
......
......@@ -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:
......
......@@ -29,8 +29,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -29,8 +29,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -31,8 +31,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -31,7 +31,10 @@ bool display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -37,7 +37,10 @@ bool display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -34,8 +34,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -34,8 +34,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -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);
......
......@@ -34,8 +34,13 @@ void display(const std::shared_ptr<std::vector<std::shared_ptr<op::Datum>>>& 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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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__);
}
}
}
......
......@@ -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__);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册