提交 03e0ce2b 编写于 作者: G gineshidalgo99

Added prototxt_path and caffemodel_path flags

上级 4cd459af
...@@ -713,7 +713,7 @@ if (UNIX OR APPLE) ...@@ -713,7 +713,7 @@ if (UNIX OR APPLE)
-DCPU_ONLY=${CAFFE_CPU_ONLY} -DCPU_ONLY=${CAFFE_CPU_ONLY}
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
-DBUILD_docs=OFF -DBUILD_docs=OFF
-DBUILD_python=OFF -DBUILD_python=${BUILD_PYTHON}
-DBUILD_python_layer=OFF -DBUILD_python_layer=OFF
-DUSE_LEVELDB=OFF -DUSE_LEVELDB=OFF
-DUSE_LMDB=OFF -DUSE_LMDB=OFF
...@@ -731,7 +731,7 @@ if (UNIX OR APPLE) ...@@ -731,7 +731,7 @@ if (UNIX OR APPLE)
-DCPU_ONLY=${CAFFE_CPU_ONLY} -DCPU_ONLY=${CAFFE_CPU_ONLY}
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release
-DBUILD_docs=OFF -DBUILD_docs=OFF
-DBUILD_python=OFF -DBUILD_python=${BUILD_PYTHON}
-DBUILD_python_layer=OFF -DBUILD_python_layer=OFF
-DUSE_LEVELDB=OFF -DUSE_LEVELDB=OFF
-DUSE_LMDB=OFF -DUSE_LMDB=OFF
......
...@@ -155,6 +155,8 @@ Each flag is divided into flag name, default value, and description. ...@@ -155,6 +155,8 @@ Each flag is divided into flag name, default value, and description.
3. OpenPose 3. OpenPose
- DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located."); - DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located.");
- DEFINE_string(prototxt_path, "", "The combination `--model_folder` + `--prototxt_path` represents the whole path to the prototxt file. If empty, it will use the default OpenPose ProtoTxt file.");
- DEFINE_string(caffemodel_path, "", "The combination `--model_folder` + `--caffemodel_path` represents the whole path to the caffemodel file. If empty, it will use the default OpenPose CaffeModel file.");
- DEFINE_string(output_resolution, "-1x-1", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the input image resolution."); - DEFINE_string(output_resolution, "-1x-1", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the input image resolution.");
- DEFINE_int32(num_gpu, -1, "The number of GPU devices to use. If negative, it will use all the available GPUs in your machine."); - DEFINE_int32(num_gpu, -1, "The number of GPU devices to use. If negative, it will use all the available GPUs in your machine.");
- DEFINE_int32(num_gpu_start, 0, "GPU device start number."); - DEFINE_int32(num_gpu_start, 0, "GPU device start number.");
......
...@@ -303,6 +303,7 @@ OpenPose Library - Release Notes ...@@ -303,6 +303,7 @@ OpenPose Library - Release Notes
29. Added documentation for Nvidia TX2 with JetPack 3.3. 29. Added documentation for Nvidia TX2 with JetPack 3.3.
30. Added Travis build check for several configurations: Ubuntu (14/16)/Mac/Windows and CPU/CUDA/OpenCL and with/without Python. 30. Added Travis build check for several configurations: Ubuntu (14/16)/Mac/Windows and CPU/CUDA/OpenCL and with/without Python.
31. Assigned 755 access to all sh scripts (some of them were only 644). 31. Assigned 755 access to all sh scripts (some of them were only 644).
32. Added the flags `--prototxt_path` and `--caffemodel_path` to allow custom ProtoTxt and CaffeModel paths.
2. Functions or parameters renamed: 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. 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. 2. WrapperStructPose default parameters changed to match those of the OpenPose demo binary.
......
...@@ -73,7 +73,7 @@ int openPoseDemo() ...@@ -73,7 +73,7 @@ int openPoseDemo()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapper.configure(wrapperStructPose); opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -86,7 +86,7 @@ int tutorialAddModule1() ...@@ -86,7 +86,7 @@ int tutorialAddModule1()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -92,7 +92,7 @@ int tutorialApiCpp3() ...@@ -92,7 +92,7 @@ int tutorialApiCpp3()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapper.configure(wrapperStructPose); opWrapper.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -227,7 +227,7 @@ int tutorialApiCpp4() ...@@ -227,7 +227,7 @@ int tutorialApiCpp4()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -169,7 +169,7 @@ int tutorialApiCpp5() ...@@ -169,7 +169,7 @@ int tutorialApiCpp5()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -137,7 +137,7 @@ int tutorialApiCpp6() ...@@ -137,7 +137,7 @@ int tutorialApiCpp6()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -173,7 +173,7 @@ int tutorialApiCpp7() ...@@ -173,7 +173,7 @@ int tutorialApiCpp7()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -185,7 +185,7 @@ int tutorialApiCpp8() ...@@ -185,7 +185,7 @@ int tutorialApiCpp8()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -284,7 +284,7 @@ int tutorialApiCpp9() ...@@ -284,7 +284,7 @@ int tutorialApiCpp9()
poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap, poseModel, !FLAGS_disable_blending, (float)FLAGS_alpha_pose, (float)FLAGS_alpha_heatmap,
FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates, FLAGS_part_to_show, FLAGS_model_folder, heatMapTypes, heatMapScale, FLAGS_part_candidates,
(float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max, (float)FLAGS_render_threshold, FLAGS_number_people_max, FLAGS_maximize_positives, FLAGS_fps_max,
enableGoogleLogging}; FLAGS_prototxt_path, FLAGS_caffemodel_path, enableGoogleLogging};
opWrapperT.configure(wrapperStructPose); opWrapperT.configure(wrapperStructPose);
// Face configuration (use op::WrapperStructFace{} to disable it) // Face configuration (use op::WrapperStructFace{} to disable it)
const op::WrapperStructFace wrapperStructFace{ const op::WrapperStructFace wrapperStructFace{
......
...@@ -60,6 +60,10 @@ DEFINE_bool(frame_undistort, false, "If false (default), it ...@@ -60,6 +60,10 @@ DEFINE_bool(frame_undistort, false, "If false (default), it
#endif // OPENPOSE_FLAGS_DISABLE_PRODUCER #endif // OPENPOSE_FLAGS_DISABLE_PRODUCER
// OpenPose // OpenPose
DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located."); DEFINE_string(model_folder, "models/", "Folder path (absolute or relative) where the models (pose, face, ...) are located.");
DEFINE_string(prototxt_path, "", "The combination `--model_folder` + `--prototxt_path` represents the whole path to the"
" prototxt file. If empty, it will use the default OpenPose ProtoTxt file.");
DEFINE_string(caffemodel_path, "", "The combination `--model_folder` + `--caffemodel_path` represents the whole path to the"
" caffemodel file. If empty, it will use the default OpenPose CaffeModel file.");
DEFINE_string(output_resolution, "-1x-1", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the" DEFINE_string(output_resolution, "-1x-1", "The image resolution (display and output). Use \"-1x-1\" to force the program to use the"
" input image resolution."); " input image resolution.");
DEFINE_int32(num_gpu, -1, "The number of GPU devices to use. If negative, it will use all the available GPUs in your" DEFINE_int32(num_gpu, -1, "The number of GPU devices to use. If negative, it will use all the available GPUs in your"
......
...@@ -10,12 +10,13 @@ namespace op ...@@ -10,12 +10,13 @@ namespace op
class OP_API PoseExtractorCaffe : public PoseExtractorNet class OP_API PoseExtractorCaffe : public PoseExtractorNet
{ {
public: public:
PoseExtractorCaffe(const PoseModel poseModel, const std::string& modelFolder, const int gpuId, PoseExtractorCaffe(
const std::vector<HeatMapType>& heatMapTypes = {}, const PoseModel poseModel, const std::string& modelFolder, const int gpuId,
const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const std::vector<HeatMapType>& heatMapTypes = {},
const bool addPartCandidates = false, const ScaleMode heatMapScale = ScaleMode::ZeroToOne,
const bool maximizePositives = false, const bool addPartCandidates = false, const bool maximizePositives = false,
const bool enableGoogleLogging = true); const std::string& protoTxtPath = "", const std::string& caffeModelPath = "",
const bool enableGoogleLogging = true);
virtual ~PoseExtractorCaffe(); virtual ~PoseExtractorCaffe();
......
...@@ -9,33 +9,33 @@ namespace op ...@@ -9,33 +9,33 @@ namespace op
return (tPointerContainer != nullptr && tPointerContainer->size() > 0); return (tPointerContainer != nullptr && tPointerContainer->size() > 0);
} }
template<typename TDatums> template<typename TDatumsSP>
class PointerContainerGreater class PointerContainerGreater
{ {
public: public:
bool operator() (TDatums& a, TDatums& b) bool operator() (const TDatumsSP& a, const TDatumsSP& b)
{ {
if (!b || b->empty()) if (!b || b->empty())
return true; return true;
else if (!a || a->empty()) else if (!a || a->empty())
return false; return false;
else else
return (*a)[0] > (*b)[0]; return *(*a)[0] > *(*b)[0];
} }
}; };
template<typename TDatums> template<typename TDatumsSP>
class PointerContainerLess class PointerContainerLess
{ {
public: public:
bool operator() (TDatums& a, TDatums& b) bool operator() (const TDatumsSP& a, const TDatumsSP& b)
{ {
if (!b || b->empty()) if (!b || b->empty())
return false; return false;
else if (!a || a->empty()) else if (!a || a->empty())
return true; return true;
else else
return (*a)[0] < (*b)[0]; return *(*a)[0] < *(*b)[0];
} }
}; };
} }
......
...@@ -263,6 +263,7 @@ namespace op ...@@ -263,6 +263,7 @@ namespace op
wrapperStructPose.poseModel, modelFolder, gpuId + gpuNumberStart, wrapperStructPose.poseModel, modelFolder, gpuId + gpuNumberStart,
wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale, wrapperStructPose.heatMapTypes, wrapperStructPose.heatMapScale,
wrapperStructPose.addPartCandidates, wrapperStructPose.maximizePositives, wrapperStructPose.addPartCandidates, wrapperStructPose.maximizePositives,
wrapperStructPose.protoTxtPath, wrapperStructPose.caffeModelPath,
wrapperStructPose.enableGoogleLogging wrapperStructPose.enableGoogleLogging
)); ));
......
...@@ -173,6 +173,20 @@ namespace op ...@@ -173,6 +173,20 @@ namespace op
*/ */
double fpsMax; double fpsMax;
/**
* Final path where the pose Caffe ProtoTxt file is located.
* The combination modelFolder + protoTxtPath represents the whole path to the prototxt file.
* If empty, it will use the default OpenPose ProtoTxt file.
*/
std::string protoTxtPath;
/**
* Final path where the pose Caffe CaffeModel is located.
* The combination modelFolder + caffeModelPath represents the whole path to the caffemodel file.
* If empty, it will use the default OpenPose CaffeModel file.
*/
std::string caffeModelPath;
/** /**
* Whether to internally enable Google Logging. * Whether to internally enable Google Logging.
* This option is only applicable if Caffe is used. * This option is only applicable if Caffe is used.
...@@ -198,7 +212,8 @@ namespace op ...@@ -198,7 +212,8 @@ namespace op
const std::string& modelFolder = "models/", const std::vector<HeatMapType>& heatMapTypes = {}, const std::string& modelFolder = "models/", const std::vector<HeatMapType>& heatMapTypes = {},
const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false, const ScaleMode heatMapScale = ScaleMode::ZeroToOne, const bool addPartCandidates = false,
const float renderThreshold = 0.05f, const int numberPeopleMax = -1, const bool maximizePositives = false, const float renderThreshold = 0.05f, const int numberPeopleMax = -1, const bool maximizePositives = false,
const double fpsMax = -1., const bool enableGoogleLogging = true); const double fpsMax = -1., const std::string& protoTxtPath = "",
const std::string& caffeModelPath = "", const bool enableGoogleLogging = true);
}; };
} }
......
...@@ -32,6 +32,8 @@ namespace op ...@@ -32,6 +32,8 @@ namespace op
const PoseModel mPoseModel; const PoseModel mPoseModel;
const int mGpuId; const int mGpuId;
const std::string mModelFolder; const std::string mModelFolder;
const std::string mProtoTxtPath;
const std::string mCaffeModelPath;
const bool mEnableGoogleLogging; const bool mEnableGoogleLogging;
// General parameters // General parameters
std::vector<std::shared_ptr<Net>> spNets; std::vector<std::shared_ptr<Net>> spNets;
...@@ -47,11 +49,15 @@ namespace op ...@@ -47,11 +49,15 @@ namespace op
std::shared_ptr<caffe::Blob<float>> spPeaksBlob; std::shared_ptr<caffe::Blob<float>> spPeaksBlob;
std::shared_ptr<caffe::Blob<float>> spMaximumPeaksBlob; std::shared_ptr<caffe::Blob<float>> spMaximumPeaksBlob;
ImplPoseExtractorCaffe(const PoseModel poseModel, const int gpuId, ImplPoseExtractorCaffe(
const std::string& modelFolder, const bool enableGoogleLogging) : const PoseModel poseModel, const int gpuId, const std::string& modelFolder,
const std::string& protoTxtPath, const std::string& caffeModelPath,
const bool enableGoogleLogging) :
mPoseModel{poseModel}, mPoseModel{poseModel},
mGpuId{gpuId}, mGpuId{gpuId},
mModelFolder{modelFolder}, mModelFolder{modelFolder},
mProtoTxtPath{protoTxtPath},
mCaffeModelPath{caffeModelPath},
mEnableGoogleLogging{enableGoogleLogging}, mEnableGoogleLogging{enableGoogleLogging},
spResizeAndMergeCaffe{std::make_shared<ResizeAndMergeCaffe<float>>()}, spResizeAndMergeCaffe{std::make_shared<ResizeAndMergeCaffe<float>>()},
spNmsCaffe{std::make_shared<NmsCaffe<float>>()}, spNmsCaffe{std::make_shared<NmsCaffe<float>>()},
...@@ -119,23 +125,24 @@ namespace op ...@@ -119,23 +125,24 @@ namespace op
} }
} }
void addCaffeNetOnThread(std::vector<std::shared_ptr<Net>>& net, void addCaffeNetOnThread(
std::vector<boost::shared_ptr<caffe::Blob<float>>>& caffeNetOutputBlob, std::vector<std::shared_ptr<Net>>& net,
const PoseModel poseModel, const int gpuId, std::vector<boost::shared_ptr<caffe::Blob<float>>>& caffeNetOutputBlob,
const std::string& modelFolder, const bool enableGoogleLogging) const PoseModel poseModel, const int gpuId, const std::string& modelFolder,
const std::string& protoTxtPath, const std::string& caffeModelPath, const bool enableGoogleLogging)
{ {
try try
{ {
// Add Caffe Net // Add Caffe Net
net.emplace_back( net.emplace_back(
std::make_shared<NetCaffe>( std::make_shared<NetCaffe>(
modelFolder + getPoseProtoTxt(poseModel), modelFolder + (protoTxtPath.empty() ? getPoseProtoTxt(poseModel) : protoTxtPath),
modelFolder + getPoseTrainedModel(poseModel), modelFolder + (caffeModelPath.empty() ? getPoseTrainedModel(poseModel) : caffeModelPath),
gpuId, enableGoogleLogging)); gpuId, enableGoogleLogging));
// net.emplace_back( // net.emplace_back(
// std::make_shared<NetOpenCv>( // std::make_shared<NetOpenCv>(
// modelFolder + getPoseProtoTxt(poseModel), // modelFolder + (protoTxtPath.empty() ? getPoseProtoTxt(poseModel) : protoTxtPath),
// modelFolder + getPoseTrainedModel(poseModel), // modelFolder + (caffeModelPath.empty() ? getPoseTrainedModel(poseModel) : caffeModelPath),
// gpuId)); // gpuId));
// UNUSED(enableGoogleLogging); // UNUSED(enableGoogleLogging);
// Initializing them on the thread // Initializing them on the thread
...@@ -157,13 +164,15 @@ namespace op ...@@ -157,13 +164,15 @@ namespace op
} }
#endif #endif
PoseExtractorCaffe::PoseExtractorCaffe(const PoseModel poseModel, const std::string& modelFolder, PoseExtractorCaffe::PoseExtractorCaffe(
const int gpuId, const std::vector<HeatMapType>& heatMapTypes, const PoseModel poseModel, const std::string& modelFolder, const int gpuId,
const ScaleMode heatMapScale, const bool addPartCandidates, const std::vector<HeatMapType>& heatMapTypes, const ScaleMode heatMapScale, const bool addPartCandidates,
const bool maximizePositives, const bool enableGoogleLogging) : const bool maximizePositives, const std::string& protoTxtPath, const std::string& caffeModelPath,
const bool enableGoogleLogging) :
PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates, maximizePositives} PoseExtractorNet{poseModel, heatMapTypes, heatMapScale, addPartCandidates, maximizePositives}
#ifdef USE_CAFFE #ifdef USE_CAFFE
, upImpl{new ImplPoseExtractorCaffe{poseModel, gpuId, modelFolder, enableGoogleLogging}} , upImpl{new ImplPoseExtractorCaffe{poseModel, gpuId, modelFolder, protoTxtPath, caffeModelPath,
enableGoogleLogging}}
#endif #endif
{ {
try try
...@@ -201,8 +210,9 @@ namespace op ...@@ -201,8 +210,9 @@ namespace op
// Logging // Logging
log("Starting initialization on thread.", Priority::Low, __LINE__, __FUNCTION__, __FILE__); log("Starting initialization on thread.", Priority::Low, __LINE__, __FUNCTION__, __FILE__);
// Initialize Caffe net // Initialize Caffe net
addCaffeNetOnThread(upImpl->spNets, upImpl->spCaffeNetOutputBlobs, upImpl->mPoseModel, addCaffeNetOnThread(
upImpl->mGpuId, upImpl->mModelFolder, upImpl->mEnableGoogleLogging); upImpl->spNets, upImpl->spCaffeNetOutputBlobs, upImpl->mPoseModel, upImpl->mGpuId,
upImpl->mModelFolder, upImpl->mProtoTxtPath, upImpl->mCaffeModelPath, upImpl->mEnableGoogleLogging);
#ifdef USE_CUDA #ifdef USE_CUDA
cudaCheck(__LINE__, __FUNCTION__, __FILE__); cudaCheck(__LINE__, __FUNCTION__, __FILE__);
#endif #endif
...@@ -245,8 +255,9 @@ namespace op ...@@ -245,8 +255,9 @@ namespace op
const auto numberScales = inputNetData.size(); const auto numberScales = inputNetData.size();
upImpl->mNetInput4DSizes.resize(numberScales); upImpl->mNetInput4DSizes.resize(numberScales);
while (upImpl->spNets.size() < numberScales) while (upImpl->spNets.size() < numberScales)
addCaffeNetOnThread(upImpl->spNets, upImpl->spCaffeNetOutputBlobs, upImpl->mPoseModel, addCaffeNetOnThread(
upImpl->mGpuId, upImpl->mModelFolder, false); upImpl->spNets, upImpl->spCaffeNetOutputBlobs, upImpl->mPoseModel, upImpl->mGpuId,
upImpl->mModelFolder, upImpl->mProtoTxtPath, upImpl->mCaffeModelPath, false);
// Process each image // Process each image
for (auto i = 0u ; i < inputNetData.size(); i++) for (auto i = 0u ; i < inputNetData.size(); i++)
......
...@@ -10,7 +10,7 @@ namespace op ...@@ -10,7 +10,7 @@ namespace op
const int defaultPartToRender_, const std::string& modelFolder_, const std::vector<HeatMapType>& heatMapTypes_, const int defaultPartToRender_, const std::string& modelFolder_, const std::vector<HeatMapType>& heatMapTypes_,
const ScaleMode heatMapScale_, const bool addPartCandidates_, const float renderThreshold_, const ScaleMode heatMapScale_, const bool addPartCandidates_, const float renderThreshold_,
const int numberPeopleMax_, const bool maximizePositives_, const double fpsMax_, const int numberPeopleMax_, const bool maximizePositives_, const double fpsMax_,
const bool enableGoogleLogging_) : const std::string& protoTxtPath_, const std::string& caffeModelPath_, const bool enableGoogleLogging_) :
enable{enable_}, enable{enable_},
netInputSize{netInputSize_}, netInputSize{netInputSize_},
outputSize{outputSize_}, outputSize{outputSize_},
...@@ -33,6 +33,8 @@ namespace op ...@@ -33,6 +33,8 @@ namespace op
numberPeopleMax{numberPeopleMax_}, numberPeopleMax{numberPeopleMax_},
maximizePositives{maximizePositives_}, maximizePositives{maximizePositives_},
fpsMax{fpsMax_}, fpsMax{fpsMax_},
protoTxtPath{protoTxtPath_},
caffeModelPath{caffeModelPath_},
enableGoogleLogging{enableGoogleLogging_} enableGoogleLogging{enableGoogleLogging_}
{ {
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册