提交 d2dc9963 编写于 作者: G gineshidalgo99

Added flag maximize_positives

上级 b2725c07
......@@ -802,10 +802,10 @@ if (WITH_CERES)
include_directories(${CERES_INCLUDE_DIRS})
endif (WITH_CERES)
if (WITH_FLIR_CAMERA)
include_directories(${SPINNAKER_INCLUDE_DIRS})
include_directories(SYSTEM ${SPINNAKER_INCLUDE_DIRS}) # To remove its warnings, equiv. to -isystem
endif (WITH_FLIR_CAMERA)
if (WITH_3D_ADAM_MODEL)
include_directories(include/adam) # TEMPORARY - TO BE REMOVED IN THE FUTURE
include_directories(include/adam) # TODO: TEMPORARY - TO BE REMOVED IN THE FUTURE
include_directories(${CERES_INCLUDE_DIRS})
include_directories(${EIGEN3_INCLUDE_DIRS})
include_directories(${IGL_INCLUDE_DIRS})
......
......@@ -161,6 +161,7 @@ Each flag is divided into flag name, default value, and description.
- DEFINE_int32(num_gpu_start, 0, "GPU device start number.");
- DEFINE_int32(keypoint_scale, 0, "Scaling of the (x,y) coordinates of the final pose data array, i.e., the scale of the (x,y) coordinates that will be saved with the `write_json` & `write_keypoint` flags. Select `0` to scale it to the original source resolution; `1`to scale it to the net output size (set with `net_resolution`); `2` to scale it to the final output size (set with `resolution`); `3` to scale it in the range [0,1], where (0,0) would be the top-left corner of the image, and (1,1) the bottom-right one; and 4 for range [-1,1], where (-1,-1) would be the top-left corner of the image, and (1,1) the bottom-right one. Non related with `scale_number` and `scale_gap`.");
- DEFINE_int32(number_people_max, -1, "This parameter will limit the maximum number of people detected, by keeping the people with top scores. The score is based in person area over the image, body part score, as well as joint score (between each pair of connected body parts). Useful if you know the exact number of people in the scene, so it can remove false positives (if all the people have been detected. However, it might also include false negatives by removing very small or highly occluded people. -1 will keep them all.");
- DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and true positives. I.e., it maximizes average recall but could harm average precision.");
4. OpenPose Body Pose
- DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face keypoint detection.");
......
......@@ -286,11 +286,14 @@ OpenPose Library - Release Notes
15. Function `resizeFixedAspectRatio` can take already allocated memory (e.g., faster if target is an Array<T> object, no intermediate cv::Mat required).
16. Added compatibility for OpenCV 4.0, while preserving 2.4.X and 3.X compatibility.
17. Improved and added several functions to `utilities/keypoints.hpp` and Array to simplify keypoint post-processing.
18. Removed warnings from Spinnaker SDK at compiling time.
19. All bash scripts incorporate `#!/bin/bash` to tell the terminal that they are bash scripts.
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.
3. WrapperT.configure() changed from 1 function that requries all arguments to individual functions that take 1 argument each.
4. Added `Forward` to all net classes that automatically selects between CUDA, OpenCL, or CPU-only version depending on the defines.
5. Previously hardcoded `COCO_CHALLENGE` variable turned into user configurable flag `--maximize_positives`.
3. Main bugs fixed:
1. CMake-GUI was forcing to Release mode, allowed Debug modes too.
2. NMS returns in index 0 the number of found peaks. However, while the number of peaks was truncated to a maximum of 127, this index 0 was saving the real number instead of the truncated one.
......
......@@ -72,7 +72,7 @@ int openPoseDemo()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
# Required
......
......@@ -55,7 +55,7 @@ int handFromJsonTest()
op::ScaleMode::InputResolution, FLAGS_num_gpu, FLAGS_num_gpu_start,
1, 0.15f, op::RenderMode::None, op::PoseModel::BODY_25,
true, 0.f, 0.f, 0, "models/", {}, op::ScaleMode::ZeroToOne, false,
0.05f, -1, enableGoogleLogging};
0.05f, -1, false, enableGoogleLogging};
wrapperStructPose.modelFolder = FLAGS_model_folder;
// Hand configuration (use op::WrapperStructHand{} to disable it)
const op::WrapperStructHand wrapperStructHand{FLAGS_hand, handNetInputSize, FLAGS_hand_scale_number,
......
#!/bin/bash
# Disclaimer:
# Script for internal use. We might make continuous changess on it and we will not answer questions about it.
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......@@ -21,6 +25,7 @@ OP_BIN=./build/examples/openpose/openpose.bin
# 1 scale
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --render_pose 0
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_max.json --display 0 --render_pose 0 --maximize_positives --model_pose BODY_25E
# 1 scale - Debugging
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --display 0 --write_images ~/Desktop/CppValidation/
......@@ -30,6 +35,4 @@ $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1.json --displ
# # 4 scales
# $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
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4_max.json --display 0 --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --maximize_positives
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
clear && clear
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
# # Go back to main folder
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
# # Go back to main folder
......
#!/bin/bash
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
# USAGE EXAMPLE
......
......@@ -85,7 +85,7 @@ int tutorialAddModule1()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -91,7 +91,7 @@ int tutorialApiCpp3()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -224,7 +224,7 @@ int tutorialApiCpp4()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -167,7 +167,7 @@ int tutorialApiCpp5()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -135,7 +135,7 @@ int tutorialApiCpp6()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -175,7 +175,7 @@ int tutorialApiCpp7()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -182,7 +182,7 @@ int tutorialApiCpp8()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -281,7 +281,7 @@ int tutorialApiCpp9()
FLAGS_scale_number, (float)FLAGS_scale_gap, op::flagsToRenderMode(FLAGS_render_pose, multipleView),
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, enableGoogleLogging};
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{
......
......@@ -82,6 +82,8 @@ DEFINE_int32(number_people_max, -1, "This parameter will lim
" number of people in the scene, so it can remove false positives (if all the people have"
" been detected. However, it might also include false negatives by removing very small or"
" highly occluded people. -1 will keep them all.");
DEFINE_bool(maximize_positives, false, "It reduces the thresholds to accept a person candidate. It highly increases both false and"
" true positives. I.e., it maximizes average recall but could harm average precision.");
// OpenPose Body Pose
DEFINE_bool(body_disable, false, "Disable body keypoint detection. Option only possible for faster (but less accurate) face"
" keypoint detection.");
......
......@@ -10,7 +10,8 @@ namespace op
void connectBodyPartsCpu(
Array<T>& poseKeypoints, Array<T>& poseScores, const T* const heatMapPtr, const T* const peaksPtr,
const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks, const T interMinAboveThreshold,
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f);
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f,
const bool maximizePositives = false);
// Windows: Cuda functions do not include OP_API
template <typename T>
......@@ -18,7 +19,7 @@ namespace op
Array<T>& poseKeypoints, Array<T>& poseScores, const T* const heatMapGpuPtr, const T* const peaksPtr,
const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks, const T interMinAboveThreshold,
const T interThreshold, const int minSubsetCnt, const T minSubsetScore, const T scaleFactor = 1.f,
Array<T> pairScoresCpu = Array<T>{}, T* pairScoresGpuPtr = nullptr,
const bool maximizePositives = false, Array<T> pairScoresCpu = Array<T>{}, T* pairScoresGpuPtr = nullptr,
const unsigned int* const bodyPartPairsGpuPtr = nullptr, const unsigned int* const mapIdxGpuPtr = nullptr,
const T* const peaksGpuPtr = nullptr);
......@@ -34,7 +35,7 @@ namespace op
void removePeopleBelowThresholds(std::vector<int>& validSubsetIndexes, int& numberPeople,
const std::vector<std::pair<std::vector<int>, T>>& subsets,
const unsigned int numberBodyParts, const int minSubsetCnt,
const T minSubsetScore, const int maxPeaks);
const T minSubsetScore, const int maxPeaks, const bool maximizePositives);
template <typename T>
void peopleVectorToPeopleArray(Array<T>& poseKeypoints, Array<T>& poseScores, const T scaleFactor,
......
......@@ -23,6 +23,8 @@ namespace op
void setPoseModel(const PoseModel poseModel);
void setMaximizePositives(const bool maximizePositives);
void setInterMinAboveThreshold(const T interMinAboveThreshold);
void setInterThreshold(const T interThreshold);
......@@ -50,6 +52,7 @@ namespace op
private:
PoseModel mPoseModel;
bool mMaximizePositives;
T mInterMinAboveThreshold;
T mInterThreshold;
int mMinSubsetCnt;
......
......@@ -14,6 +14,7 @@ namespace op
const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne,
const bool addPartCandidates = false,
const bool maximizePositives = false,
const bool enableGoogleLogging = true);
virtual ~PoseExtractorCaffe();
......
......@@ -14,7 +14,8 @@ namespace op
PoseExtractorNet(const PoseModel poseModel,
const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne,
const bool addPartCandidates = false);
const bool addPartCandidates = false,
const bool maximizePositives = false);
virtual ~PoseExtractorNet();
......
......@@ -26,14 +26,11 @@ namespace op
OP_API unsigned int poseBodyPartMapStringToKey(const PoseModel poseModel, const std::vector<std::string>& strings);
// Default NSM and body connector parameters
OP_API float getPoseDefaultNmsThreshold(const PoseModel poseModel);
OP_API float getPoseDefaultConnectInterMinAboveThreshold(const PoseModel poseModel);
OP_API float getPoseDefaultConnectInterThreshold(const PoseModel poseModel);
OP_API unsigned int getPoseDefaultMinSubsetCnt(const PoseModel poseModel);
OP_API float getPoseDefaultConnectMinSubsetScore(const PoseModel poseModel);
// const bool COCO_CHALLENGE = true;
const bool COCO_CHALLENGE = false;
OP_API float getPoseDefaultNmsThreshold(const PoseModel poseModel, const bool maximizePositives = false);
OP_API float getPoseDefaultConnectInterMinAboveThreshold(const bool maximizePositives = false);
OP_API float getPoseDefaultConnectInterThreshold(const PoseModel poseModel, const bool maximizePositives = false);
OP_API unsigned int getPoseDefaultMinSubsetCnt(const bool maximizePositives = false);
OP_API float getPoseDefaultConnectMinSubsetScore(const bool maximizePositives = false);
}
#endif // OPENPOSE_POSE_POSE_PARAMETERS_HPP
......@@ -263,7 +263,8 @@ namespace op
poseExtractorNets.emplace_back(std::make_shared<PoseExtractorCaffe>(
wrapperStructPose.poseModel, modelFolder, gpuId + gpuNumberStart,
wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale,
wrapperStructPose.addPartCandidates, wrapperStructPose.enableGoogleLogging
wrapperStructPose.addPartCandidates, wrapperStructPose.maximizePositives,
wrapperStructPose.enableGoogleLogging
));
// Pose renderers
......
......@@ -158,6 +158,13 @@ namespace op
*/
int numberPeopleMax;
/**
* Whether to maximize the number of positives.
* It reduces the thresholds to accept a person candidate. It highly increases both false and true positives.
* I.e., it maximizes average recall but could harm average precision.
*/
bool maximizePositives;
/**
* Whether to internally enable Google Logging.
* This option is only applicable if Caffe is used.
......@@ -184,7 +191,7 @@ namespace op
const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false,
const float renderThreshold = 0.05f, const int numberPeopleMax = -1,
const bool enableGoogleLogging = true);
const bool maximizePositives = false, const bool enableGoogleLogging = true);
};
}
......
......@@ -617,7 +617,8 @@ namespace op
void removePeopleBelowThresholds(std::vector<int>& validSubsetIndexes, int& numberPeople,
const std::vector<std::pair<std::vector<int>, T>>& peopleVector,
const unsigned int numberBodyParts, const int minSubsetCnt,
const T minSubsetScore, const int maxPeaks)
const T minSubsetScore, const int maxPeaks,
const bool maximizePositives)
{
try
{
......@@ -635,7 +636,7 @@ namespace op
// same foot usually appears as both left and right keypoints)
// Pros: Removed tons of false positives
// Cons: Standalone leg will never be recorded
if (!COCO_CHALLENGE && numberBodyParts == 25)
if (!maximizePositives && numberBodyParts == 25)
{
// No consider foot keypoints for that
for (auto i = 19 ; i < 25 ; i++)
......@@ -1097,7 +1098,8 @@ namespace op
void connectBodyPartsCpu(Array<T>& poseKeypoints, Array<T>& poseScores, const T* const heatMapPtr,
const T* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize,
const int maxPeaks, const T interMinAboveThreshold, const T interThreshold,
const int minSubsetCnt, const T minSubsetScore, const T scaleFactor)
const int minSubsetCnt, const T minSubsetScore, const T scaleFactor,
const bool maximizePositives)
{
try
{
......@@ -1124,7 +1126,7 @@ namespace op
std::vector<int> validSubsetIndexes;
validSubsetIndexes.reserve(fastMin((size_t)maxPeaks, peopleVector.size()));
removePeopleBelowThresholds(validSubsetIndexes, numberPeople, peopleVector, numberBodyParts, minSubsetCnt,
minSubsetScore, maxPeaks);
minSubsetScore, maxPeaks, maximizePositives);
// Fill and return poseKeypoints
peopleVectorToPeopleArray(poseKeypoints, poseScores, scaleFactor, peopleVector, validSubsetIndexes,
......@@ -1148,12 +1150,12 @@ namespace op
Array<float>& poseKeypoints, Array<float>& poseScores, const float* const heatMapPtr,
const float* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks,
const float interMinAboveThreshold, const float interThreshold, const int minSubsetCnt,
const float minSubsetScore, const float scaleFactor);
const float minSubsetScore, const float scaleFactor, const bool maximizePositives);
template OP_API void connectBodyPartsCpu(
Array<double>& poseKeypoints, Array<double>& poseScores, const double* const heatMapPtr,
const double* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks,
const double interMinAboveThreshold, const double interThreshold, const int minSubsetCnt,
const double minSubsetScore, const double scaleFactor);
const double minSubsetScore, const double scaleFactor, const bool maximizePositives);
template OP_API std::vector<std::pair<std::vector<int>, float>> createPeopleVector(
const float* const heatMapPtr, const float* const peaksPtr, const PoseModel poseModel,
......@@ -1172,12 +1174,12 @@ namespace op
std::vector<int>& validSubsetIndexes, int& numberPeople,
const std::vector<std::pair<std::vector<int>, float>>& peopleVector,
const unsigned int numberBodyParts,
const int minSubsetCnt, const float minSubsetScore, const int maxPeaks);
const int minSubsetCnt, const float minSubsetScore, const int maxPeaks, const bool maximizePositives);
template OP_API void removePeopleBelowThresholds(
std::vector<int>& validSubsetIndexes, int& numberPeople,
const std::vector<std::pair<std::vector<int>, double>>& peopleVector,
const unsigned int numberBodyParts,
const int minSubsetCnt, const double minSubsetScore, const int maxPeaks);
const int minSubsetCnt, const double minSubsetScore, const int maxPeaks, const bool maximizePositives);
template OP_API void peopleVectorToPeopleArray(
Array<float>& poseKeypoints, Array<float>& poseScores, const float scaleFactor,
......
......@@ -111,7 +111,7 @@ namespace op
const T* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize,
const int maxPeaks, const T interMinAboveThreshold, const T interThreshold,
const int minSubsetCnt, const T minSubsetScore, const T scaleFactor,
Array<T> pairScoresCpu, T* pairScoresGpuPtr,
const bool maximizePositives, Array<T> pairScoresCpu, T* pairScoresGpuPtr,
const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr,
const T* const peaksGpuPtr)
{
......@@ -169,7 +169,7 @@ namespace op
std::vector<int> validSubsetIndexes;
validSubsetIndexes.reserve(fastMin((size_t)maxPeaks, peopleVector.size()));
removePeopleBelowThresholds(validSubsetIndexes, numberPeople, peopleVector, numberBodyParts, minSubsetCnt,
minSubsetScore, maxPeaks);
minSubsetScore, maxPeaks, maximizePositives);
// Fill and return poseKeypoints
peopleVectorToPeopleArray(poseKeypoints, poseScores, scaleFactor, peopleVector, validSubsetIndexes,
......@@ -188,14 +188,14 @@ namespace op
Array<float>& poseKeypoints, Array<float>& poseScores, const float* const heatMapGpuPtr,
const float* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks,
const float interMinAboveThreshold, const float interThreshold, const int minSubsetCnt,
const float minSubsetScore, const float scaleFactor, Array<float> pairScoresCpu, float* pairScoresGpuPtr,
const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr,
const float* const peaksGpuPtr);
const float minSubsetScore, const float scaleFactor, const bool maximizePositives,
Array<float> pairScoresCpu, float* pairScoresGpuPtr, const unsigned int* const bodyPartPairsGpuPtr,
const unsigned int* const mapIdxGpuPtr, const float* const peaksGpuPtr);
template void connectBodyPartsGpu(
Array<double>& poseKeypoints, Array<double>& poseScores, const double* const heatMapGpuPtr,
const double* const peaksPtr, const PoseModel poseModel, const Point<int>& heatMapSize, const int maxPeaks,
const double interMinAboveThreshold, const double interThreshold, const int minSubsetCnt,
const double minSubsetScore, const double scaleFactor, Array<double> pairScoresCpu, double* pairScoresGpuPtr,
const unsigned int* const bodyPartPairsGpuPtr, const unsigned int* const mapIdxGpuPtr,
const double* const peaksGpuPtr);
const double minSubsetScore, const double scaleFactor, const bool maximizePositives,
Array<double> pairScoresCpu, double* pairScoresGpuPtr, const unsigned int* const bodyPartPairsGpuPtr,
const unsigned int* const mapIdxGpuPtr, const double* const peaksGpuPtr);
}
......@@ -12,6 +12,8 @@ namespace op
{
template <typename T>
BodyPartConnectorCaffe<T>::BodyPartConnectorCaffe() :
mPoseModel{PoseModel::Size},
mMaximizePositives{false},
pBodyPartPairsGpuPtr{nullptr},
pMapIdxGpuPtr{nullptr},
pFinalOutputGpuPtr{nullptr}
......@@ -61,10 +63,10 @@ namespace op
// Array sizes
mTopSize = std::array<int, 4>{1, maxPeaks, numberBodyParts, 3};
mHeatMapsSize = std::array<int, 4>{heatMapsBlob->shape(0), heatMapsBlob->shape(1),
heatMapsBlob->shape(2), heatMapsBlob->shape(3)};
mPeaksSize = std::array<int, 4>{peaksBlob->shape(0), peaksBlob->shape(1), peaksBlob->shape(2),
peaksBlob->shape(3)};
mHeatMapsSize = std::array<int, 4>{
heatMapsBlob->shape(0), heatMapsBlob->shape(1), heatMapsBlob->shape(2), heatMapsBlob->shape(3)};
mPeaksSize = std::array<int, 4>{
peaksBlob->shape(0), peaksBlob->shape(1), peaksBlob->shape(2), peaksBlob->shape(3)};
#else
UNUSED(bottom);
#endif
......@@ -88,6 +90,19 @@ namespace op
}
}
template <typename T>
void BodyPartConnectorCaffe<T>::setMaximizePositives(const bool maximizePositives)
{
try
{
mMaximizePositives = {maximizePositives};
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
}
}
template <typename T>
void BodyPartConnectorCaffe<T>::setInterMinAboveThreshold(const T interMinAboveThreshold)
{
......@@ -187,7 +202,7 @@ namespace op
connectBodyPartsCpu(poseKeypoints, poseScores, heatMapsPtr, peaksPtr, mPoseModel,
Point<int>{heatMapsBlob->shape(3), heatMapsBlob->shape(2)},
maxPeaks, mInterMinAboveThreshold, mInterThreshold,
mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput);
mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mMaximizePositives);
#else
UNUSED(bottom);
UNUSED(poseKeypoints);
......@@ -256,8 +271,9 @@ namespace op
connectBodyPartsGpu(poseKeypoints, poseScores, heatMapsGpuPtr, peaksPtr, mPoseModel,
Point<int>{heatMapsBlob->shape(3), heatMapsBlob->shape(2)},
maxPeaks, mInterMinAboveThreshold, mInterThreshold,
mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mFinalOutputCpu,
pFinalOutputGpuPtr, pBodyPartPairsGpuPtr, pMapIdxGpuPtr, peaksGpuPtr);
mMinSubsetCnt, mMinSubsetScore, mScaleNetToOutput, mMaximizePositives,
mFinalOutputCpu, pFinalOutputGpuPtr, pBodyPartPairsGpuPtr, pMapIdxGpuPtr,
peaksGpuPtr);
#else
UNUSED(bottom);
UNUSED(poseKeypoints);
......
......@@ -156,8 +156,8 @@ namespace op
PoseExtractorCaffe::PoseExtractorCaffe(const PoseModel poseModel, const std::string& modelFolder,
const int gpuId, const std::vector<HeatMapType>& heatMapTypes,
const ScaleMode heatMapScale, const bool addPartCandidates,
const bool enableGoogleLogging) :
PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates}
const bool maximizePositives, const bool enableGoogleLogging) :
PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates, maximizePositives}
#ifdef USE_CAFFE
, upImpl{new ImplPoseExtractorCaffe{poseModel, gpuId, modelFolder, enableGoogleLogging}}
#endif
......@@ -167,6 +167,7 @@ namespace op
#ifdef USE_CAFFE
// Layers parameters
upImpl->spBodyPartConnectorCaffe->setPoseModel(upImpl->mPoseModel);
upImpl->spBodyPartConnectorCaffe->setMaximizePositives(maximizePositives);
#else
UNUSED(poseModel);
UNUSED(modelFolder);
......
......@@ -45,7 +45,8 @@ namespace op
}
PoseExtractorNet::PoseExtractorNet(const PoseModel poseModel, const std::vector<HeatMapType>& heatMapTypes,
const ScaleMode heatMapScale, const bool addPartCandidates) :
const ScaleMode heatMapScale, const bool addPartCandidates,
const bool maximizePositives) :
mPoseModel{poseModel},
mNetOutputSize{0,0},
mHeatMapTypes{heatMapTypes},
......@@ -60,15 +61,18 @@ namespace op
error("The ScaleMode heatMapScale must be ZeroToOne, PlusMinusOne, UnsignedChar, or NoScale.",
__LINE__, __FUNCTION__, __FILE__);
// Properties
// Properties - Init to 0
for (auto& property : mProperties)
property = 0.;
mProperties[(int)PoseProperty::NMSThreshold] = getPoseDefaultNmsThreshold(mPoseModel);
// Properties - Fill default values
mProperties[(int)PoseProperty::NMSThreshold] = getPoseDefaultNmsThreshold(mPoseModel, maximizePositives);
mProperties[(int)PoseProperty::ConnectInterMinAboveThreshold]
= getPoseDefaultConnectInterMinAboveThreshold(mPoseModel);
mProperties[(int)PoseProperty::ConnectInterThreshold] = getPoseDefaultConnectInterThreshold(mPoseModel);
mProperties[(int)PoseProperty::ConnectMinSubsetCnt] = getPoseDefaultMinSubsetCnt(mPoseModel);
mProperties[(int)PoseProperty::ConnectMinSubsetScore] = getPoseDefaultConnectMinSubsetScore(mPoseModel);
= getPoseDefaultConnectInterMinAboveThreshold(maximizePositives);
mProperties[(int)PoseProperty::ConnectInterThreshold] = getPoseDefaultConnectInterThreshold(
mPoseModel, maximizePositives);
mProperties[(int)PoseProperty::ConnectMinSubsetCnt] = getPoseDefaultMinSubsetCnt(maximizePositives);
mProperties[(int)PoseProperty::ConnectMinSubsetScore] = getPoseDefaultConnectMinSubsetScore(
maximizePositives);
}
catch (const std::exception& e)
{
......
......@@ -483,31 +483,6 @@ namespace op
8.f, // CAR_22
};
// Default Model Parameters
// They might be modified on running time
const auto nmsT = (COCO_CHALLENGE ? 0.02f : 0.05f);
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_NMS_THRESHOLD{
nmsT, nmsT, 0.6f, 0.3f, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT, nmsT
};
const auto minAT = (COCO_CHALLENGE ? 0.75f : 0.95f); // Matlab version: 0.85f
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_INTER_MIN_ABOVE_THRESHOLD{
minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT, minAT
// 0.85f, 0.85f, 0.85f, 0.85f, 0.85f, 0.85f // Matlab version
};
const auto conIT = (COCO_CHALLENGE ? 0.01f : 0.05f);
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_INTER_THRESHOLD{
conIT, conIT, 0.01f, 0.01f, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT, conIT
};
const auto minSC = (COCO_CHALLENGE ? 2 : 3);
const std::array<unsigned int, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_MIN_SUBSET_CNT{
minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC, minSC
};
const auto minSS = (COCO_CHALLENGE ? 0.05f : 0.4f);
const std::array<float, (int)PoseModel::Size> POSE_DEFAULT_CONNECT_MIN_SUBSET_SCORE{
minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS, minSS
// 0.2f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f // Matlab version
};
const std::map<unsigned int, std::string>& getPoseBodyPartMapping(const PoseModel poseModel)
{
try
......@@ -645,11 +620,19 @@ namespace op
}
// Default Model Parameters
float getPoseDefaultNmsThreshold(const PoseModel poseModel)
// They might be modified on running time
float getPoseDefaultNmsThreshold(const PoseModel poseModel, const bool maximizePositives)
{
try
{
return POSE_DEFAULT_NMS_THRESHOLD.at((int)poseModel);
// MPI models
if (poseModel == PoseModel::MPI_15)
return 0.6f;
else if (poseModel == PoseModel::MPI_15_4)
return 0.3f;
// Non-MPI models
else
return (maximizePositives ? 0.02f : 0.05f);
}
catch (const std::exception& e)
{
......@@ -658,11 +641,11 @@ namespace op
}
}
float getPoseDefaultConnectInterMinAboveThreshold(const PoseModel poseModel)
float getPoseDefaultConnectInterMinAboveThreshold(const bool maximizePositives)
{
try
{
return POSE_DEFAULT_CONNECT_INTER_MIN_ABOVE_THRESHOLD.at((int)poseModel);
return (maximizePositives ? 0.75f : 0.95f);
}
catch (const std::exception& e)
{
......@@ -671,11 +654,16 @@ namespace op
}
}
float getPoseDefaultConnectInterThreshold(const PoseModel poseModel)
float getPoseDefaultConnectInterThreshold(const PoseModel poseModel, const bool maximizePositives)
{
try
{
return POSE_DEFAULT_CONNECT_INTER_THRESHOLD.at((int)poseModel);
// MPI models
if (poseModel == PoseModel::MPI_15 || poseModel == PoseModel::MPI_15_4)
return 0.01f;
// Non-MPI models
else
return (maximizePositives ? 0.01f : 0.05f);
}
catch (const std::exception& e)
{
......@@ -684,11 +672,11 @@ namespace op
}
}
unsigned int getPoseDefaultMinSubsetCnt(const PoseModel poseModel)
unsigned int getPoseDefaultMinSubsetCnt(const bool maximizePositives)
{
try
{
return POSE_DEFAULT_CONNECT_MIN_SUBSET_CNT.at((int)poseModel);
return (maximizePositives ? 2u : 3u);
}
catch (const std::exception& e)
{
......@@ -697,11 +685,11 @@ namespace op
}
}
float getPoseDefaultConnectMinSubsetScore(const PoseModel poseModel)
float getPoseDefaultConnectMinSubsetScore(const bool maximizePositives)
{
try
{
return POSE_DEFAULT_CONNECT_MIN_SUBSET_SCORE.at((int)poseModel);
return (maximizePositives ? 0.05f : 0.4f);
}
catch (const std::exception& e)
{
......
......@@ -2,9 +2,9 @@
namespace op
{
WrapperStructExtra::WrapperStructExtra(const bool reconstruct3d_, const int minViews3d_,
const bool identification_, const int tracking_,
const int ikThreads_) :
WrapperStructExtra::WrapperStructExtra(
const bool reconstruct3d_, const int minViews3d_, const bool identification_, const int tracking_,
const int ikThreads_) :
reconstruct3d{reconstruct3d_},
minViews3d{minViews3d_},
identification{identification_},
......
......@@ -2,9 +2,9 @@
namespace op
{
WrapperStructFace::WrapperStructFace(const bool enable_, const Point<int>& netInputSize_, const RenderMode renderMode_,
const float alphaKeypoint_, const float alphaHeatMap_,
const float renderThreshold_) :
WrapperStructFace::WrapperStructFace(
const bool enable_, const Point<int>& netInputSize_, const RenderMode renderMode_, const float alphaKeypoint_,
const float alphaHeatMap_, const float renderThreshold_) :
enable{enable_},
netInputSize{netInputSize_},
renderMode{renderMode_},
......
......@@ -2,10 +2,10 @@
namespace op
{
WrapperStructHand::WrapperStructHand(const bool enable_, const Point<int>& netInputSize_, const int scalesNumber_,
const float scaleRange_, const bool tracking_, const RenderMode renderMode_,
const float alphaKeypoint_, const float alphaHeatMap_,
const float renderThreshold_) :
WrapperStructHand::WrapperStructHand(
const bool enable_, const Point<int>& netInputSize_, const int scalesNumber_, const float scaleRange_,
const bool tracking_, const RenderMode renderMode_, const float alphaKeypoint_, const float alphaHeatMap_,
const float renderThreshold_) :
enable{enable_},
netInputSize{netInputSize_},
scalesNumber{scalesNumber_},
......
......@@ -2,13 +2,12 @@
namespace op
{
WrapperStructInput::WrapperStructInput(const ProducerType producerType_, const std::string& producerString_,
const unsigned long long frameFirst_, const unsigned long long frameStep_,
const unsigned long long frameLast_, const bool realTimeProcessing_,
const bool frameFlip_, const int frameRotate_, const bool framesRepeat_,
const Point<int>& cameraResolution_, const double webcamFps_,
const std::string& cameraParameterPath_, const bool undistortImage_,
const unsigned int imageDirectoryStereo_) :
WrapperStructInput::WrapperStructInput(
const ProducerType producerType_, const std::string& producerString_, const unsigned long long frameFirst_,
const unsigned long long frameStep_, const unsigned long long frameLast_, const bool realTimeProcessing_,
const bool frameFlip_, const int frameRotate_, const bool framesRepeat_, const Point<int>& cameraResolution_,
const double webcamFps_, const std::string& cameraParameterPath_, const bool undistortImage_,
const unsigned int imageDirectoryStereo_) :
producerType{producerType_},
producerString{producerString_},
frameFirst{frameFirst_},
......
......@@ -2,16 +2,14 @@
namespace op
{
WrapperStructOutput::WrapperStructOutput(const DisplayMode displayMode_, const bool guiVerbose_,
const bool fullScreen_, const std::string& writeKeypoint_,
const DataFormat writeKeypointFormat_, const std::string& writeJson_,
const std::string& writeCocoJson_, const std::string& writeCocoFootJson_,
const int writeCocoJsonVariant_, const std::string& writeImages_,
const std::string& writeImagesFormat_, const std::string& writeVideo_,
const double writeVideoFps_, const std::string& writeHeatMaps_,
const std::string& writeHeatMapsFormat_,
const std::string& writeVideoAdam_, const std::string& writeBvh_,
const std::string& udpHost_, const std::string& udpPort_) :
WrapperStructOutput::WrapperStructOutput(
const DisplayMode displayMode_, const bool guiVerbose_, const bool fullScreen_,
const std::string& writeKeypoint_, const DataFormat writeKeypointFormat_, const std::string& writeJson_,
const std::string& writeCocoJson_, const std::string& writeCocoFootJson_, const int writeCocoJsonVariant_,
const std::string& writeImages_, const std::string& writeImagesFormat_, const std::string& writeVideo_,
const double writeVideoFps_, const std::string& writeHeatMaps_, const std::string& writeHeatMapsFormat_,
const std::string& writeVideoAdam_, const std::string& writeBvh_, const std::string& udpHost_,
const std::string& udpPort_) :
displayMode{displayMode_},
guiVerbose{guiVerbose_},
fullScreen{fullScreen_},
......
......@@ -2,18 +2,14 @@
namespace op
{
WrapperStructPose::WrapperStructPose(const bool enable_, const Point<int>& netInputSize_,
const Point<int>& outputSize_, const ScaleMode keypointScale_,
const int gpuNumber_, const int gpuNumberStart_,
const int scalesNumber_, const float scaleGap_,
const RenderMode renderMode_, const PoseModel poseModel_,
const bool blendOriginalFrame_, const float alphaKeypoint_,
const float alphaHeatMap_, const int defaultPartToRender_,
const std::string& modelFolder_,
const std::vector<HeatMapType>& heatMapTypes_,
const ScaleMode heatMapScale_, const bool addPartCandidates_,
const float renderThreshold_, const int numberPeopleMax_,
const bool enableGoogleLogging_) :
WrapperStructPose::WrapperStructPose(
const bool enable_, const Point<int>& netInputSize_, const Point<int>& outputSize_,
const ScaleMode keypointScale_, const int gpuNumber_, const int gpuNumberStart_, const int scalesNumber_,
const float scaleGap_, const RenderMode renderMode_, const PoseModel poseModel_,
const bool blendOriginalFrame_, const float alphaKeypoint_, const float alphaHeatMap_,
const int defaultPartToRender_, const std::string& modelFolder_, const std::vector<HeatMapType>& heatMapTypes_,
const ScaleMode heatMapScale_, const bool addPartCandidates_, const float renderThreshold_,
const int numberPeopleMax_, const bool maximizePositives_, const bool enableGoogleLogging_) :
enable{enable_},
netInputSize{netInputSize_},
outputSize{outputSize_},
......@@ -34,6 +30,7 @@ namespace op
addPartCandidates{addPartCandidates_},
renderThreshold{renderThreshold_},
numberPeopleMax{numberPeopleMax_},
maximizePositives{maximizePositives_},
enableGoogleLogging{enableGoogleLogging_}
{
}
......
......@@ -108,7 +108,8 @@ ifneq ($(WITH_FLIR_CAMERA), 0)
COMMON_FLAGS += -DUSE_FLIR_CAMERA
# Spinnaker SDK
LIBRARIES += Spinnaker
INCLUDE_DIRS += $(SPINNAKER_DIR)
# INCLUDE_DIRS += $(SPINNAKER_DIR)
COMMON_FLAGS += -isystem $(SPINNAKER_DIR) # Remove warnings from this library
endif
##############################
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册