提交 1222eb89 编写于 作者: G gineshidalgo99

Removed BODY_23, *.sh scripts for BODY_25

上级 787f4ef9
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
# USAGE EXAMPLE
# clear && clear && make all -j`nproc` && bash ./examples/tests/pose_accuracy_coco_test.sh
# # Go back to main folder
# cd ../../
# Write COCO-format JSON
# Last id:
# ID 20671 <--> #frames = 1471 --> ~ 1.5 min at 15fps
# ID 50006 <--> #frames = 3559 --> ~ 4 min at 15fps
# Parameters
IMAGE_FOLDER=/mnt/DataUbuntu/openpose_train/dataset/COCO/car_dataset/Dataset/images_jpg_val/
JSON_FOLDER=../evaluation/coco_val_jsons/
OP_BIN=./build/examples/openpose/openpose.bin
# 1 scale
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}car_1.json --display 0 --render_pose 0 --model_pose CAR_12
# # 4 scales
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --model_pose CAR_12 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --model_pose CAR_12 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 1005
# # Debugging - Rendered frames saved
# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --display 0
......@@ -6,12 +6,12 @@ clear && clear
# See ./examples/tests/pose_accuracy_coco_test.sh
# Parameters
IMAGE_FOLDER=/media/posefs3b/Users/gines/openpose_train/dataset/COCO/images/test2017_dev/
IMAGE_FOLDER=/media/posefs3b/Users/gines/openpose_train/dataset/COCO/cocoapi/images/test2017_dev/
JSON_FOLDER=../evaluation/coco_val_jsons/
OP_BIN=./build/examples/openpose/openpose.bin
# 1 scale
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_test.json --display 0 --render_pose 0
# # 1 scale
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_test.json --display 0 --render_pose 0
# 4 scales
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_test.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"
......@@ -29,7 +29,7 @@ $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --displ
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_3.json --display 0 --render_pose 0 --scale_number 3 --scale_gap 0.25
# # 4 scales
# $OP_BIN --num_gpu 1 --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"
# # Debugging - Rendered frames saved
# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --display 0
......@@ -11,7 +11,7 @@ JSON_FOLDER=../evaluation/coco_val_jsons/
OP_BIN=./build/examples/openpose/openpose.bin
# 1 scale
$OP_BIN --model_pose BODY_25 --image_dir $IMAGE_FOLDER --write_coco_foot_json ${JSON_FOLDER}1_foot.json --display 0 --render_pose 0
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_foot_json ${JSON_FOLDER}1_foot.json --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0
# # 4 scales
# $OP_BIN --model_pose BODY_25 --image_dir $IMAGE_FOLDER --write_coco_foot_json ${JSON_FOLDER}1_4_foot.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736"
......@@ -17,12 +17,12 @@ 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_23, /**< Experimental. Do not use. */
BODY_59, /**< Experimental. Do not use. */
BODY_19N, /**< Experimental. Do not use. */
BODY_19b, /**< Experimental. Do not use. */
BODY_25_19, /**< Experimental. Do not use. */
BODY_65, /**< Experimental. Do not use. */
CAR_12, /**< Experimental. Do not use. */
Size,
};
......
......@@ -134,34 +134,6 @@ namespace op
170.f, 0.f, 255.f, \
255.f, 0.f, 255.f, \
85.f, 0.f, 255.f
// BODY_23
#define POSE_BODY_23_PAIRS_RENDER_GPU \
0,1, 0,4, 1,2, 2,3, 4,5, 5,6, 0,7, 7,8, 7,13, 8,9, 9,10,10,11,11,12,13,14,14,15,15,16,16,17, 0,18,18,19,18,21,19,20,21,22
#define POSE_BODY_23_SCALES_RENDER_GPU 1
#define POSE_BODY_23_COLORS_RENDER_GPU \
255.f, 0.f, 0.f, \
255.f, 55.f, 0.f, \
255.f, 110.f, 0.f, \
255.f, 165.f, 0.f, \
255.f, 215.f, 0.f, \
255.f, 235.f, 0.f, \
255.f, 255.f, 0.f, \
255.f, 0.f, 0.f, \
175.f, 255.f, 0.f, \
85.f, 255.f, 0.f, \
0.f, 255.f, 0.f, \
0.f, 255.f, 85.f, \
0.f, 255.f, 170.f, \
25.f, 25.f, 128.f, \
0.f, 85.f, 255.f, \
0.f, 170.f, 255.f, \
0.f, 212.5f, 255.f, \
0.f, 255.f, 255.f, \
255.f, 0.f, 0.f, \
255.f, 0.f, 255.f, \
238.f, 130.f, 238.f, \
138.f, 43.f, 226.f, \
75.f, 0.f, 130.f
// BODY_59
// Body + left hand + right hand
#define POSE_BODY_59_PAIRS_RENDER_GPU \
......@@ -312,7 +284,6 @@ namespace op
0.f, 191.f, 191.f, \
0.f, 127.f, 127.f, \
0.f, 63.f, 63.f
// Hand color selection
// http://www.perbang.dk/rgbgradient/
// 1. Main color
......@@ -324,6 +295,27 @@ namespace op
// - Inside each finger: 5 steps from main color to 000000, and selecting first 4 from RGB gradient.
// Note: Used HSV gradient for red finger.
// CAR_12
#define POSE_CAR_12_PAIRS_RENDER_GPU \
4,5, 4,6, 4,0, 0,2, 4,8, 8,10, 5,7, 5,1, 1,3, 5,9, 9,11, 2,3, 6,7, 10,11, 6,2,7,3, 6,10,7,11
// 4,5, 4,6, 4,0, 0,2, 4,8, 8,10, 5,7, 5,1, 1,3, 5,9, 9,11
#define POSE_CAR_12_SCALES_RENDER_GPU 1
#define POSE_CAR_12_COLORS_RENDER_GPU \
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, 0.f, 0.f, \
255.f, 0.f, 0.f, \
255.f, 75.f, 75.f, \
255.f, 75.f, 75.f, \
\
0.f, 0.f, 255.f, \
0.f, 0.f, 255.f, \
255.f, 0.f, 255.f, \
255.f, 0.f, 255.f
// Rendering functions
OP_API const std::vector<float>& getPoseScales(const PoseModel poseModel);
OP_API const std::vector<float>& getPoseColors(const PoseModel poseModel);
......
......@@ -45,7 +45,7 @@ namespace op
error("Dimension mismatch between poseKeypoints and poseScores.", __LINE__, __FUNCTION__, __FILE__);
const auto numberPeople = poseKeypoints.getSize(0);
const auto numberBodyParts = poseKeypoints.getSize(1);
const auto imageId = getLastNumber(imageName);
const auto imageId = (numberBodyParts != 12 ? getLastNumber(imageName) : 1900000 + getLastNumber(imageName));
for (auto person = 0 ; person < numberPeople ; person++)
{
// Comma at any moment but first element
......@@ -74,15 +74,21 @@ namespace op
mJsonOfstream.key("keypoints");
mJsonOfstream.arrayOpen();
std::vector<int> indexesInCocoOrder;
// Body/car
if (mCocoJsonFormat == CocoJsonFormat::Body)
{
// Body
if (numberBodyParts == 18)
indexesInCocoOrder = std::vector<int>{0, 15,14,17,16, 5,2,6,3,7, 4,11,8,12, 9, 13,10};
else if (numberBodyParts == 19 || numberBodyParts == 25 || numberBodyParts == 59)
indexesInCocoOrder = std::vector<int>{0, 16,15,18,17, 5,2,6,3,7, 4,12,9,13,10, 14,11};
else if (numberBodyParts == 23)
indexesInCocoOrder = std::vector<int>{18,21,19,22,20, 4,1,5,2,6, 3,13,8,14, 9, 15,10};
// Car
else if (numberBodyParts == 12)
indexesInCocoOrder = std::vector<int>{0,1,2,3, 4,5,6,7, 8, 8,9,10,11, 11};
}
// Foot
else if (mCocoJsonFormat == CocoJsonFormat::Foot)
if (numberBodyParts == 25)
indexesInCocoOrder = std::vector<int>{19,20,21, 22,23,24};
......
......@@ -237,7 +237,6 @@ namespace op
|| ((numberBodyParts == 19 || numberBodyParts == 25 || numberBodyParts == 59
|| numberBodyParts == 65)
&& (pairIndex==18 || pairIndex==19))
|| (numberBodyParts == 23 && (pairIndex==22 || pairIndex==23))
|| (poseModel == PoseModel::BODY_19b
&& (pairIndex == numberBodyPartPairs-1 || pairIndex == numberBodyPartPairs-2))
)
......
......@@ -239,7 +239,6 @@ namespace op
|| ((numberBodyParts == 19 || numberBodyParts == 25 || numberBodyParts == 59
|| numberBodyParts == 65)
&& (pairIndex==18 || pairIndex==19))
|| (numberBodyParts == 23 && (pairIndex==22 || pairIndex==23))
|| (poseModel == PoseModel::BODY_19b
&& (pairIndex == numberBodyPartPairs-1 || pairIndex == numberBodyPartPairs-2))
)
......
......@@ -93,32 +93,6 @@ namespace op
{18, "LEar"},
{19, "Background"}
};
const std::map<unsigned int, std::string> POSE_BODY_23_BODY_PARTS {
{0, "Neck"},
{1, "RShoulder"},
{2, "RElbow"},
{3, "RWrist"},
{4, "LShoulder"},
{5, "LElbow"},
{6, "LWrist"},
{7, "MidHip"},
{8, "RHip"},
{9, "RKnee"},
{10, "RAnkle"},
{11, "RBigToe"},
{12, "RSmallToe"},
{13, "LHip"},
{14, "LKnee"},
{15, "LAnkle"},
{16, "LBigToe"},
{17, "LSmallToe"},
{18, "Nose"},
{19, "REye"},
{20, "REar"},
{21, "LEye"},
{22, "LEar"},
{23, "Background"}
};
const std::map<unsigned int, std::string> POSE_BODY_59_BODY_PARTS {
// Body
{0, "Nose"},
......@@ -208,6 +182,21 @@ namespace op
// - All fingers:
// - Fingertips
// More information: Page 6 of http://www.mccc.edu/~behrensb/documents/TheHandbig.pdf
const std::map<unsigned int, std::string> POSE_CAR_12_PARTS {
{0, "FRWheel"},
{1, "FLWheel"},
{2, "BRWheel"},
{3, "BLWheel"},
{4, "FRLight"},
{5, "FLLight"},
{6, "BRLight"},
{7, "BLLight"},
{8, "FRTop"},
{9, "FLTop"},
{10, "BRTop"},
{11, "BLTop"},
{12, "Background"},
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_MAP_INDEX{
// BODY_25
std::vector<unsigned int>{
......@@ -233,10 +222,6 @@ namespace op
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
},
// BODY_23
std::vector<unsigned int>{
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>{
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
......@@ -265,12 +250,16 @@ namespace op
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, 120,121, 122,123, 124,125, 126,127, 128,129, 130,131 // Right hand
},
// CAR_12
std::vector<unsigned int>{
0,1, 2,3, 4,5, 6,7, 8,9, 10,11, 12,13, 14,15, 16,17, 18,19, 20,21
},
};
// 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{
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_23_BODY_PARTS,POSE_BODY_59_BODY_PARTS,
POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_25_BODY_PARTS,POSE_BODY_65_BODY_PARTS
POSE_BODY_19_BODY_PARTS,POSE_BODY_19_BODY_PARTS,POSE_BODY_59_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
};
const std::array<std::string, (int)PoseModel::Size> POSE_PROTOTXT{
......@@ -280,12 +269,12 @@ 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_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",
"pose/body_65/pose_deploy.prototxt",
"car/car_12/pose_deploy.prototxt",
};
const std::array<std::string, (int)PoseModel::Size> POSE_TRAINED_MODEL{
"pose/body_25/pose_iter_584000.caffemodel",
......@@ -294,18 +283,18 @@ 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_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",
"pose/body_65/pose_iter_XXXXXX.caffemodel",
"car/car_12/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{
25, 18, 15, 15, 19, 19, 23, 59, 19, 19, 25, 65
25, 18, 15, 15, 19, 19, 59, 19, 19, 25, 65, 12
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_BODY_PART_PAIRS{
// BODY_25
......@@ -328,10 +317,6 @@ 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
},
// BODY_23
std::vector<unsigned int>{
0,1, 0,4, 1,2, 2,3, 4,5, 5,6, 0,7, 7,8, 7,13, 8,9, 9,10,10,11,10,12,13,14,14,15,15,16,15,17, 0,18,18,19,18,21,19,20,21,22, 1,20, 4,22
},
// BODY_59
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,// Body
......@@ -356,6 +341,10 @@ namespace op
7,25, 25,26, 26,27, 27,28, 7,29, 29,30, 30,31, 31,32, 7,33, 33,34, 34,35, 35,36, 7,37, 37,38, 38,39, 39,40, 7,41, 41,42, 42,43, 43,44, // Left hand
4,45, 45,46, 46,47, 47,48, 4,49, 49,50, 50,51, 51,52, 4,53, 53,54, 54,55, 55,56, 4,57, 57,58, 58,59, 59,60, 4,61, 61,62, 62,63, 63,64 // Right hand
},
// CAR_12
std::vector<unsigned int>{
4,5, 4,6, 4,0, 0,2, 4,8, 8,10, 5,7, 5,1, 1,3, 5,9, 9,11
},
};
const std::array<unsigned int, (int)PoseModel::Size> POSE_MAX_PEAKS{
POSE_MAX_PEOPLE, // BODY_25
......@@ -364,12 +353,12 @@ namespace op
POSE_MAX_PEOPLE, // MPI_15_4
POSE_MAX_PEOPLE, // BODY_19
POSE_MAX_PEOPLE, // BODY_19_X2
POSE_MAX_PEOPLE, // BODY_23
POSE_MAX_PEOPLE, // BODY_59
POSE_MAX_PEOPLE, // BODY_19N
POSE_MAX_PEOPLE, // BODY_19b
POSE_MAX_PEOPLE, // BODY_25_19
POSE_MAX_PEOPLE, // BODY_65
POSE_MAX_PEOPLE, // CAR_12
};
const std::array<float, (int)PoseModel::Size> POSE_CCN_DECREASE_FACTOR{
8.f, // BODY_25
......@@ -378,12 +367,12 @@ namespace op
8.f, // MPI_15_4
8.f, // BODY_19
4.f, // BODY_19_X2
8.f, // BODY_23
8.f, // BODY_59
8.f, // BODY_19N
8.f, // BODY_19b
8.f, // BODY_25_19
8.f, // BODY_65
8.f, // CAR_12
};
// Default Model Parameters
......
......@@ -10,12 +10,12 @@ namespace op
std::vector<float>{POSE_MPI_SCALES_RENDER_GPU}, // MPI_15_4
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU}, // BODY_19_X2
std::vector<float>{POSE_BODY_23_SCALES_RENDER_GPU}, // BODY_23
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_19
std::vector<float>{POSE_BODY_65_SCALES_RENDER_GPU}, // BODY_65
std::vector<float>{POSE_CAR_12_SCALES_RENDER_GPU}, // CAR_12
};
const std::array<std::vector<float>, (int)PoseModel::Size> POSE_COLORS{
std::vector<float>{POSE_BODY_25_COLORS_RENDER_GPU}, // BODY_25
......@@ -24,12 +24,12 @@ namespace op
std::vector<float>{POSE_MPI_COLORS_RENDER_GPU}, // MPI_15_4
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU}, // BODY_19_X2
std::vector<float>{POSE_BODY_23_COLORS_RENDER_GPU}, // BODY_23
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_19
std::vector<float>{POSE_BODY_65_COLORS_RENDER_GPU}, // BODY_65
std::vector<float>{POSE_CAR_12_COLORS_RENDER_GPU}, // CAR_12
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_BODY_PART_PAIRS_RENDER{
std::vector<unsigned int>{POSE_BODY_25_PAIRS_RENDER_GPU}, // BODY_25
......@@ -38,12 +38,12 @@ namespace op
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU}, // MPI_15_4
std::vector<unsigned int>{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19
std::vector<unsigned int>{POSE_BODY_19_PAIRS_RENDER_GPU}, // BODY_19_X2
std::vector<unsigned int>{POSE_BODY_23_PAIRS_RENDER_GPU}, // BODY_23
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_19
std::vector<unsigned int>{POSE_BODY_65_PAIRS_RENDER_GPU}, // BODY_65
std::vector<unsigned int>{POSE_CAR_12_PAIRS_RENDER_GPU}, // CAR_12
};
// Rendering functions
......
......@@ -13,28 +13,28 @@ 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_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_59_PAIRS_GPU[] = {POSE_BODY_59_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};
// Keypoint scales
__constant__ const float BODY_25_SCALES[] = {POSE_BODY_25_SCALES_RENDER_GPU};
__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_19b_SCALES[] = {POSE_BODY_19b_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_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};
// RGB colors
__constant__ const float BODY_25_COLORS[] = {POSE_BODY_25_COLORS_RENDER_GPU};
__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_19b_COLORS[] = {POSE_BODY_19b_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_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};
......@@ -196,33 +196,6 @@ namespace op
blendOriginalFrame, (googlyEyes ? 15 : -1), (googlyEyes ? 16 : -1));
}
__global__ void renderPoseBody23(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_23_PAIRS_GPU) / (2*sizeof(BODY_23_PAIRS_GPU[0]));
const auto numberScales = sizeof(BODY_23_SCALES) / sizeof(BODY_23_SCALES[0]);
const auto numberColors = sizeof(BODY_23_COLORS) / (3*sizeof(BODY_23_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_23_PAIRS_GPU, numberPeople, 23, numberPartPairs, BODY_23_COLORS, numberColors,
radius, lineWidth, BODY_23_SCALES, numberScales, threshold, alphaColorToAdd,
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)
......@@ -330,6 +303,33 @@ namespace op
radius, lineWidth, COCO_SCALES, numberScales, threshold, alphaColorToAdd, blendOriginalFrame);
}
__global__ void renderPoseCar12(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(CAR_12_PAIRS_GPU) / (2*sizeof(CAR_12_PAIRS_GPU[0]));
const auto numberScales = sizeof(CAR_12_SCALES) / sizeof(CAR_12_SCALES[0]);
const auto numberColors = sizeof(CAR_12_COLORS) / (3*sizeof(CAR_12_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, CAR_12_PAIRS_GPU, numberPeople, 12, numberPartPairs, CAR_12_COLORS, numberColors,
radius, lineWidth, CAR_12_SCALES, numberScales, threshold, alphaColorToAdd,
blendOriginalFrame, (googlyEyes ? 4 : -1), (googlyEyes ? 5 : -1));
}
__global__ void renderBodyPartHeatMaps(float* targetPtr, const int targetWidth, const int targetHeight,
const float* const heatMapPtr, const int widthHeatMap,
const int heightHeatMap, const float scaleToKeepRatio,
......@@ -499,6 +499,7 @@ namespace op
dim3 numBlocks;
getNumberCudaThreadsAndBlocks(threadsPerBlock, numBlocks, frameSize);
// Body pose
if (poseModel == PoseModel::BODY_25 || poseModel == PoseModel::BODY_25_19)
renderPoseBody25<<<threadsPerBlock, numBlocks>>>(
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
......@@ -520,11 +521,6 @@ namespace op
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
);
else if (poseModel == PoseModel::BODY_23)
renderPoseBody23<<<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,
......@@ -540,6 +536,13 @@ namespace op
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold,
blendOriginalFrame, alphaBlending
);
// Car pose
else if (poseModel == PoseModel::CAR_12)
renderPoseCar12<<<threadsPerBlock, numBlocks>>>(
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
);
// Unknown
else
error("Invalid Model.", __LINE__, __FUNCTION__, __FILE__);
cudaCheck(__LINE__, __FUNCTION__, __FILE__);
......
......@@ -14,6 +14,7 @@ namespace op
try
{
log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
// Body pose
if (poseModeString == "BODY_25")
return PoseModel::BODY_25;
else if (poseModeString == "COCO")
......@@ -32,12 +33,13 @@ namespace op
return PoseModel::BODY_19_X2;
else if (poseModeString == "BODY_25_19")
return PoseModel::BODY_25_19;
else if (poseModeString == "BODY_23")
return PoseModel::BODY_23;
else if (poseModeString == "BODY_59")
return PoseModel::BODY_59;
else if (poseModeString == "BODY_65")
return PoseModel::BODY_65;
// Car pose
else if (poseModeString == "CAR_12")
return PoseModel::CAR_12;
// else
error("String does not correspond to any model (BODY_25, COCO, MPI, MPI_4_layers)",
__LINE__, __FUNCTION__, __FILE__);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册