diff --git a/doc/release_notes.md b/doc/release_notes.md index 3e1e3428..166db929 100644 --- a/doc/release_notes.md +++ b/doc/release_notes.md @@ -293,6 +293,8 @@ OpenPose Library - Release Notes 23. Video (`--write_video`) can be generated from images (`--image_dir`), as long as they maintain the same resolution. 24. Added `--fps_max` flag to limit the maximum processing frame rate of OpenPose (useful to display results at a maximum desired speed). 25. Frame undistortion can be applied not only to FLIR cameras, but also to all other input sources (image, webcam, video, etc.). + 26. Calibration improvements: + 1. Improved chessboard orientation detection, more robust and less errors. 2. Functions or parameters renamed: 1. By default, python example `tutorial_developer/python_2_pose_from_heatmaps.py` was using 2 scales starting at -1x736, changed to 1 scale at -1x368. 2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary. diff --git a/examples/tests/hand_accuracy_test.sh b/examples/tests/hand_accuracy_test.sh index d5d89029..0d229424 100755 --- a/examples/tests/hand_accuracy_test.sh +++ b/examples/tests/hand_accuracy_test.sh @@ -44,7 +44,7 @@ SUFFIX="_${SCALES}" HAND_RESULTS_FOLDER_BASE=${PEOPLE_JSON_FOLDER}"hand_keypoints_estimated" HAND_RESULTS_FOLDER_NO_BB=${HAND_RESULTS_FOLDER_BASE}"_old"${SUFFIX} HAND_RESULTS_FOLDER_BB=${HAND_RESULTS_FOLDER_BASE}"_BBox"${SUFFIX} -HAND_RESULTS_FOLDER_BODY_59=${HAND_RESULTS_FOLDER_BASE}"_BODY_59" +HAND_RESULTS_FOLDER_BODY_65=${HAND_RESULTS_FOLDER_BASE}"_BODY_65" @@ -74,12 +74,12 @@ rm -rf $HAND_RESULTS_FOLDER_NO_BB -# No bounding box BODY_59 -echo "Output on ${HAND_RESULTS_FOLDER_BODY_59}" -rm -rf $HAND_RESULTS_FOLDER_BODY_59 +# No bounding box BODY_65 +echo "Output on ${HAND_RESULTS_FOLDER_BODY_65}" +rm -rf $HAND_RESULTS_FOLDER_BODY_65 # 1 scale ./build/examples/openpose/openpose.bin \ - --model_pose BODY_59 \ + --model_pose BODY_65 \ --image_dir ${IMAGES_FOLDER} \ - --write_json $HAND_RESULTS_FOLDER_BODY_59 \ + --write_json $HAND_RESULTS_FOLDER_BODY_65 \ --display 0 diff --git a/include/openpose/calibration/gridPatternFunctions.hpp b/include/openpose/calibration/gridPatternFunctions.hpp index b9cee0b0..e9e7ff7d 100644 --- a/include/openpose/calibration/gridPatternFunctions.hpp +++ b/include/openpose/calibration/gridPatternFunctions.hpp @@ -27,7 +27,7 @@ namespace op const std::vector& points2DVector, const cv::Size& gridInnerCorners); OP_API void reorderPoints(std::vector& points2DVector, const cv::Size& gridInnerCorners, - const Points2DOrigin points2DOriginDesired); + const cv::Mat& image, const bool showWarning = true); OP_API void plotGridCorners( const cv::Size& gridInnerCorners, const std::vector& points2DVector, diff --git a/include/openpose/pose/enumClasses.hpp b/include/openpose/pose/enumClasses.hpp index fb223340..5128f960 100644 --- a/include/openpose/pose/enumClasses.hpp +++ b/include/openpose/pose/enumClasses.hpp @@ -17,16 +17,15 @@ namespace op MPI_15_4, /**< Variation of the MPI model, reduced number of CNN stages to 4: faster but less accurate.*/ BODY_19, /**< Experimental. Do not use. */ BODY_19_X2, /**< Experimental. Do not use. */ - BODY_59, /**< Experimental. Do not use. */ BODY_19N, /**< Experimental. Do not use. */ BODY_25E, /**< Experimental. Do not use. */ - BODY_25_19, /**< Experimental. Do not use. */ BODY_65, /**< Experimental. Do not use. */ CAR_12, /**< Experimental. Do not use. */ BODY_25D, /**< Experimental. Do not use. */ BODY_23, /**< Experimental. Do not use. */ CAR_22, /**< Experimental. Do not use. */ BODY_19E, /**< Experimental. Do not use. */ + BODY_25B, /**< Experimental. Do not use. */ Size, }; diff --git a/include/openpose/pose/poseParametersRender.hpp b/include/openpose/pose/poseParametersRender.hpp index 8e4d8a29..b3a2f071 100644 --- a/include/openpose/pose/poseParametersRender.hpp +++ b/include/openpose/pose/poseParametersRender.hpp @@ -140,17 +140,13 @@ namespace op 0.f, 255.f, 255.f, \ 0.f, 255.f, 255.f, \ 0.f, 255.f, 255.f - // BODY_59 - // Body + left hand + right hand - #define POSE_BODY_59_PAIRS_RENDER_GPU \ - 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, \ - 7,19, 19,20, 20,21, 21,22, 7,23, 23,24, 24,25, 25,26, 7,27, 27,28, 28,29, 29,30, 7,31, 31,32, 32,33, 33,34, 7,35, 35,36, 36,37, 37,38, \ - 4,39, 39,40, 40,41, 41,42, 4,43, 43,44, 44,45, 45,46, 4,47, 47,48, 48,49, 49,50, 4,51, 51,52, 52,53, 53,54, 4,55, 55,56, 56,57, 57,58 - #define POSE_BODY_59_SCALES_RENDER_GPU \ - 1.f,1.f,1.f,1.f,1.f, 1.f,1.f,1.f,1.f,1.f, 1.f,1.f,1.f,1.f,1.f, 1.f,1.f,1.f,1.f, \ - 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f, \ - 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f, 0.75f,0.75f,0.75f,0.75f,0.75f - #define POSE_BODY_59_COLORS_RENDER_GPU \ + // BODY_25B + #define POSE_BODY_25B_PAIRS_RENDER_GPU \ + 0,1, 0,2, 1,3, 2,4, 5,7, 6,8, 7,9, 8,10, 5,11, 6,12, 11,13, 12,14, 13,15, 14,16, \ + 15,19, 19,20, 15,21, 16,22, 22,23, 16,24, 5,17, \ + 6,17, 17,18, 11,12 + #define POSE_BODY_25B_SCALES_RENDER_GPU 1 + #define POSE_BODY_25B_COLORS_RENDER_GPU \ 255.f, 0.f, 85.f, \ 255.f, 0.f, 0.f, \ 255.f, 85.f, 0.f, \ @@ -170,48 +166,12 @@ namespace op 170.f, 0.f, 255.f, \ 255.f, 0.f, 255.f, \ 85.f, 0.f, 255.f, \ - \ - 255.f, 0.f, 0.f, \ - 191.f, 47.f, 47.f, \ - 127.f, 63.f, 63.f, \ - 63.f, 47.f, 47.f, \ - 255.f, 76.f, 0.f, \ - 191.f, 57.f, 0.f, \ - 127.f, 38.f, 0.f, \ - 63.f, 19.f, 0.f, \ - 255.f, 152.f, 0.f, \ - 191.f, 114.f, 0.f, \ - 127.f, 76.f, 0.f, \ - 63.f, 38.f, 0.f, \ - 255.f, 255.f, 0.f, \ - 191.f, 191.f, 0.f, \ - 127.f, 127.f, 0.f, \ - 63.f, 63.f, 0.f, \ - 0.f, 255.f, 0.f, \ - 0.f, 191.f, 0.f, \ - 0.f, 127.f, 0.f, \ - 0.f, 63.f, 0.f, \ - \ - 255.f, 0.f, 153.f, \ - 191.f, 0.f, 114.f, \ - 127.f, 0.f, 76.f, \ - 63.f, 0.f, 38.f, \ - 203.f, 0.f, 255.f, \ - 152.f, 0.f, 191.f, \ - 101.f, 0.f, 127.f, \ - 50.f, 0.f, 63.f, \ - 50.f, 0.f, 255.f, \ - 37.f, 0.f, 191.f, \ - 25.f, 0.f, 127.f, \ - 12.f, 0.f, 63.f, \ - 0.f, 102.f, 255.f, \ - 0.f, 76.f, 191.f, \ - 0.f, 51.f, 127.f, \ - 0.f, 25.f, 63.f, \ - 0.f, 255.f, 255.f, \ - 0.f, 191.f, 191.f, \ - 0.f, 127.f, 127.f, \ - 0.f, 63.f, 63.f + 0.f, 0.f, 255.f, \ + 0.f, 0.f, 255.f, \ + 0.f, 0.f, 255.f, \ + 0.f, 255.f, 255.f, \ + 0.f, 255.f, 255.f, \ + 0.f, 255.f, 255.f // BODY_65 // Body + left hand + right hand #define POSE_BODY_65_PAIRS_RENDER_GPU \ diff --git a/src/openpose/3d/jointAngleEstimation.cpp b/src/openpose/3d/jointAngleEstimation.cpp index 7cc265dd..b6fd7500 100644 --- a/src/openpose/3d/jointAngleEstimation.cpp +++ b/src/openpose/3d/jointAngleEstimation.cpp @@ -225,7 +225,7 @@ namespace op // Sanity check if (!poseKeypoints3D.empty() && poseKeypoints3D.getSize(1) != 19 && poseKeypoints3D.getSize(1) != 25 && poseKeypoints3D.getSize(1) != 65) - error("Only working for BODY_19 or BODY_25/BODY_25_19 or BODY_65 (#parts = " + error("Only working for BODY_19 or BODY_25 or BODY_65 (#parts = " + std::to_string(poseKeypoints3D.getSize(2)) + ").", __LINE__, __FUNCTION__, __FILE__); // Shorter naming diff --git a/src/openpose/calibration/cameraParameterEstimation.cpp b/src/openpose/calibration/cameraParameterEstimation.cpp index cd26eda2..ff7b3b0e 100644 --- a/src/openpose/calibration/cameraParameterEstimation.cpp +++ b/src/openpose/calibration/cameraParameterEstimation.cpp @@ -497,7 +497,7 @@ namespace op // Reordering points2DVector to have the first point at the top left position (top right in // case the chessboard is mirrored) - reorderPoints(points2DVector, gridInnerCorners, Points2DOrigin::TopLeft); + reorderPoints(points2DVector, gridInnerCorners, image); // Generate objects3DVector from gridSquareSizeMm const auto objects3DVector = getObjects3DVector(gridInnerCorners, gridSquareSizeMm); @@ -779,7 +779,7 @@ namespace op // Reorder & save 2D pixels points if (found) { - reorderPoints(points2DVector, gridInnerCornersCvSize, Points2DOrigin::TopLeft); + reorderPoints(points2DVector, gridInnerCornersCvSize, image); for (auto i = 0 ; i < numberCorners ; i++) matchIndexesCamera.emplace_back(viewIndex * numberCorners + i); } @@ -884,7 +884,9 @@ namespace op // Reorder & save 2D pixels points if (found) { - reorderPoints(points2DVector, gridInnerCornersCvSize, Points2DOrigin::TopLeft); + // For intrinsics order is irrelevant, so I do not care if it fails + const auto showWarning = false; + reorderPoints(points2DVector, gridInnerCornersCvSize, image, showWarning); points2DVectors.emplace_back(points2DVector); } else diff --git a/src/openpose/calibration/gridPatternFunctions.cpp b/src/openpose/calibration/gridPatternFunctions.cpp index 91deb5a2..30460537 100644 --- a/src/openpose/calibration/gridPatternFunctions.cpp +++ b/src/openpose/calibration/gridPatternFunctions.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -118,7 +119,7 @@ namespace op if (chessboardFound && image.size().width != tempImage.size().width) { log("Chessboard found at lower resolution (" + std::to_string(tempImage.cols) + "x" - + std::to_string(tempImage.rows) + ".", Priority::High); + + std::to_string(tempImage.rows) + ").", Priority::High); for (auto& point : points2DVector) point *= (image.size().width / tempImage.size().width); } @@ -310,37 +311,234 @@ namespace op } void reorderPoints(std::vector& points2DVector, const cv::Size& gridInnerCorners, - const Points2DOrigin points2DOriginDesired) + const cv::Mat& image, const bool showWarning) { try { - const auto points2DOriginCurrent = getPoints2DOrigin(gridInnerCorners, points2DVector); - - // No mirrored image - if (points2DOriginDesired == Points2DOrigin::TopLeft) + const auto debugging = false; + // gridInnerCorners is 2 even + // In this case, there will be 2 black corners in diagonal, and 2 white ones in the opposite diagonal + // No way to get absolute orientation. + // OR + // gridInnerCorners is 2 odd + // In this case, there will be all black (or white) corners in diagonal, and 2 white ones in the opposite + // diagonal + // No way to get absolute orientation. + if ((gridInnerCorners.width % 2 == 0 && gridInnerCorners.height % 2 == 0) + || (gridInnerCorners.width % 2 == 1 && gridInnerCorners.height % 2 == 1)) { - if (points2DOriginCurrent == Points2DOrigin::TopRight) - invertXPositionsIndices(points2DVector, gridInnerCorners); - else if (points2DOriginCurrent == Points2DOrigin::BottomLeft) - { - std::reverse(points2DVector.begin(), points2DVector.end()); - invertXPositionsIndices(points2DVector, gridInnerCorners); - } - else if (points2DOriginCurrent == Points2DOrigin::BottomRight) - std::reverse(points2DVector.begin(), points2DVector.end()); + // Warning + if (showWarning) + log("For maximum multi-view accuracy: The number of corners of the chessboard should be even in" + " 1 dimension and odd in the other (e.g., 1x2, 2x1, 1x4, 3x8, 6x9, 9x6, etc.). Otherwise," + " extrinsics calibration results might be affected.", Priority::High); + // Old method + const auto points2DOriginCurrent = getPoints2DOrigin(gridInnerCorners, points2DVector); + // // No mirrored image + // if (points2DOriginDesired == Points2DOrigin::TopLeft) + // { + if (points2DOriginCurrent == Points2DOrigin::TopRight) + invertXPositionsIndices(points2DVector, gridInnerCorners); + else if (points2DOriginCurrent == Points2DOrigin::BottomLeft) + { + std::reverse(points2DVector.begin(), points2DVector.end()); + invertXPositionsIndices(points2DVector, gridInnerCorners); + } + else if (points2DOriginCurrent == Points2DOrigin::BottomRight) + std::reverse(points2DVector.begin(), points2DVector.end()); + // } + // // Mirrored image + // else if (points2DOriginDesired == Points2DOrigin::TopRight) + // { + // if (points2DOriginCurrent == Points2DOrigin::TopLeft) + // invertXPositionsIndices(points2DVector, gridInnerCorners); + // else if (points2DOriginCurrent == Points2DOrigin::BottomLeft) + // std::reverse(points2DVector.begin(), points2DVector.end()); + // else if (points2DOriginCurrent == Points2DOrigin::BottomRight) + // { + // std::reverse(points2DVector.begin(), points2DVector.end()); + // invertXPositionsIndices(points2DVector, gridInnerCorners); + // } + // } } - - // Mirrored image - else if (points2DOriginDesired == Points2DOrigin::TopRight) + // gridInnerCorners is 1 even, 1 odd + // In this case, there will be 2 consecutive white and 2 consecutive black corners. + // Easy to get absolute orientation: We detect the 2 black corners. Then, we pick as main one the black + // one whose left is white and right is black (only 1 satisfies this) by cross product properties. + else { - if (points2DOriginCurrent == Points2DOrigin::TopLeft) - invertXPositionsIndices(points2DVector, gridInnerCorners); - else if (points2DOriginCurrent == Points2DOrigin::BottomLeft) - std::reverse(points2DVector.begin(), points2DVector.end()); - else if (points2DOriginCurrent == Points2DOrigin::BottomRight) + const auto outterCornerIndices = getOutterCornerIndices(points2DVector, gridInnerCorners); + const std::vector fourPointsVector{ + points2DVector.at(outterCornerIndices.at(0)), + points2DVector.at(outterCornerIndices.at(1)), + points2DVector.at(outterCornerIndices.at(2)), + points2DVector.at(outterCornerIndices.at(3)) + }; + const auto point01 = fourPointsVector.at(0)-fourPointsVector.at(1); + const auto point01Norm = cv::norm(point01); + const auto point02 = fourPointsVector.at(0)-fourPointsVector.at(2); + const auto point02Norm = cv::norm(point02); + const auto point13 = fourPointsVector.at(1)-fourPointsVector.at(3); + const auto point13Norm = cv::norm(point13); + const auto averageSquareSizePx = + (point01Norm/gridInnerCorners.width + + point02Norm/gridInnerCorners.height + + point13Norm/gridInnerCorners.height + + cv::norm(fourPointsVector.at(3)-fourPointsVector.at(2))/gridInnerCorners.width) + / 4.; + // Debugging + if (debugging) + log("\naverageSquareSizePx: " + std::to_string(averageSquareSizePx)); + // How many pixels does the outter square has? + // 0.67 is a threshold to be safe + const auto diagonalLength = 0.67 * std::sqrt(2) * averageSquareSizePx; + // Debugging + if (debugging) + log("diagonalLength: " + std::to_string(diagonalLength)); + + // In which direction do I have to look? + // Normal vector between corners 0-1, 0-2, 1-3? + const auto point01Direction = 1. / point01Norm * point01; + const auto point02Direction = 1. / point02Norm * point02; + const auto point13Direction = 1. / point13Norm * point13; + // Debugging + if (debugging) + { + log("\npoint01Direction:"); + log(point01Direction); + log("point02Direction:"); + log(point02Direction); + log("point13Direction:"); + log(point13Direction); + log(" "); + } + + auto pointDirection = fourPointsVector; // Initialization + pointDirection[0] = 1. / cv::norm(point01Direction + point02Direction) + * (point01Direction + point02Direction); + pointDirection[1] = pointDirection[0]; + pointDirection[1].y *= -1; + pointDirection[2] = pointDirection[0]; + pointDirection[2].x *= -1; + pointDirection[3] = -pointDirection[0]; + // Debugging + if (debugging) + { + for (auto i = 0u ; i < fourPointsVector.size() ; i++) + { + log("pointDirection[" + std::to_string(i) + "]:"); + log(pointDirection[i]); + } + log(" "); + } + + // Get line to check whether outter grid color is black + auto pointLimit = fourPointsVector; // Initialization + for (auto i = 0u ; i < fourPointsVector.size() ; i++) + pointLimit[i] = fourPointsVector[i] + diagonalLength * pointDirection[i]; + + // Line search to see if white or black + std::vector meanPxValues(fourPointsVector.size()); + const auto numberPointsInLine = 25; + const auto imageSize = image.size(); + for (auto i = 0u ; i < fourPointsVector.size() ; i++) + { + auto sum = 0.; + auto count = 0u; + for (auto lm = 0; lm < numberPointsInLine; lm++) + { + const auto mX = fastMax( + 0, fastMin(imageSize.width-1, intRound(fourPointsVector[i].x + lm*pointDirection[i].x))); + const auto mY = fastMax( + 0, fastMin(imageSize.height-1, intRound(fourPointsVector[i].y + lm*pointDirection[i].y))); + const cv::Vec3b bgrValue = image.at(mY, mX); + sum += (bgrValue.val[0] + bgrValue.val[1] + bgrValue.val[2])/3; + count++; + } + meanPxValues[i] = sum/count; + // Debugging + if (debugging) + log("meanPxValues[" + std::to_string(i) + "]: " + std::to_string(meanPxValues[i])); + } + + // Get black indexes + const bool blackIs0 = meanPxValues[0] < meanPxValues[3]; + bool blackIs1 = meanPxValues[1] < meanPxValues[2]; + + // Debugging + if (debugging) + { + // Plotting visually results + auto imageToPlot = image.clone(); + for (auto i = 0u ; i < fourPointsVector.size() ; i++) + cv::line(imageToPlot, fourPointsVector[i], pointLimit[i], cv::Scalar{0,0,255}, 10); + // Black indexes + log(" "); + log("blackIs0: " + std::to_string(blackIs0)); + log("blackIs1: " + std::to_string(blackIs1)); + // Plotting results + // Chessboard before + drawGridCorners(imageToPlot, gridInnerCorners, points2DVector); + cv::pyrDown(imageToPlot, imageToPlot); + cv::imshow("image_before", imageToPlot); + } + + // Apply transformations + // For simplicity, we assume 0 is black + if (!blackIs0) { std::reverse(points2DVector.begin(), points2DVector.end()); - invertXPositionsIndices(points2DVector, gridInnerCorners); + blackIs1 = !blackIs1; + // Debugging + if (debugging) + log("Swapping 0 and 3 so 0 is black."); + } + // Lead is 0 or 1||2 (depending on blackIs1)? + const auto outterCornerIndicesAfter = getOutterCornerIndices(points2DVector, gridInnerCorners); + const auto middle = 0.25f*( + fourPointsVector[0] + fourPointsVector[1] + fourPointsVector[2] + fourPointsVector[3]); + const std::vector fourPointsVectorAfter{ + points2DVector.at(outterCornerIndicesAfter.at(0)) - middle, + points2DVector.at(outterCornerIndicesAfter.at(1)) - middle, + points2DVector.at(outterCornerIndicesAfter.at(2)) - middle, + points2DVector.at(outterCornerIndicesAfter.at(3)) - middle + }; + const auto crossProduct = fourPointsVectorAfter[0].cross(fourPointsVectorAfter[(blackIs1 ? 1 : 2)]); + // Debugging + if (debugging) + log("crossProduct: " + std::to_string(crossProduct)); + const auto leadIs0 = crossProduct < 0; + // Second transformation + if (!leadIs0) + { + // Debugging + if (debugging) + log("Lead is not 0."); + // Second black is 1 + if (blackIs1) + { + // Debugging + if (debugging) + log("Lead was 1."); + invertXPositionsIndices(points2DVector, gridInnerCorners); // 1->0 + } + // Second black is 2 + else + { + // Debugging + if (debugging) + log("Lead was 2."); + std::reverse(points2DVector.begin(), points2DVector.end()); // 2->3 + invertXPositionsIndices(points2DVector, gridInnerCorners); // 3->0 + } + } + + // Debugging + if (debugging) + { + // Chessboard after + plotGridCorners(gridInnerCorners, points2DVector, "image_after.jpg", image); + cv::waitKey(0); } } } @@ -357,10 +555,8 @@ namespace op try { cv::Mat imageToPlot = image.clone(); - // Draw corners drawGridCorners(imageToPlot, gridInnerCorners, points2DVector); - // Plotting results const std::string windowName = getFileNameAndExtension(imagePath); cv::pyrDown(imageToPlot, imageToPlot); diff --git a/src/openpose/net/bodyPartConnectorBase.cpp b/src/openpose/net/bodyPartConnectorBase.cpp index 928cd9d1..b2fd734a 100644 --- a/src/openpose/net/bodyPartConnectorBase.cpp +++ b/src/openpose/net/bodyPartConnectorBase.cpp @@ -74,7 +74,7 @@ namespace op // - double: person subset score std::vector, T>> peopleVector; const auto& mapIdx = getPoseMapIndex(poseModel); - const auto numberBodyPartsAndBkg = numberBodyParts + 1; + const auto numberBodyPartsAndBkg = numberBodyParts + (poseModel != PoseModel::BODY_25B ? 1 : 0); const auto vectorSize = numberBodyParts+1; const auto peaksOffset = 3*(maxPeaks+1); const auto heatMapOffset = heatMapSize.area(); diff --git a/src/openpose/net/bodyPartConnectorCaffe.cpp b/src/openpose/net/bodyPartConnectorCaffe.cpp index 7c9efa53..f00f7cd6 100644 --- a/src/openpose/net/bodyPartConnectorCaffe.cpp +++ b/src/openpose/net/bodyPartConnectorCaffe.cpp @@ -196,7 +196,7 @@ namespace op { #ifdef USE_CAFFE const auto heatMapsBlob = bottom.at(0); - const auto* const heatMapsPtr = heatMapsBlob->cpu_data(); // ~8.5 ms COCO, 27ms BODY_59 + const auto* const heatMapsPtr = heatMapsBlob->cpu_data(); // ~8.5 ms COCO, ~27ms BODY_65 const auto* const peaksPtr = bottom.at(1)->cpu_data(); // ~0.02ms const auto maxPeaks = mTopSize[1]; connectBodyPartsCpu(poseKeypoints, poseScores, heatMapsPtr, peaksPtr, mPoseModel, @@ -239,9 +239,10 @@ namespace op const auto numberBodyParts = getPoseNumberBodyParts(mPoseModel); const auto& mapIdxOffset = getPoseMapIndex(mPoseModel); // Update mapIdx + const auto offset = (mPoseModel != PoseModel::BODY_25B ? 1 : 0); auto mapIdx = mapIdxOffset; for (auto& i : mapIdx) - i += (numberBodyParts+1); + i += (numberBodyParts+offset); // Re-allocate memory cudaMalloc((void **)&pBodyPartPairsGpuPtr, bodyPartPairs.size() * sizeof(unsigned int)); cudaMemcpy(pBodyPartPairsGpuPtr, &bodyPartPairs[0], bodyPartPairs.size() * sizeof(unsigned int), diff --git a/src/openpose/pose/poseGpuRenderer.cpp b/src/openpose/pose/poseGpuRenderer.cpp index 0792a1f2..451d2d29 100644 --- a/src/openpose/pose/poseGpuRenderer.cpp +++ b/src/openpose/pose/poseGpuRenderer.cpp @@ -80,7 +80,8 @@ namespace op cpuToGpuMemoryIfNotCopiedYet(outputData.getPtr(), outputData.getVolume()); cudaCheck(__LINE__, __FUNCTION__, __FILE__); const auto numberBodyParts = getPoseNumberBodyParts(mPoseModel); - const auto numberBodyPartsPlusBkg = numberBodyParts+1; + const auto hasBkg = (mPoseModel != PoseModel::BODY_25B); + const auto numberBodyPartsPlusBkg = numberBodyParts + (hasBkg ? 1 : 0); const auto numberBodyPAFChannels = getPosePartPairs(mPoseModel).size(); const Point frameSize{outputData.getSize(1), outputData.getSize(0)}; // Draw poseKeypoints @@ -134,8 +135,8 @@ namespace op else if (elementRendered <= numberBodyPartsPlusBkg+2) { const auto realElementRendered = (elementRendered == 1 - ? numberBodyParts - : elementRendered - 4); + ? (hasBkg ? numberBodyParts : 0) + : elementRendered - 3 - (hasBkg ? 1:0)); elementRenderedName = mPartIndexToName.at(realElementRendered); renderPoseHeatMapGpu( *spGpuMemory, frameSize, spPoseExtractorNet->getHeatMapGpuConstPtr(), heatMapSize, diff --git a/src/openpose/pose/poseParameters.cpp b/src/openpose/pose/poseParameters.cpp index 7ad439e6..c7f9c23a 100644 --- a/src/openpose/pose/poseParameters.cpp +++ b/src/openpose/pose/poseParameters.cpp @@ -119,41 +119,32 @@ namespace op {22, "RHeel"}, {23, "Background"} }; - const std::map POSE_BODY_59_BODY_PARTS { - // Body + const std::map POSE_BODY_25B_BODY_PARTS { {0, "Nose"}, - {1, "Neck"}, - {2, "RShoulder"}, - {3, "RElbow"}, - {4, "RWrist"}, + {1, "LEye"}, + {2, "REye"}, + {3, "LEar"}, + {4, "REar"}, {5, "LShoulder"}, - {6, "LElbow"}, - {7, "LWrist"}, - {8, "MidHip"}, - {9, "RHip"}, - {10, "RKnee"}, - {11, "RAnkle"}, - {12, "LHip"}, + {6, "RShoulder"}, + {7, "LElbow"}, + {8, "RElbow"}, + {9, "LWrist"}, + {10, "RWrist"}, + {11, "LHip"}, + {12, "RHip"}, {13, "LKnee"}, - {14, "LAnkle"}, - {15, "REye"}, - {16, "LEye"}, - {17, "REar"}, - {18, "LEar"}, - // Left hand - {19, "LThumb1CMC"}, {20, "LThumb2Knuckles"},{21, "LThumb3IP"}, {22, "LThumb4FingerTip"}, - {23, "LIndex1Knuckles"}, {24, "LIndex2PIP"}, {25, "LIndex3DIP"}, {26, "LIndex4FingerTip"}, - {27, "LMiddle1Knuckles"}, {28, "LMiddle2PIP"}, {29, "LMiddle3DIP"},{30, "LMiddle4FingerTip"}, - {31, "LRing1Knuckles"}, {32, "LRing2PIP"}, {33, "LRing3DIP"}, {34, "LRing4FingerTip"}, - {35, "LPinky1Knuckles"}, {36, "LPinky2PIP"}, {37, "LPinky3DIP"}, {38, "LPinky4FingerTip"}, - // Right hand - {39, "RThumb1CMC"}, {40, "RThumb2Knuckles"},{41, "RThumb3IP"}, {42, "RThumb4FingerTip"}, - {43, "RIndex1Knuckles"}, {44, "RIndex2PIP"}, {45, "RIndex3DIP"}, {46, "RIndex4FingerTip"}, - {47, "RMiddle1Knuckles"}, {48, "RMiddle2PIP"}, {49, "RMiddle3DIP"},{50, "RMiddle4FingerTip"}, - {51, "RRing1Knuckles"}, {52, "RRing2PIP"}, {53, "RRing3DIP"}, {54, "RRing4FingerTip"}, - {55, "RPinky1Knuckles"}, {56, "RPinky2PIP"}, {57, "RPinky3DIP"}, {58, "RPinky4FingerTip"}, - // Background - {59, "Background"}, + {14, "RKnee"}, + {15, "LAnkle"}, + {16, "RAnkle"}, + {17, "UpperNeck"}, + {18, "HeadTop"}, + {19, "LBigToe"}, + {20, "LSmallToe"}, + {21, "LHeel"}, + {22, "RBigToe"}, + {23, "RSmallToe"}, + {24, "RHeel"}, }; const std::map POSE_BODY_65_BODY_PARTS { // Body @@ -273,14 +264,6 @@ namespace op std::vector{ 0,1, 14,15, 22,23, 16,17, 18,19, 24,25, 26,27, 6,7, 2,3, 4,5, 8,9, 10,11, 12,13, 30,31, 32,33, 36,37, 34,35, 38,39, 20,21, 28,29 }, - // BODY_59 - std::vector{ - 0,1, 14,15, 22,23, 16,17, 18,19, 24,25, 26,27, 6,7, 2,3, 4,5, 8,9, 10,11, 12,13, 30,31, 32,33, 36,37, 34,35, 38,39, 20,21, 28,29, // Body - 40,41, 42,43, 44,45, 46,47, 48,49, 14,51, 52,53, 54,55, 56,57, 58,59, - 60,61, 62,63, 64,65, 66,67, 68,69, 70,71, 72,73, 74,75, 76,77, 78,79,// Left hand - 80,81, 82,83, 84,85, 86,87, 88,89, 90,91, 92,93, 94,95, 96,97, 98,99, - 100,101, 102,103, 104,105, 106,107, 108,109, 110,111, 112,113, 114,115, 116,117, 118,119 // Right hand - }, // BODY_19N std::vector{ 0,1, 14,15, 22,23, 16,17, 18,19, 24,25, 26,27, 6,7, 2,3, 4,5, 8,9, 10,11, 12,13, 30,31, 32,33, 36,37, 34,35, 38,39, 20,21, 28,29 @@ -292,10 +275,6 @@ namespace op // Redundant ones 48,49, 50,51, 52,53, 54,55, 56,57, 58,59, 60,61, 62,63, 64,65, 66,67, 68,69, 70,71, 72,73, 74,75 }, - // BODY_25_19 - std::vector{ - 0,1, 14,15, 22,23, 16,17, 18,19, 24,25, 26,27, 6,7, 2,3, 4,5, 8,9, 10,11, 12,13, 30,31, 32,33, 36,37, 34,35, 38,39, 20,21, 28,29, 40,41,42,43,44,45, 46,47,48,49,50,51 - }, // BODY_65 std::vector{ 0,1, 14,15, 22,23, 16,17, 18,19, 24,25, 26,27, 6,7, 2,3, 4,5, 8,9, 10,11, 12,13, 30,31, 32,33, 36,37, 34,35, 38,39, 20,21, 28,29, 40,41,42,43,44,45, 46,47,48,49,50,51, // Body @@ -331,13 +310,25 @@ namespace op // Redundant ones 38,39, 40,41, 42,43, 44,45, 46,47, 48,49, 50,51, 52,53, 54,55, 56,57, 58,59, 60,61 }, + // BODY_25B + std::vector{ + // Minimum spanning tree + // |------------------------------------------- COCO Body -------------------------------------------| + 0,1, 2,3, 4,5, 6,7, 8,9,10,11, 12,13,14,15,16,17,18,19, 20,21, 22,23, 24,25, 26,27, 28,29, 30,31, + // Redundant ones + // |------------------ Foot ------------------| |-- MPII --| + 32,33, 34,35, 36,37, 38,39, 40,41, 42,43, 44,45, 46,47, + // Redundant ones + // MPII redundant, ears, ears-shoulders, shoulders-wrists, wrists, wrists-hips, hips, ankles) + 48,49, 50,51, 52,53, 54,55, 56,57, 58,59, 60,61, 62,63, 64,65, 66,67, 68,69, 70,71 + }, }; // POSE_BODY_PART_MAPPING on HPP crashes on Windows at dynamic initialization if it's on hpp const std::array, (int)PoseModel::Size> POSE_BODY_PART_MAPPING{ POSE_BODY_25_BODY_PARTS,POSE_COCO_BODY_PARTS, POSE_MPI_BODY_PARTS, POSE_MPI_BODY_PARTS, - POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_59_BODY_PARTS,POSE_BODY_19_BODY_PARTS, - POSE_BODY_25_BODY_PARTS,POSE_BODY_25_BODY_PARTS,POSE_BODY_65_BODY_PARTS,POSE_CAR_12_PARTS, - POSE_BODY_25_BODY_PARTS,POSE_BODY_23_BODY_PARTS,POSE_CAR_22_PARTS, POSE_BODY_19_BODY_PARTS + POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_25_BODY_PARTS, + POSE_BODY_65_BODY_PARTS,POSE_CAR_12_PARTS, POSE_BODY_25_BODY_PARTS,POSE_BODY_23_BODY_PARTS, + POSE_CAR_22_PARTS, POSE_BODY_19_BODY_PARTS,POSE_BODY_25B_BODY_PARTS }; const std::array POSE_PROTOTXT{ @@ -347,16 +338,15 @@ namespace op "pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt", "pose/body_19/pose_deploy.prototxt", "pose/body_19_x2/pose_deploy.prototxt", - "pose/body_59/pose_deploy.prototxt", "pose/body_19n/pose_deploy.prototxt", "pose/body_25e/pose_deploy.prototxt", - "pose/body_19_25/pose_deploy_25.prototxt", "pose/body_65/pose_deploy.prototxt", "car/car_12/pose_deploy.prototxt", "pose/body_25d/pose_deploy.prototxt", "pose/body_23/pose_deploy.prototxt", "car/car_22/pose_deploy.prototxt", "pose/body_19e/pose_deploy.prototxt", + "pose/body_25b/pose_deploy.prototxt", }; const std::array POSE_TRAINED_MODEL{ "pose/body_25/pose_iter_584000.caffemodel", @@ -365,22 +355,21 @@ namespace op "pose/mpi/pose_iter_160000.caffemodel", "pose/body_19/pose_iter_XXXXXX.caffemodel", "pose/body_19_x2/pose_iter_XXXXXX.caffemodel", - "pose/body_59/pose_iter_XXXXXX.caffemodel", "pose/body_19n/pose_iter_XXXXXX.caffemodel", "pose/body_25e/pose_iter_XXXXXX.caffemodel", - "pose/body_19_25/pose_iter_XXXXXX.caffemodel", "pose/body_65/pose_iter_XXXXXX.caffemodel", "car/car_12/pose_iter_XXXXXX.caffemodel", "pose/body_25d/pose_iter_XXXXXX.caffemodel", "pose/body_23/pose_iter_XXXXXX.caffemodel", "car/car_22/pose_iter_XXXXXX.caffemodel", "pose/body_19e/pose_iter_XXXXXX.caffemodel", + "pose/body_25b/pose_iter_XXXXXX.caffemodel", }; // Constant Array Parameters // POSE_NUMBER_BODY_PARTS equivalent to size of std::map POSE_BODY_XX_BODY_PARTS - 1 (removing background) const std::array POSE_NUMBER_BODY_PARTS{ - 25, 18, 15, 15, 19, 19, 59, 19, 25, 25, 65, 12, 25, 23, 22, 19 + 25, 18, 15, 15, 19, 19, 19, 25, 65, 12, 25, 23, 22, 19, 25 }; const std::array, (int)PoseModel::Size> POSE_BODY_PART_PAIRS{ // BODY_25 @@ -403,12 +392,6 @@ namespace op std::vector{ 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, 2,17, 5,18 }, - // BODY_59 - std::vector{ - 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, 2,17, 5,18,// Body - 7,19, 19,20, 20,21, 21,22, 7,23, 23,24, 24,25, 25,26, 7,27, 27,28, 28,29, 29,30, 7,31, 31,32, 32,33, 33,34, 7,35, 35,36, 36,37, 37,38, // Left hand - 4,39, 39,40, 40,41, 41,42, 4,43, 43,44, 44,45, 45,46, 4,47, 47,48, 48,49, 49,50, 4,51, 51,52, 52,53, 53,54, 4,55, 55,56, 56,57, 57,58 // Right hand - }, // BODY_19N std::vector{ 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, 2,17, 5,18 @@ -423,10 +406,6 @@ namespace op // Ears-shoulders, shoulders-hips, shoulders-wrists, hips-ankles, wrists, ankles, wrists-hips, small toes-ankles) 2,17, 5,18, 2,9, 5,12, 2,4, 5,7, 9,11, 12,14, 4,7, 11,14, 4,9, 7,12, 11,23, 14,20 }, - // BODY_25_19 - std::vector{ - 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, 2,17, 5,18, 14,19,19,20,14,21, 11,22,22,23,11,24 - }, // BODY_65 std::vector{ 1,8, 1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 8,9, 9,10, 10,11, 8,12, 12,13, 13,14, 1,0, 0,15, 15,17, 0,16, 16,18, 2,17, 5,18, 14,19,19,20,14,21, 11,22,22,23,11,24, @@ -465,6 +444,17 @@ namespace op // Ears-shoulders, shoulders-hips, shoulders-wrists, hips-ankles, wrists, ankles, wrists-hips, small toes-ankles) 2,17, 5,18, 2,9, 5,12, 2,4, 5,7, 9,11, 12,14, 4,7, 11,14, 4,9, 7,12//, 11,23, 14,20 }, + // BODY_25B + std::vector{ + // Minimum spanning tree + // |------------------------------------------- COCO Body -------------------------------------------| + 0,1, 0,2, 1,3, 2,4, 0,5, 0,6, 5,7, 6,8, 7,9, 8,10, 5,11, 6,12, 11,13, 12,14, 13,15, 14,16, + // |------------------ Foot ------------------| |-- MPII --| + 15,19, 19,20, 15,21, 16,22, 22,23, 16,24, 5,17, 5,18, + // Redundant ones + // MPII redundant, ears, ears-shoulders, shoulders-wrists, wrists, wrists-hips, hips, ankles) + 6,17, 6,18, 3,4, 3,5, 4,6, 5,9, 6,10, 9,10, 9,11, 10,12, 11,12, 15,16 + } }; const std::array POSE_CCN_DECREASE_FACTOR{ 8.f, // BODY_25 @@ -473,16 +463,15 @@ namespace op 8.f, // MPI_15_4 8.f, // BODY_19 4.f, // BODY_19_X2 - 8.f, // BODY_59 8.f, // BODY_19N 8.f, // BODY_25E - 8.f, // BODY_25_19 8.f, // BODY_65 8.f, // CAR_12 8.f, // BODY_25D 8.f, // BODY_23 8.f, // CAR_22 8.f, // BODY_19E + 8.f, // BODY_25B }; const std::map& getPoseBodyPartMapping(const PoseModel poseModel) diff --git a/src/openpose/pose/poseParametersRender.cpp b/src/openpose/pose/poseParametersRender.cpp index 8075706c..7c6759c1 100644 --- a/src/openpose/pose/poseParametersRender.cpp +++ b/src/openpose/pose/poseParametersRender.cpp @@ -10,16 +10,15 @@ namespace op std::vector{POSE_MPI_SCALES_RENDER_GPU}, // MPI_15_4 std::vector{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19 std::vector{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19_X2 - std::vector{POSE_BODY_59_SCALES_RENDER_GPU}, // BODY_59 std::vector{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19N std::vector{POSE_BODY_25_SCALES_RENDER_GPU}, // BODY_25E - std::vector{POSE_BODY_25_SCALES_RENDER_GPU}, // BODY_25_19 std::vector{POSE_BODY_65_SCALES_RENDER_GPU}, // BODY_65 std::vector{POSE_CAR_12_SCALES_RENDER_GPU}, // CAR_12 std::vector{POSE_BODY_25_SCALES_RENDER_GPU}, // BODY_25D std::vector{POSE_BODY_23_SCALES_RENDER_GPU}, // BODY_23 std::vector{POSE_CAR_22_SCALES_RENDER_GPU}, // CAR_22 std::vector{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19E + std::vector{POSE_BODY_25B_SCALES_RENDER_GPU}, // BODY_25B }; const std::array, (int)PoseModel::Size> POSE_COLORS{ std::vector{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25 @@ -28,16 +27,15 @@ namespace op std::vector{POSE_MPI_COLORS_RENDER_GPU}, // MPI_15_4 std::vector{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19 std::vector{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19_X2 - std::vector{POSE_BODY_59_COLORS_RENDER_GPU}, // BODY_59 std::vector{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19N std::vector{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25E - std::vector{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25_19 std::vector{POSE_BODY_65_COLORS_RENDER_GPU}, // BODY_65 std::vector{POSE_CAR_12_COLORS_RENDER_GPU}, // CAR_12 std::vector{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25D std::vector{POSE_BODY_23_COLORS_RENDER_GPU}, // BODY_23 std::vector{POSE_CAR_22_COLORS_RENDER_GPU}, // CAR_22 std::vector{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19E + std::vector{POSE_BODY_25B_COLORS_RENDER_GPU}, // BODY_25B }; const std::array, (int)PoseModel::Size> POSE_BODY_PART_PAIRS_RENDER{ std::vector{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25 @@ -46,16 +44,15 @@ namespace op std::vector{POSE_MPI_PAIRS_RENDER_GPU}, // MPI_15_4 std::vector{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19 std::vector{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19_X2 - std::vector{POSE_BODY_59_PAIRS_RENDER_GPU}, // BODY_59 std::vector{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19N std::vector{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25E - std::vector{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25_19 std::vector{POSE_BODY_65_PAIRS_RENDER_GPU}, // BODY_65 std::vector{POSE_CAR_12_PAIRS_RENDER_GPU}, // CAR_12 std::vector{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25D std::vector{POSE_BODY_23_PAIRS_RENDER_GPU}, // BODY_23 std::vector{POSE_CAR_22_PAIRS_RENDER_GPU}, // CAR_22 std::vector{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19E + std::vector{POSE_BODY_25B_PAIRS_RENDER_GPU}, // BODY_25B }; // Rendering functions diff --git a/src/openpose/pose/poseRenderer.cpp b/src/openpose/pose/poseRenderer.cpp index b9e5609c..5303f971 100644 --- a/src/openpose/pose/poseRenderer.cpp +++ b/src/openpose/pose/poseRenderer.cpp @@ -14,7 +14,7 @@ namespace op const auto& bodyPartPairs = getPosePartPairs(poseModel); const auto& mapIdx = getPoseMapIndex(poseModel); const auto numberBodyParts = getPoseNumberBodyParts(poseModel); - const auto numberBodyPartsPlusBkg = numberBodyParts+1; + const auto numberBodyPartsPlusBkg = numberBodyParts+(poseModel != PoseModel::BODY_25B ? 1 : 0); // Sanity check if (bodyPartPairs.size() != mapIdx.size()) error("The variables bodyPartPairs and mapIdx should have the same size.", diff --git a/src/openpose/pose/renderPose.cu b/src/openpose/pose/renderPose.cu index 0d876f8d..f3b696bc 100644 --- a/src/openpose/pose/renderPose.cu +++ b/src/openpose/pose/renderPose.cu @@ -13,7 +13,7 @@ namespace op __constant__ const unsigned int COCO_PAIRS_GPU[] = {POSE_COCO_PAIRS_RENDER_GPU}; __constant__ const unsigned int BODY_19_PAIRS_GPU[] = {POSE_BODY_19_PAIRS_RENDER_GPU}; __constant__ const unsigned int BODY_23_PAIRS_GPU[] = {POSE_BODY_23_PAIRS_RENDER_GPU}; - __constant__ const unsigned int BODY_59_PAIRS_GPU[] = {POSE_BODY_59_PAIRS_RENDER_GPU}; + __constant__ const unsigned int BODY_25B_PAIRS_GPU[] = {POSE_BODY_25B_PAIRS_RENDER_GPU}; __constant__ const unsigned int BODY_65_PAIRS_GPU[] = {POSE_BODY_65_PAIRS_RENDER_GPU}; __constant__ const unsigned int MPI_PAIRS_GPU[] = {POSE_MPI_PAIRS_RENDER_GPU}; __constant__ const unsigned int CAR_12_PAIRS_GPU[] = {POSE_CAR_12_PAIRS_RENDER_GPU}; @@ -23,7 +23,7 @@ namespace op __constant__ const float COCO_SCALES[] = {POSE_COCO_SCALES_RENDER_GPU}; __constant__ const float BODY_19_SCALES[] = {POSE_BODY_19_SCALES_RENDER_GPU}; __constant__ const float BODY_23_SCALES[] = {POSE_BODY_23_SCALES_RENDER_GPU}; - __constant__ const float BODY_59_SCALES[] = {POSE_BODY_59_SCALES_RENDER_GPU}; + __constant__ const float BODY_25B_SCALES[] = {POSE_BODY_25B_SCALES_RENDER_GPU}; __constant__ const float BODY_65_SCALES[] = {POSE_BODY_65_SCALES_RENDER_GPU}; __constant__ const float MPI_SCALES[] = {POSE_MPI_SCALES_RENDER_GPU}; __constant__ const float CAR_12_SCALES[] = {POSE_CAR_12_SCALES_RENDER_GPU}; @@ -33,7 +33,7 @@ namespace op __constant__ const float COCO_COLORS[] = {POSE_COCO_COLORS_RENDER_GPU}; __constant__ const float BODY_19_COLORS[] = {POSE_BODY_19_COLORS_RENDER_GPU}; __constant__ const float BODY_23_COLORS[] = {POSE_BODY_23_COLORS_RENDER_GPU}; - __constant__ const float BODY_59_COLORS[] = {POSE_BODY_59_COLORS_RENDER_GPU}; + __constant__ const float BODY_25B_COLORS[] = {POSE_BODY_25B_COLORS_RENDER_GPU}; __constant__ const float BODY_65_COLORS[] = {POSE_BODY_65_COLORS_RENDER_GPU}; __constant__ const float MPI_COLORS[] = {POSE_MPI_COLORS_RENDER_GPU}; __constant__ const float CAR_12_COLORS[] = {POSE_CAR_12_COLORS_RENDER_GPU}; @@ -226,9 +226,9 @@ namespace op blendOriginalFrame, (googlyEyes ? 15 : -1), (googlyEyes ? 16 : -1)); } - __global__ void renderPoseBody59(float* targetPtr, const int targetWidth, const int targetHeight, - const float* const posePtr, const int numberPeople, const float threshold, - const bool googlyEyes, const bool blendOriginalFrame, const float alphaColorToAdd) + __global__ void renderPoseBody25b(float* targetPtr, const int targetWidth, const int targetHeight, + const float* const posePtr, const int numberPeople, const float threshold, + const bool googlyEyes, const bool blendOriginalFrame, const float alphaColorToAdd) { const auto x = (blockIdx.x * blockDim.x) + threadIdx.x; const auto y = (blockIdx.y * blockDim.y) + threadIdx.y; @@ -240,17 +240,17 @@ namespace op __shared__ float sharedScaleF[POSE_MAX_PEOPLE]; // Other parameters - const auto numberPartPairs = sizeof(BODY_59_PAIRS_GPU) / (2*sizeof(BODY_59_PAIRS_GPU[0])); - const auto numberScales = sizeof(BODY_59_SCALES) / sizeof(BODY_59_SCALES[0]); - const auto numberColors = sizeof(BODY_59_COLORS) / (3*sizeof(BODY_59_COLORS[0])); + const auto numberPartPairs = sizeof(BODY_25B_PAIRS_GPU) / (2*sizeof(BODY_25B_PAIRS_GPU[0])); + const auto numberScales = sizeof(BODY_25B_SCALES) / sizeof(BODY_25B_SCALES[0]); + const auto numberColors = sizeof(BODY_25B_COLORS) / (3*sizeof(BODY_25B_COLORS[0])); const auto radius = fastMin(targetWidth, targetHeight) / 100.f; const auto lineWidth = fastMin(targetWidth, targetHeight) / 120.f; // Render key points renderKeypoints(targetPtr, sharedMaxs, sharedMins, sharedScaleF, globalIdx, x, y, targetWidth, targetHeight, - posePtr, BODY_59_PAIRS_GPU, numberPeople, 59, numberPartPairs, BODY_59_COLORS, numberColors, - radius, lineWidth, BODY_59_SCALES, numberScales, threshold, alphaColorToAdd, - blendOriginalFrame, (googlyEyes ? 15 : -1), (googlyEyes ? 16 : -1)); + posePtr, BODY_25B_PAIRS_GPU, numberPeople, 25, numberPartPairs, BODY_25B_COLORS, numberColors, + radius, lineWidth, BODY_25B_SCALES, numberScales, threshold, alphaColorToAdd, + blendOriginalFrame, (googlyEyes ? 1 : -1), (googlyEyes ? 2 : -1)); } __global__ void renderPoseBody65(float* targetPtr, const int targetWidth, const int targetHeight, @@ -572,8 +572,8 @@ namespace op getNumberCudaThreadsAndBlocks(threadsPerBlock, numBlocks, frameSize); // Body pose - if (poseModel == PoseModel::BODY_25 || poseModel == PoseModel::BODY_25_19 - || poseModel == PoseModel::BODY_25D || poseModel == PoseModel::BODY_25E) + if (poseModel == PoseModel::BODY_25 || poseModel == PoseModel::BODY_25D + || poseModel == PoseModel::BODY_25E) renderPoseBody25<<>>( framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes, blendOriginalFrame, alphaBlending @@ -594,8 +594,8 @@ namespace op framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes, blendOriginalFrame, alphaBlending ); - else if (poseModel == PoseModel::BODY_59) - renderPoseBody59<<>>( + else if (poseModel == PoseModel::BODY_25B) + renderPoseBody25b<<>>( framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes, blendOriginalFrame, alphaBlending ); @@ -706,8 +706,10 @@ namespace op try { const auto numberBodyPartPairs = (int)getPosePartPairs(poseModel).size()/2; - renderPosePAFGpuAux(framePtr, poseModel, frameSize, heatMapPtr, heatMapSize, scaleToKeepRatio, - getPoseNumberBodyParts(poseModel)+1, numberBodyPartPairs, alphaBlending); + renderPosePAFGpuAux( + framePtr, poseModel, frameSize, heatMapPtr, heatMapSize, scaleToKeepRatio, + getPoseNumberBodyParts(poseModel) + (poseModel != PoseModel::BODY_25B ? 1 : 0), + numberBodyPartPairs, alphaBlending); } catch (const std::exception& e) { diff --git a/src/openpose/utilities/flagsToOpenPose.cpp b/src/openpose/utilities/flagsToOpenPose.cpp index 19a87839..134ce32c 100644 --- a/src/openpose/utilities/flagsToOpenPose.cpp +++ b/src/openpose/utilities/flagsToOpenPose.cpp @@ -22,22 +22,20 @@ namespace op return PoseModel::BODY_19; else if (poseModeString == "BODY_19E") return PoseModel::BODY_19E; - else if (poseModeString == "BODY_23") - return PoseModel::BODY_23; - else if (poseModeString == "BODY_25E") - return PoseModel::BODY_25E; else if (poseModeString == "BODY_19N") return PoseModel::BODY_19N; else if (poseModeString == "BODY_19_X2") return PoseModel::BODY_19_X2; - else if (poseModeString == "BODY_25_19") - return PoseModel::BODY_25_19; - else if (poseModeString == "BODY_59") - return PoseModel::BODY_59; - else if (poseModeString == "BODY_65") - return PoseModel::BODY_65; + else if (poseModeString == "BODY_23") + return PoseModel::BODY_23; + else if (poseModeString == "BODY_25B") + return PoseModel::BODY_25B; else if (poseModeString == "BODY_25D") return PoseModel::BODY_25D; + else if (poseModeString == "BODY_25E") + return PoseModel::BODY_25E; + else if (poseModeString == "BODY_65") + return PoseModel::BODY_65; // Car pose else if (poseModeString == "CAR_12") return PoseModel::CAR_12;