提交 d7351940 编写于 作者: G gineshidalgo99

BODY_25 added

上级 d03a27b9
......@@ -53,6 +53,20 @@ Note: This example will assume that the target are 3 Flir/Point Grey cameras, bu
./build/examples/openpose/openpose.bin --num_gpu 0 --flir_camera --flir_camera_index 0 --frame_keep_distortion
# Without distortion (lines should look as lines)
./build/examples/openpose/openpose.bin --num_gpu 0 --flir_camera --flir_camera_index 0
```
7. Full example for 4 flir cameras:
```
# Get images for calibration
./build/examples/openpose/openpose.bin --num_gpu 0 --frame_keep_distortion --flir_camera --flir_camera_index 0 --write_images ~/Desktop/intrinsics_0
./build/examples/openpose/openpose.bin --num_gpu 0 --frame_keep_distortion --flir_camera --flir_camera_index 1 --write_images ~/Desktop/intrinsics_1
./build/examples/openpose/openpose.bin --num_gpu 0 --frame_keep_distortion --flir_camera --flir_camera_index 2 --write_images ~/Desktop/intrinsics_2
./build/examples/openpose/openpose.bin --num_gpu 0 --frame_keep_distortion --flir_camera --flir_camera_index 3 --write_images ~/Desktop/intrinsics_3
# Run calibration
# Note: If your computer has enough RAM memory, you can run all of them at the same time in order to speed up the time (they are not internally multi-threaded).
./build/examples/calibration/calibration.bin --mode 1 --grid_square_size_mm 127.0 --grid_number_inner_corners "9x6" --camera_serial_number 17012332 --intrinsics_image_dir ~/Desktop/intrinsics_0
./build/examples/calibration/calibration.bin --mode 1 --grid_square_size_mm 127.0 --grid_number_inner_corners "9x6" --camera_serial_number 17092861 --intrinsics_image_dir ~/Desktop/intrinsics_1
./build/examples/calibration/calibration.bin --mode 1 --grid_square_size_mm 127.0 --grid_number_inner_corners "9x6" --camera_serial_number 17092865 --intrinsics_image_dir ~/Desktop/intrinsics_2
./build/examples/calibration/calibration.bin --mode 1 --grid_square_size_mm 127.0 --grid_number_inner_corners "9x6" --camera_serial_number 18079957 --intrinsics_image_dir ~/Desktop/intrinsics_3
```
2. Extrinsic parameter calibration:
......
......@@ -18,6 +18,7 @@ namespace op
BODY_59, /**< Experimental. Do not use. */
BODY_19N, /**< Experimental. Do not use. */
BODY_19b, /**< Experimental. Do not use. */
BODY_25, /**< Experimental. Do not use. */
Size,
};
......
......@@ -132,6 +132,36 @@ namespace op
238.f, 130.f, 238.f, \
138.f, 43.f, 226.f, \
75.f, 0.f, 130.f
// BODY_25
#define POSE_BODY_25_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, 14,19,19,20,14,21, 11,22,22,23,11,24
#define POSE_BODY_25_SCALES_RENDER_GPU 1
#define POSE_BODY_25_COLORS_RENDER_GPU \
255.f, 0.f, 85.f, \
255.f, 0.f, 0.f, \
255.f, 85.f, 0.f, \
255.f, 170.f, 0.f, \
255.f, 255.f, 0.f, \
170.f, 255.f, 0.f, \
85.f, 255.f, 0.f, \
0.f, 255.f, 0.f, \
255.f, 0.f, 0.f, \
0.f, 255.f, 85.f, \
0.f, 255.f, 170.f, \
0.f, 255.f, 255.f, \
0.f, 170.f, 255.f, \
0.f, 85.f, 255.f, \
0.f, 0.f, 255.f, \
255.f, 0.f, 170.f, \
170.f, 0.f, 255.f, \
255.f, 0.f, 255.f, \
85.f, 0.f, 255.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_59
// Body + left hand + right hand
#define POSE_BODY_59_PAIRS_RENDER_GPU \
......
......@@ -17,7 +17,11 @@ namespace op
const auto& bodyPartPairs = getPosePartPairs(poseModel);
const auto& mapIdx = getPoseMapIndex(poseModel);
const auto numberBodyParts = getPoseNumberBodyParts(poseModel);
const auto numberBodyPartsAndBkg = numberBodyParts + 1;
const auto numberBodyPartPairs = bodyPartPairs.size() / 2;
if (numberBodyParts == 0)
error("Invalid value of numberBodyParts, it must be positive, not " + std::to_string(numberBodyParts),
__LINE__, __FUNCTION__, __FILE__);
// Vector<int> = Each body part + body parts counter; double = subsetScore
std::vector<std::pair<std::vector<int>, double>> subset;
......@@ -134,8 +138,8 @@ namespace op
else // if (numberA != 0 && numberB != 0)
{
std::vector<std::tuple<double, int, int>> temp;
const auto* mapX = heatMapPtr + mapIdx[2*pairIndex] * heatMapOffset;
const auto* mapY = heatMapPtr + mapIdx[2*pairIndex+1] * heatMapOffset;
const auto* mapX = heatMapPtr + (numberBodyPartsAndBkg + mapIdx[2*pairIndex]) * heatMapOffset;
const auto* mapY = heatMapPtr + (numberBodyPartsAndBkg + mapIdx[2*pairIndex+1]) * heatMapOffset;
for (auto i = 1; i <= numberA; i++)
{
for (auto j = 1; j <= numberB; j++)
......@@ -230,7 +234,7 @@ namespace op
// Add ears connections (in case person is looking to opposite direction to camera)
else if (
(numberBodyParts == 18 && (pairIndex==17 || pairIndex==18))
|| ((numberBodyParts == 19 || numberBodyParts == 59)
|| ((numberBodyParts == 19 || numberBodyParts == 25 || numberBodyParts == 59)
&& (pairIndex==18 || pairIndex==19))
|| (numberBodyParts == 23 && (pairIndex==22 || pairIndex==23))
|| (poseModel == PoseModel::BODY_19b
......
......@@ -19,7 +19,11 @@ namespace op
const auto& bodyPartPairs = getPosePartPairs(poseModel);
const auto& mapIdx = getPoseMapIndex(poseModel);
const auto numberBodyParts = getPoseNumberBodyParts(poseModel);
const auto numberBodyPartsAndBkg = numberBodyParts + 1;
const auto numberBodyPartPairs = bodyPartPairs.size() / 2;
if (numberBodyParts == 0)
error("Invalid value of numberBodyParts, it must be positive, not " + std::to_string(numberBodyParts),
__LINE__, __FUNCTION__, __FILE__);
// Vector<int> = Each body part + body parts counter; double = subsetScore
std::vector<std::pair<std::vector<int>, double>> subset;
......@@ -136,8 +140,8 @@ namespace op
else // if (numberA != 0 && numberB != 0)
{
std::vector<std::tuple<double, int, int>> temp;
const auto* mapX = heatMapPtr + mapIdx[2*pairIndex] * heatMapOffset;
const auto* mapY = heatMapPtr + mapIdx[2*pairIndex+1] * heatMapOffset;
const auto* mapX = heatMapPtr + (numberBodyPartsAndBkg + mapIdx[2*pairIndex]) * heatMapOffset;
const auto* mapY = heatMapPtr + (numberBodyPartsAndBkg + mapIdx[2*pairIndex+1]) * heatMapOffset;
for (auto i = 1; i <= numberA; i++)
{
for (auto j = 1; j <= numberB; j++)
......@@ -232,7 +236,7 @@ namespace op
// Add ears connections (in case person is looking to opposite direction to camera)
else if (
(numberBodyParts == 18 && (pairIndex==17 || pairIndex==18))
|| ((numberBodyParts == 19 || numberBodyParts == 59)
|| ((numberBodyParts == 19 || numberBodyParts == 25 || numberBodyParts == 59)
&& (pairIndex==18 || pairIndex==19))
|| (numberBodyParts == 23 && (pairIndex==22 || pairIndex==23))
|| (poseModel == PoseModel::BODY_19b
......
......@@ -139,7 +139,7 @@ namespace op
else
{
const auto affinityPart = (elementRendered-numberBodyPartsPlusBkg-3)*2;
const auto affinityPartMapped = getPoseMapIndex(mPoseModel).at(affinityPart);
const auto affinityPartMapped = numberBodyPartsPlusBkg+getPoseMapIndex(mPoseModel).at(affinityPart);
elementRenderedName = mPartIndexToName.at(affinityPartMapped);
elementRenderedName = elementRenderedName.substr(0, elementRenderedName.find("("));
renderPosePAFGpu(*spGpuMemory, mPoseModel, frameSize,
......
......@@ -91,6 +91,34 @@ namespace op
{22, "LEar"},
{23, "Background"}
};
const std::map<unsigned int, std::string> POSE_BODY_25_BODY_PARTS {
{0, "Nose"},
{1, "Neck"},
{2, "RShoulder"},
{3, "RElbow"},
{4, "RWrist"},
{5, "LShoulder"},
{6, "LElbow"},
{7, "LWrist"},
{8, "LowerAbs"},
{9, "RHip"},
{10, "RKnee"},
{11, "RAnkle"},
{12, "LHip"},
{13, "LKnee"},
{14, "LAnkle"},
{15, "REye"},
{16, "LEye"},
{17, "REar"},
{18, "LEar"},
{19, "LBigToe"},
{20, "LSmallToe"},
{21, "LHeel"},
{22, "RBigToe"},
{23, "RSmallToe"},
{24, "RHeel"},
{25, "Background"}
};
const std::map<unsigned int, std::string> POSE_BODY_59_BODY_PARTS {
// Body
{0, "Nose"},
......@@ -141,54 +169,58 @@ namespace op
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_MAP_INDEX{
// COCO
std::vector<unsigned int>{
31,32, 39,40, 33,34, 35,36, 41,42, 43,44, 19,20, 21,22, 23,24, 25,26, 27,28, 29,30, 47,48, 49,50, 53,54, 51,52, 55,56, 37,38, 45,46
12,13, 20,21, 14,15, 16,17, 22,23, 24,25, 0,1, 2,3, 4,5, 6,7, 8,9, 10,11, 28,29, 30,31, 34,35, 32,33, 36,37, 18,19, 26,27
},
// MPI_15
std::vector<unsigned int>{
16,17, 18,19, 20,21, 22,23, 24,25, 26,27, 28,29, 30,31, 32,33, 34,35, 36,37, 38,39, 40,41, 42,43
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
},
// MPI_15_4
std::vector<unsigned int>{
16,17, 18,19, 20,21, 22,23, 24,25, 26,27, 28,29, 30,31, 32,33, 34,35, 36,37, 38,39, 40,41, 42,43
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
},
// BODY_18
std::vector<unsigned int>{
31,32, 39,40, 33,34, 35,36, 41,42, 43,44, 19,20, 21,22, 23,24, 25,26, 27,28, 29,30, 47,48, 49,50, 53,54, 51,52, 55,56, 37,38, 45,46
12,13, 20,21, 14,15, 16,17, 22,23, 24,25, 0,1, 2,3, 4,5, 6,7, 8,9, 10,11, 28,29, 30,31, 34,35, 32,33, 36,37, 18,19, 26,27
},
// BODY_19
std::vector<unsigned int>{
20,21, 34,35, 42,43, 36,37, 38,39, 44,45, 46,47, 26,27, 22,23, 24,25, 28,29, 30,31, 32,33, 50,51, 52,53, 56,57, 54,55, 58,59, 40,41, 48,49
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_19_X2
std::vector<unsigned int>{
20,21, 34,35, 42,43, 36,37, 38,39, 44,45, 46,47, 26,27, 22,23, 24,25, 28,29, 30,31, 32,33, 50,51, 52,53, 56,57, 54,55, 58,59, 40,41, 48,49
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_23
std::vector<unsigned int>{
24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71
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, 32,33, 34,35, 36,37, 38,39, 40,41, 42,43, 44,45, 46,47
},
// BODY_59
std::vector<unsigned int>{
60,61, 74,75, 82,83, 76,77, 78,79, 84,85, 86,87, 66,67, 62,63, 64,65, 68,69, 70,71, 72,73, 90,91, 92,93, 96,97, 94,95, 98,99, 80,81, 88,89, // Body
100,101, 102,103, 104,105, 106,107, 108,109, 110,111, 112,113, 114,115, 116,117, 118,119,
120,121, 122,123, 124,125, 126,127, 128,129, 130,131, 132,133, 134,135, 136,137, 138,139,// Left hand
140,141, 142,143, 144,145, 146,147, 148,149, 150,151, 152,153, 154,155, 156,157, 158,159,
160,161, 162,163, 164,165, 166,167, 168,169, 170,171, 172,173, 174,175, 176,177, 178,179 // Right hand
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, 160,161, 162,163, 164,165, 166,167, 168,169 // Right hand
},
// BODY_19N
std::vector<unsigned int>{
20,21, 34,35, 42,43, 36,37, 38,39, 44,45, 46,47, 26,27, 22,23, 24,25, 28,29, 30,31, 32,33, 50,51, 52,53, 56,57, 54,55, 58,59, 40,41, 48,49
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_19b
std::vector<unsigned int>{
20,21, 34,35, 42,43, 36,37, 38,39, 44,45, 46,47, 26,27, 22,23, 24,25, 28,29, 30,31, 32,33, 50,51, 52,53, 56,57, 54,55, 58,59, 40,41, 48,49, 60,61, 62,63
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, 60,61, 62,63
},
// BODY_25
std::vector<unsigned int>{
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
},
};
// POSE_BODY_PART_MAPPING on HPP crashes on Windows at dynamic initialization if it's on hpp
const std::array<std::map<unsigned int, std::string>, (int)PoseModel::Size> POSE_BODY_PART_MAPPING{
const std::array<std::map<unsigned int, std::string>, (int)PoseModel::Size> POSE_BODY_PART_MAPPING{
POSE_COCO_BODY_PARTS, POSE_MPI_BODY_PARTS, POSE_MPI_BODY_PARTS, POSE_COCO_BODY_PARTS,
POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_23_BODY_PARTS,POSE_BODY_59_BODY_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
};
const std::array<std::string, (int)PoseModel::Size> POSE_PROTOTXT{
......@@ -196,30 +228,32 @@ namespace op
"pose/mpi/pose_deploy_linevec.prototxt",
"pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt",
"pose/body_18/pose_deploy.prototxt",
"pose/body_19/pose_deploy.prototxt",
"pose/body_19_25/pose_deploy_19.prototxt",
"pose/body_19_x2/pose_deploy.prototxt",
"pose/body_23/pose_deploy.prototxt",
"pose/body_59/pose_deploy.prototxt",
"pose/body_19n/pose_deploy.prototxt",
"pose/body_19b/pose_deploy.prototxt",
"pose/body_19_25/pose_deploy_25.prototxt",
};
const std::array<std::string, (int)PoseModel::Size> POSE_TRAINED_MODEL{
"pose/coco/pose_iter_440000.caffemodel",
"pose/mpi/pose_iter_160000.caffemodel",
"pose/mpi/pose_iter_160000.caffemodel",
"pose/body_18/pose_iter_XXXXXX.caffemodel",
"pose/body_19/pose_iter_XXXXXX.caffemodel",
"pose/body_19_25/pose_iter_XXXXXX.caffemodel",
"pose/body_19_x2/pose_iter_XXXXXX.caffemodel",
"pose/body_23/pose_iter_XXXXXX.caffemodel",
"pose/body_59/pose_iter_XXXXXX.caffemodel",
"pose/body_19n/pose_iter_XXXXXX.caffemodel",
"pose/body_19b/pose_iter_XXXXXX.caffemodel",
"pose/body_19_25/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<unsigned int, (int)PoseModel::Size> POSE_NUMBER_BODY_PARTS{
18, 15, 15, 18, 19, 19, 23, 59, 19, 19
18, 15, 15, 18, 19, 19, 23, 59, 19, 19, 25
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_BODY_PART_PAIRS{
// COCO
......@@ -260,6 +294,10 @@ namespace op
std::vector<unsigned int>{
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, 2,9, 5,12
},
// BODY_25
std::vector<unsigned int>{
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
},
};
const std::array<unsigned int, (int)PoseModel::Size> POSE_MAX_PEAKS{
POSE_MAX_PEOPLE, // COCO
......@@ -272,6 +310,7 @@ namespace op
POSE_MAX_PEOPLE, // BODY_59
POSE_MAX_PEOPLE, // BODY_19N
POSE_MAX_PEOPLE, // BODY_19b
POSE_MAX_PEOPLE, // BODY_25
};
const std::array<float, (int)PoseModel::Size> POSE_CCN_DECREASE_FACTOR{
8.f, // COCO
......@@ -284,25 +323,26 @@ namespace op
8.f, // BODY_59
8.f, // BODY_19N
8.f, // BODY_19b
8.f, // BODY_25
};
// Default Model Parameters
// They might be modified on running time
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_NMS_THRESHOLD{
0.05f, 0.6f, 0.3f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f
0.05f, 0.6f, 0.3f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f
};
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_INTER_MIN_ABOVE_THRESHOLD{
0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f
0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f, 0.95f
// 0.85f, 0.85f, 0.85f, 0.85f, 0.85f, 0.85f // Matlab version
};
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_INTER_THRESHOLD{
0.05f, 0.01f, 0.01f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f
0.05f, 0.01f, 0.01f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f
};
const std::array<unsigned int, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_MIN_SUBSET_CNT{
3, 3, 3, 3, 3, 3, 3, 3, 3, 3
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
};
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_MIN_SUBSET_SCORE{
0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f
0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f
// 0.2f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f // Matlab version
};
......@@ -415,8 +455,8 @@ namespace op
try
{
const auto& poseBodyPartMapping = POSE_BODY_PART_MAPPING[(int)poseModel];
for (auto& string : strings)
for (auto& pair : poseBodyPartMapping)
for (const auto& string : strings)
for (const auto& pair : poseBodyPartMapping)
if (pair.second == string)
return pair.first;
error("String(s) could not be found.", __LINE__, __FUNCTION__, __FILE__);
......
......@@ -14,6 +14,7 @@ namespace op
std::vector<float>{POSE_BODY_59_SCALES_RENDER_GPU}, // BODY_59
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19N
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19b
std::vector<float>{POSE_BODY_25_SCALES_RENDER_GPU}, // BODY_25
};
const std::array<std::vector<float>, (int)PoseModel::Size> POSE_COLORS{
std::vector<float>{POSE_COCO_COLORS_RENDER_GPU}, // COCO
......@@ -26,6 +27,7 @@ namespace op
std::vector<float>{POSE_BODY_59_COLORS_RENDER_GPU}, // BODY_59
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19N
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19b
std::vector<float>{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_BODY_PART_PAIRS_RENDER{
std::vector<unsigned int>{POSE_COCO_PAIRS_RENDER_GPU}, // COCO
......@@ -38,6 +40,7 @@ namespace op
std::vector<unsigned int>{POSE_BODY_59_PAIRS_RENDER_GPU}, // BODY_59
std::vector<unsigned int>{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19N
std::vector<unsigned int>{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19b
std::vector<unsigned int>{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25
};
// Rendering functions
......
......@@ -9,18 +9,17 @@ namespace op
{
try
{
// POSE_BODY_PART_MAPPING crashes on Windows, replaced by getPoseBodyPartMapping
// auto partToName = POSE_BODY_PART_MAPPING[(int)poseModel];
auto partToName = getPoseBodyPartMapping(poseModel);
const auto& bodyPartPairs = getPosePartPairs(poseModel);
const auto& mapIdx = getPoseMapIndex(poseModel);
const auto numberBodyPartsPlusBkg = getPoseNumberBodyParts(poseModel)+1;
for (auto bodyPart = 0u; bodyPart < bodyPartPairs.size(); bodyPart+=2)
{
const auto bodyPartPairsA = bodyPartPairs.at(bodyPart);
const auto bodyPartPairsB = bodyPartPairs.at(bodyPart+1);
const auto mapIdxA = mapIdx.at(bodyPart);
const auto mapIdxB = mapIdx.at(bodyPart+1);
const auto mapIdxA = numberBodyPartsPlusBkg + mapIdx.at(bodyPart);
const auto mapIdxB = numberBodyPartsPlusBkg + mapIdx.at(bodyPart+1);
partToName[mapIdxA] = partToName.at(bodyPartPairsA) + "->" + partToName.at(bodyPartPairsB) + "(X)";
partToName[mapIdxB] = partToName.at(bodyPartPairsA) + "->" + partToName.at(bodyPartPairsB) + "(Y)";
}
......
......@@ -13,6 +13,7 @@ namespace op
__constant__ const unsigned int BODY_19_PAIRS_GPU[] = {POSE_BODY_19_PAIRS_RENDER_GPU};
__constant__ const unsigned int BODY_19b_PAIRS_GPU[] = {POSE_BODY_19b_PAIRS_RENDER_GPU};
__constant__ const unsigned int BODY_23_PAIRS_GPU[] = {POSE_BODY_23_PAIRS_RENDER_GPU};
__constant__ const unsigned int BODY_25_PAIRS_GPU[] = {POSE_BODY_25_PAIRS_RENDER_GPU};
__constant__ const unsigned int BODY_59_PAIRS_GPU[] = {POSE_BODY_59_PAIRS_RENDER_GPU};
__constant__ const unsigned int MPI_PAIRS_GPU[] = {POSE_MPI_PAIRS_RENDER_GPU};
// Keypoint scales
......@@ -20,6 +21,7 @@ namespace op
__constant__ const float BODY_19_SCALES[] = {POSE_BODY_19_SCALES_RENDER_GPU};
__constant__ const float BODY_19b_SCALES[] = {POSE_BODY_19b_SCALES_RENDER_GPU};
__constant__ const float BODY_23_SCALES[] = {POSE_BODY_23_SCALES_RENDER_GPU};
__constant__ const float BODY_25_SCALES[] = {POSE_BODY_25_SCALES_RENDER_GPU};
__constant__ const float BODY_59_SCALES[] = {POSE_BODY_59_SCALES_RENDER_GPU};
__constant__ const float MPI_SCALES[] = {POSE_MPI_SCALES_RENDER_GPU};
// RGB colors
......@@ -27,6 +29,7 @@ namespace op
__constant__ const float BODY_19_COLORS[] = {POSE_BODY_19_COLORS_RENDER_GPU};
__constant__ const float BODY_19b_COLORS[] = {POSE_BODY_19b_COLORS_RENDER_GPU};
__constant__ const float BODY_23_COLORS[] = {POSE_BODY_23_COLORS_RENDER_GPU};
__constant__ const float BODY_25_COLORS[] = {POSE_BODY_25_COLORS_RENDER_GPU};
__constant__ const float BODY_59_COLORS[] = {POSE_BODY_59_COLORS_RENDER_GPU};
__constant__ const float MPI_COLORS[] = {POSE_MPI_COLORS_RENDER_GPU};
......@@ -217,6 +220,33 @@ namespace op
blendOriginalFrame, (googlyEyes ? 19 : -1), (googlyEyes ? 21 : -1));
}
__global__ void renderPoseBody25(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;
const auto globalIdx = threadIdx.y * blockDim.x + threadIdx.x;
// Shared parameters
__shared__ float2 sharedMins[POSE_MAX_PEOPLE];
__shared__ float2 sharedMaxs[POSE_MAX_PEOPLE];
__shared__ float sharedScaleF[POSE_MAX_PEOPLE];
// Other parameters
const auto numberPartPairs = sizeof(BODY_25_PAIRS_GPU) / (2*sizeof(BODY_25_PAIRS_GPU[0]));
const auto numberScales = sizeof(BODY_25_SCALES) / sizeof(BODY_25_SCALES[0]);
const auto numberColors = sizeof(BODY_25_COLORS) / (3*sizeof(BODY_25_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_25_PAIRS_GPU, numberPeople, 25, numberPartPairs, BODY_25_COLORS, numberColors,
radius, lineWidth, BODY_25_SCALES, numberScales, threshold, alphaColorToAdd,
blendOriginalFrame, (googlyEyes ? 19 : -1), (googlyEyes ? 21 : -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)
......@@ -466,6 +496,11 @@ namespace op
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
);
else if (poseModel == PoseModel::BODY_25)
renderPoseBody25<<<threadsPerBlock, numBlocks>>>(
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
);
else if (poseModel == PoseModel::BODY_59)
renderPoseBody59<<<threadsPerBlock, numBlocks>>>(
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
......
......@@ -32,6 +32,8 @@ namespace op
return PoseModel::BODY_19_X2;
else if (poseModeString == "BODY_23")
return PoseModel::BODY_23;
else if (poseModeString == "BODY_25")
return PoseModel::BODY_25;
else if (poseModeString == "BODY_59")
return PoseModel::BODY_59;
// else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册