From 32c2a6f565477804cc1f7d4d2d07dd709283c79b Mon Sep 17 00:00:00 2001 From: gineshidalgo99 Date: Thu, 29 Jun 2017 11:48:57 -0400 Subject: [PATCH] Improved rendering, visually prettier --- include/openpose/hand/handParameters.hpp | 43 ++++++++++----------- include/openpose/pose/poseParameters.hpp | 18 +++++---- include/openpose/utilities/render.hu | 2 +- src/openpose/pose/bodyPartConnectorBase.cpp | 4 +- src/openpose/utilities/keypoint.cpp | 3 +- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/include/openpose/hand/handParameters.hpp b/include/openpose/hand/handParameters.hpp index 1ff79666..379effb2 100644 --- a/include/openpose/hand/handParameters.hpp +++ b/include/openpose/hand/handParameters.hpp @@ -12,30 +12,27 @@ namespace op #define HAND_PAIRS_RENDER_GPU {0,1, 1,2, 2,3, 3,4, 0,5, 5,6, 6,7, 7,8, 0,9, 9,10, 10,11, 11,12, 0,13, 13,14, 14,15, 15,16, 0,17, 17,18, 18,19, 19,20} const std::vector HAND_PAIRS_RENDER {HAND_PAIRS_RENDER_GPU}; #define HAND_COLORS_RENDER \ - 179.f, 0.f, 0.f, \ - 204.f, 0.f, 0.f, \ - 230.f, 0.f, 0.f, \ + 100.f, 100.f, 100.f, \ + 100.f, 0.f, 0.f, \ + 150.f, 0.f, 0.f, \ + 200.f, 0.f, 0.f, \ 255.f, 0.f, 0.f, \ - 143.f, 179.f, 0.f, \ - 163.f, 204.f, 0.f, \ - 184.f, 230.f, 0.f, \ - 204.f, 255.f, 0.f, \ - 0.f, 179.f, 71.f, \ - 0.f, 204.f, 82.f, \ - 0.f, 230.f, 92.f, \ - 0.f, 255.f, 102.f, \ - 0.f, 71.f, 179.f, \ - 0.f, 82.f, 204.f, \ - 0.f, 92.f, 230.f, \ - 0.f, 102.f, 255.f, \ - 143.f, 0.f, 179.f, \ - 163.f, 0.f, 204.f, \ - 184.f, 0.f, 230.f, \ - 204.f, 0.f, 255.f, \ - 179.f, 179.f, 179.f, \ - 179.f, 179.f, 179.f, \ - 179.f, 179.f, 179.f, \ - 179.f, 179.f, 179.f + 100.f, 100.f, 0.f, \ + 150.f, 150.f, 0.f, \ + 200.f, 200.f, 0.f, \ + 255.f, 255.f, 0.f, \ + 0.f, 100.f, 50.f, \ + 0.f, 150.f, 75.f, \ + 0.f, 200.f, 100.f, \ + 0.f, 255.f, 125.f, \ + 0.f, 50.f, 100.f, \ + 0.f, 75.f, 150.f, \ + 0.f, 100.f, 200.f, \ + 0.f, 125.f, 255.f, \ + 100.f, 0.f, 100.f, \ + 150.f, 0.f, 150.f, \ + 200.f, 0.f, 200.f, \ + 255.f, 0.f, 255.f // Constant parameters const auto HAND_CCN_DECREASE_FACTOR = 8.f; diff --git a/include/openpose/pose/poseParameters.hpp b/include/openpose/pose/poseParameters.hpp index 3b377b42..d81b0b69 100644 --- a/include/openpose/pose/poseParameters.hpp +++ b/include/openpose/pose/poseParameters.hpp @@ -42,6 +42,7 @@ namespace op const std::vector POSE_COCO_PAIRS_RENDER {POSE_COCO_PAIRS_RENDER_GPU}; const std::vector POSE_COCO_PAIRS {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0, 0,14, 14,16, 0,15, 15,17, 2,16, 5,17}; #define POSE_COCO_COLORS_RENDER \ + 255.f, 0.f, 85.f, \ 255.f, 0.f, 0.f, \ 255.f, 85.f, 0.f, \ 255.f, 170.f, 0.f, \ @@ -55,11 +56,10 @@ namespace op 0.f, 170.f, 255.f, \ 0.f, 85.f, 255.f, \ 0.f, 0.f, 255.f, \ - 85.f, 0.f, 255.f, \ + 255.f, 0.f, 170.f, \ 170.f, 0.f, 255.f, \ 255.f, 0.f, 255.f, \ - 255.f, 0.f, 170.f, \ - 255.f, 0.f, 85.f + 85.f, 0.f, 255.f // MPI const std::map POSE_MPI_BODY_PARTS{ {0, "Head"}, @@ -120,13 +120,17 @@ namespace op {15, "LEye"}, {16, "REar"}, {17, "LEar"}, + {18, "RTest1"}, + {19, "LTest1"}, + {20, "RTest2"}, + {21, "LTest2"}, {22, "Background"}, }; - const unsigned int POSE_BODY_22_NUMBER_PARTS = 2u; // Equivalent to size of std::map POSE_BODY_22_BODY_PARTS - 1 (removing background) - const std::vector POSE_BODY_22_MAP_IDX {35,36, 43,45}; - #define POSE_BODY_22_PAIRS_RENDER_GPU {1,2, 1,5} + const unsigned int POSE_BODY_22_NUMBER_PARTS = 22u; // Equivalent to size of std::map POSE_BODY_22_BODY_PARTS - 1 (removing background) + const std::vector POSE_BODY_22_MAP_IDX {35,36, 43,45, 37,38, 39,40, 45,46, 47,48, 23,24, 25,26, 27,28, 29,30, 31,32, 33,34, 51,52}; + #define POSE_BODY_22_PAIRS_RENDER_GPU {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12} const std::vector POSE_BODY_22_PAIRS_RENDER {POSE_BODY_22_PAIRS_RENDER_GPU}; - const std::vector POSE_BODY_22_PAIRS {1,2}; + const std::vector POSE_BODY_22_PAIRS {1,2, 1,5, 2,3, 3,4, 5,6, 6,7, 1,8, 8,9, 9,10, 1,11, 11,12, 12,13, 1,0}; #define POSE_BODY_22_COLORS_RENDER \ 255.f, 0.f, 0.f, \ 255.f, 85.f, 0.f, \ diff --git a/include/openpose/utilities/render.hu b/include/openpose/utilities/render.hu index 1d9af8a1..3990728d 100644 --- a/include/openpose/utilities/render.hu +++ b/include/openpose/utilities/render.hu @@ -103,7 +103,7 @@ namespace op const auto minV = 0.f; const auto maxV = 1.f; if (minV <= judge && judge <= maxV) - addColorWeighted(r, g, b, &rgbColorsPtr[(partPair%numberColors)*3], alphaColorToAdd); + addColorWeighted(r, g, b, &rgbColorsPtr[(partB%numberColors)*3], alphaColorToAdd); // Before used partPair vs partB } } diff --git a/src/openpose/pose/bodyPartConnectorBase.cpp b/src/openpose/pose/bodyPartConnectorBase.cpp index ed93d12c..83435d84 100644 --- a/src/openpose/pose/bodyPartConnectorBase.cpp +++ b/src/openpose/pose/bodyPartConnectorBase.cpp @@ -41,7 +41,7 @@ namespace op // Change w.r.t. other if (nB != 0) { - if (poseModel == PoseModel::COCO_18) + if (poseModel == PoseModel::COCO_18 || poseModel == PoseModel::BODY_22) { for (auto i = 1; i <= nB; i++) { @@ -82,7 +82,7 @@ namespace op } else if (nA != 0) { - if (poseModel == PoseModel::COCO_18) + if (poseModel == PoseModel::COCO_18 || poseModel == PoseModel::BODY_22) { for (auto i = 1; i <= nA; i++) { diff --git a/src/openpose/utilities/keypoint.cpp b/src/openpose/utilities/keypoint.cpp index cf15e9ef..3faffcc7 100644 --- a/src/openpose/utilities/keypoint.cpp +++ b/src/openpose/utilities/keypoint.cpp @@ -149,7 +149,8 @@ namespace op const auto index2 = (person * numberKeypoints + pairs[pair+1]) * keypoints.getSize(2); if (keypoints[index1+2] > threshold && keypoints[index2+2] > threshold) { - const auto colorIndex = pair/2*3; + // const auto colorIndex = pair/2*3; + const auto colorIndex = pairs[pair+1]*3; const cv::Scalar color{colors[colorIndex % numberColors], colors[(colorIndex+1) % numberColors], colors[(colorIndex+2) % numberColors]}; -- GitLab