提交 4986dadd 编写于 作者: G gineshidalgo99

Fixed CPU bug in Windows

上级 d80fd22c
......@@ -8,7 +8,7 @@
|-------------|
|[![Build Status](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose.svg?branch=master)](https://travis-ci.org/CMU-Perceptual-Computing-Lab/openpose)|
OpenPose represents the **first real-time multi-person system to jointly detect human body, hand, and facial keypoints (in total 130 keypoints) on single images**.
[OpenPose](https://github.com/CMU-Perceptual-Computing-Lab/openpose) represents the **first real-time multi-person system to jointly detect human body, hand, and facial keypoints (in total 130 keypoints) on single images**.
<p align="center">
<img src="doc/media/pose_face_hands.gif", width="480">
......
......@@ -13,8 +13,8 @@ OpenPose C++ API - How to Develop OpenPose
1. Class parameters should start with `m`, class pointers with `p`, shared_ptrs with `sp`, unique_ptrs with `up`, static parameters with `s`.
2. Function and class parameters coding style is the same other than the previous point.
3. Any parameters should not contain special characters, simply letters and numbers (preferred only letters) separated with upper case. E.g., `mThisIsAParameter`, `thisIsAParameter`.
4. In addition, the names should be self-explanatory and not abbreviated. Good examples: `counter`, `thisIs. Bad examples: `ctr`, `var`.
3. Lenght:
4. In addition, the names should be self-explanatory and not abbreviated. Good examples: `counter`, `thisIs`. Bad examples: `ctr`, `var`.
3. Length:
1. Lines should contain up to 120 characters.
4. Comments:
1. Only `//` comments are allowed in the code, `/* */` should not be used.
......@@ -34,15 +34,18 @@ else
```
6. Includes:
1. They should be sorted in this order:
1. There cannot be any include to a 3rd party in the headers (other than OpenCV core: `opencv2/core/core.hpp`).
1. PImpl idiom can be checked (e.g., in `include/openpose/pose/poseExtractorCaffe.hpp`) for an idea of how to avoid it.
2. Otherwise the defining class examples in `include/openpose/core/macros.hpp` (point 1 is highly preferred).
2. They should be sorted in this order:
1. Std libraries.
2. OS libraries.
3. 3rd party libraries (e.g. Caffe, OpenCV).
4. OpenPose libraries.
5. If it is a cpp file, the last one should be its own hpp.
2. Inside each of the previous groups, it should be sorted alphabetically.
3. Inside each of the previous groups, it should be sorted alphabetically.
7. Functions arguments:
1. It should first include the variables to be edited, and secondtly the const variables.
1. It should first include the variables to be edited, and secondly the const variables.
2. Any variable that is not gonna be modified must be added with `const`.
8. Pointers:
1. Pointers must be avoided if possible.
......@@ -64,7 +67,7 @@ This is the faster method to debug a segmentation fault problem. Usual scenario:
1. Comment `#ifndef NDEBUG` and its else and endif.
2. Call OpenPose with `--logging_level 0 --disable_multi_thread`.
3. At this point you have an idea of in which file class the segmentation fault is coming from. Now you can further isolate the error by iteratively adding the following line all over the code until you find the exact position of the segmentation fault: `log("", Priority::Low, __LINE__, __FUNCTION__, __FILE__);`
4. After you have found the segmentation fault, remember to remove all the extra `log()` calls that you temporaryly added.
4. After you have found the segmentation fault, remember to remove all the extra `log()` calls that you temporarily added.
......@@ -86,7 +89,7 @@ This is the faster method to debug a segmentation fault problem. Usual scenario:
3. Get JSONs in OpenPose: examples/tests/pose_accuracy_coco_val.sh
4. Get accuracy (Matlab): validation/f_getValidations.m
### Checking Ground-Truth Labes
### Checking Ground-Truth Labels
From the [COCO dataset](http://cocodataset.org/#download):
1. Download 2014 or 2017 Train/Val annotations.
2. Download the [COCO API](https://github.com/cocodataset/cocoapi).
......
......@@ -7,7 +7,7 @@ namespace op
{
CUDA = 0,
OPEN_CL = 1,
CPU_ONLY = 2,
NO_GPU = 2,
Size,
};
}
......
......@@ -9,12 +9,13 @@ namespace op
enum class PoseModel : unsigned char
{
COCO_18 = 0, /**< COCO model, with 18+1 components (see poseParameters.hpp for details). */
MPI_15 = 1, /**< MPI model, with 15+1 components (see poseParameters.hpp for details). */
MPI_15_4 = 2, /**< Variation of the MPI model, reduced number of CNN stages to 4: faster but less accurate.*/
BODY_18 = 3, /**< Experimental. Do not use. */
BODY_19 = 4, /**< Experimental. Do not use. */
BODY_23 = 5, /**< Experimental. Do not use. */
BODY_59 = 6, /**< Experimental. Do not use. */
MPI_15, /**< MPI model, with 15+1 components (see poseParameters.hpp for details). */
MPI_15_4, /**< Variation of the MPI model, reduced number of CNN stages to 4: faster but less accurate.*/
BODY_18, /**< Experimental. Do not use. */
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. */
Size,
};
......
......@@ -11,7 +11,6 @@ namespace op
const auto POSE_MAX_PEOPLE = 96u;
// Model functions
// POSE_BODY_PART_MAPPING on HPP crashes on Windows at dynamic initialization
OP_API const std::map<unsigned int, std::string>& getPoseBodyPartMapping(const PoseModel poseModel);
OP_API const std::string& getPoseProtoTxt(const PoseModel poseModel);
OP_API const std::string& getPoseTrainedModel(const PoseModel poseModel);
......
......@@ -62,7 +62,8 @@ namespace op
try
{
mIsLastRenderer = false;
return std::make_tuple(spGpuMemory, spGpuMemoryAllocated, spElementToRender, spVolume, spNumberElementsToRender);
return std::make_tuple(spGpuMemory, spGpuMemoryAllocated, spElementToRender, spVolume,
spNumberElementsToRender);
}
catch (const std::exception& e)
{
......
......@@ -38,13 +38,13 @@ namespace op
#elif defined USE_OPENCL
return GpuMode::OPEN_CL;
#else
return GpuMode::CPU_ONLY;
return GpuMode::NO_GPU;
#endif
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return GpuMode::CPU_ONLY;
return GpuMode::NO_GPU;
}
}
}
......@@ -144,7 +144,7 @@ namespace op
{
#ifdef USE_CAFFE
// Layers parameters
upImpl->spBodyPartConnectorCaffe->setPoseModel(mPoseModel);
upImpl->spBodyPartConnectorCaffe->setPoseModel(upImpl->mPoseModel);
#else
UNUSED(poseModel);
UNUSED(modelFolder);
......@@ -239,8 +239,8 @@ namespace op
reshapePoseExtractorCaffe(upImpl->spResizeAndMergeCaffe, upImpl->spNmsCaffe,
upImpl->spBodyPartConnectorCaffe, upImpl->spCaffeNetOutputBlobs,
upImpl->spHeatMapsBlob, upImpl->spPeaksBlob,
1.f, mPoseModel);
// scaleInputToNetInputs[i], mPoseModel);
1.f, upImpl->mPoseModel);
// scaleInputToNetInputs[i], upImpl->mPoseModel);
}
}
......
......@@ -87,6 +87,29 @@ namespace op
{18, "LEar"},
{19, "Background"}
};
// Windows map copy error if `POSE_BODY_19_BODY_PARTS = POSE_BODY_19_X2_BODY_PARTS`
const std::map<unsigned int, std::string> POSE_BODY_19_X2_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, "Background"}
};
const std::map<unsigned int, std::string> POSE_BODY_23_BODY_PARTS {
{0, "Neck"},
{1, "RShoulder"},
......@@ -165,37 +188,43 @@ namespace op
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
},
// MPI & MPI_15
// 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
},
// 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
},
// BODY 18
// 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
},
// BODY 19
// 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
},
// 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
},
// BODY 23
// 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
},
// BODY 59
// 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
}
},
};
// 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_COCO_BODY_PARTS, POSE_MPI_BODY_PARTS, POSE_MPI_BODY_PARTS, POSE_BODY_18_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_X2_BODY_PARTS,POSE_BODY_23_BODY_PARTS,POSE_BODY_59_BODY_PARTS
};
const std::array<std::string, (int)PoseModel::Size> POSE_PROTOTXT{
......@@ -204,8 +233,9 @@ namespace op
"pose/mpi/pose_deploy_linevec_faster_4_stages.prototxt",
"pose/body_18/pose_deploy.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_59/pose_deploy.prototxt",
};
const std::array<std::string, (int)PoseModel::Size> POSE_TRAINED_MODEL{
"pose/coco/pose_iter_440000.caffemodel",
......@@ -213,24 +243,25 @@ namespace op
"pose/mpi/pose_iter_160000.caffemodel",
"pose/body_18/pose_iter_XXXXXX.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_59/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, 23, 59
18, 15, 15, 18, 19, 19, 23, 59
};
const std::array<std::vector<unsigned int>, (int)PoseModel::Size> POSE_BODY_PART_PAIRS{
// COCO
std::vector<unsigned int>{
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
},
// MPI
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU},
// MPI_15
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU},
// MPI_15_4
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU},
// BODY_18
std::vector<unsigned int>{
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
......@@ -239,6 +270,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
},
// BODY_19_X2
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
......@@ -251,30 +286,43 @@ namespace op
},
};
const std::array<unsigned int, (int)PoseModel::Size> POSE_MAX_PEAKS{
POSE_MAX_PEOPLE, POSE_MAX_PEOPLE, POSE_MAX_PEOPLE, POSE_MAX_PEOPLE,
POSE_MAX_PEOPLE, POSE_MAX_PEOPLE, POSE_MAX_PEOPLE
POSE_MAX_PEOPLE, // COCO
POSE_MAX_PEOPLE, // MPI_15
POSE_MAX_PEOPLE, // MPI_15_4
POSE_MAX_PEOPLE, // BODY_18
POSE_MAX_PEOPLE, // BODY_19
POSE_MAX_PEOPLE, // BODY_19_X2
POSE_MAX_PEOPLE, // BODY_23
POSE_MAX_PEOPLE, // BODY_59
};
const std::array<float, (int)PoseModel::Size> POSE_CCN_DECREASE_FACTOR{
8.f, 8.f, 8.f, 8.f, 8.f, 8.f, 8.f
8.f, // COCO
8.f, // MPI_15
8.f, // MPI_15_4
8.f, // BODY_18
8.f, // BODY_19
4.f, // BODY_19_X2
8.f, // BODY_23
8.f, // BODY_59
};
// 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.6f, 0.3f, 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.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.01f, 0.01f, 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
};
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.2f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f // Matlab version
};
......
......@@ -9,8 +9,9 @@ namespace op
std::vector<float>{POSE_MPI_SCALES_RENDER_GPU},
std::vector<float>{POSE_BODY_18_SCALES_RENDER_GPU},
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU},
std::vector<float>{POSE_BODY_19_SCALES_RENDER_GPU},
std::vector<float>{POSE_BODY_23_SCALES_RENDER_GPU},
std::vector<float>{POSE_BODY_59_SCALES_RENDER_GPU}
std::vector<float>{POSE_BODY_59_SCALES_RENDER_GPU},
};
const std::array<std::vector<float>, (int)PoseModel::Size> POSE_COLORS{
std::vector<float>{POSE_COCO_COLORS_RENDER_GPU},
......@@ -18,17 +19,19 @@ namespace op
std::vector<float>{POSE_MPI_COLORS_RENDER_GPU},
std::vector<float>{POSE_BODY_18_COLORS_RENDER_GPU},
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU},
std::vector<float>{POSE_BODY_19_COLORS_RENDER_GPU},
std::vector<float>{POSE_BODY_23_COLORS_RENDER_GPU},
std::vector<float>{POSE_BODY_59_COLORS_RENDER_GPU}
std::vector<float>{POSE_BODY_59_COLORS_RENDER_GPU},
};
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
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU}, // MPI
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU}, // MPI_15
std::vector<unsigned int>{POSE_MPI_PAIRS_RENDER_GPU}, // MPI_15_4
std::vector<unsigned int>{POSE_BODY_18_PAIRS_RENDER_GPU}, // BODY_18
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_59_PAIRS_RENDER_GPU}, // BODY_59
};
// Rendering functions
......
......@@ -455,7 +455,7 @@ namespace op
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
);
else if (poseModel == PoseModel::BODY_19)
else if (poseModel == PoseModel::BODY_19 || poseModel == PoseModel::BODY_19_X2)
renderPoseBody19<<<threadsPerBlock, numBlocks>>>(
framePtr, frameSize.x, frameSize.y, posePtr, numberPeople, renderThreshold, googlyEyes,
blendOriginalFrame, alphaBlending
......
......@@ -23,6 +23,8 @@ namespace op
return PoseModel::BODY_18;
else if (poseModeString == "BODY_19")
return PoseModel::BODY_19;
else if (poseModeString == "BODY_19_X2")
return PoseModel::BODY_19_X2;
else if (poseModeString == "BODY_23")
return PoseModel::BODY_23;
else if (poseModeString == "BODY_59")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册