diff --git a/examples/openpose/openpose.cpp b/examples/openpose/openpose.cpp index ec6304c3947e2e94ddb73706e8eb93f1d25ebc33..8cf7539d49ac286ae48ee37ba8a1932ecf8b0cb7 100755 --- a/examples/openpose/openpose.cpp +++ b/examples/openpose/openpose.cpp @@ -19,7 +19,12 @@ #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include // std::this_thread // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/openpose/openposeBasicDemo.cpp b/examples/openpose/openposeBasicDemo.cpp index bbe6a010a2e72a08ba89c3884284a400a02277c8..9868b18b10f2593e60360e67169c9d9b22777f6c 100644 --- a/examples/openpose/openposeBasicDemo.cpp +++ b/examples/openpose/openposeBasicDemo.cpp @@ -3,7 +3,12 @@ #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include // std::this_thread // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies diff --git a/examples/tests/handFromJsonTest.cpp b/examples/tests/handFromJsonTest.cpp index b24590c73ab1e8e8c5738be0ac281c59b9725772..1595e577802de9a8f706f8569c408f5d1e0df20d 100644 --- a/examples/tests/handFromJsonTest.cpp +++ b/examples/tests/handFromJsonTest.cpp @@ -2,7 +2,12 @@ // Example to test hands accuracy given ground-truth bounding boxes. #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging #include #include "wrapperHandFromJsonTest.hpp" diff --git a/examples/tutorial_pose/1_extract_from_image.cpp b/examples/tutorial_pose/1_extract_from_image.cpp index 15313190de5b8ec366f691f2a3dbe6b3f6113fa9..2d0959d5c901a15910e206197eee4afcf09d08c0 100644 --- a/examples/tutorial_pose/1_extract_from_image.cpp +++ b/examples/tutorial_pose/1_extract_from_image.cpp @@ -9,7 +9,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp b/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp index d9d9e6e2a906544f2fca23e9084229f1f7ee2c3e..4b0a5a06a56c70b7fffc1931a1369add29169d0b 100644 --- a/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp +++ b/examples/tutorial_pose/2_extract_pose_or_heatmat_from_image.cpp @@ -9,7 +9,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_thread/1_openpose_read_and_display.cpp b/examples/tutorial_thread/1_openpose_read_and_display.cpp index 676c0fcbccad31dac01e67ebf4f22990988f4ef6..0ad74c6559f3037d5bf73061d165ed4812f47a87 100644 --- a/examples/tutorial_thread/1_openpose_read_and_display.cpp +++ b/examples/tutorial_thread/1_openpose_read_and_display.cpp @@ -8,7 +8,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_thread/2_user_processing_function.cpp b/examples/tutorial_thread/2_user_processing_function.cpp index 24bf858890a12cc7084027fd5b3809c975f3e9ea..d6a3f0f39fd988769e2e602ad4054b221f929f9d 100644 --- a/examples/tutorial_thread/2_user_processing_function.cpp +++ b/examples/tutorial_thread/2_user_processing_function.cpp @@ -9,7 +9,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_thread/3_user_input_processing_and_output.cpp b/examples/tutorial_thread/3_user_input_processing_and_output.cpp index e8b691534fb318f2aba90cac97c1fc123fe76cd8..4df67d8fb66cb5a18c4f2a1b2777f5bdb373725a 100644 --- a/examples/tutorial_thread/3_user_input_processing_and_output.cpp +++ b/examples/tutorial_thread/3_user_input_processing_and_output.cpp @@ -9,7 +9,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies // Option a) Importing all modules diff --git a/examples/tutorial_thread/4_user_input_processing_output_and_datum.cpp b/examples/tutorial_thread/4_user_input_processing_output_and_datum.cpp index 6659c8dd9bfbfe702fdd73c8a7391ec27fd09db4..a55f4c10d6d7ebc71def51fbf175567b23cdbc19 100644 --- a/examples/tutorial_thread/4_user_input_processing_output_and_datum.cpp +++ b/examples/tutorial_thread/4_user_input_processing_output_and_datum.cpp @@ -9,7 +9,12 @@ // 2. `utilities` module: for the error & logging functions, i.e. op::error & op::log respectively // 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies // Option a) Importing all modules diff --git a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp index 9b1dda9e1fa07f289d59d0429992081eac1b8048..c86058a91c9927226d1fb0726640da61de818072 100644 --- a/examples/tutorial_wrapper/1_user_asynchronous_output.cpp +++ b/examples/tutorial_wrapper/1_user_asynchronous_output.cpp @@ -19,7 +19,12 @@ #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include // std::this_thread // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_wrapper/2_user_synchronous.cpp b/examples/tutorial_wrapper/2_user_synchronous.cpp index 78af7c9f29e939593bef172522093e4fe87caf76..da9413591aea143051e85a95ddf680f493082553 100644 --- a/examples/tutorial_wrapper/2_user_synchronous.cpp +++ b/examples/tutorial_wrapper/2_user_synchronous.cpp @@ -19,7 +19,12 @@ #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include // std::this_thread // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples/tutorial_wrapper/3_user_asynchronous.cpp b/examples/tutorial_wrapper/3_user_asynchronous.cpp index 4d862964d190e7236940401e8e4d7815d193ade3..d51cb9d23d84d4823a9cf49de9237ecc5b1c4901 100644 --- a/examples/tutorial_wrapper/3_user_asynchronous.cpp +++ b/examples/tutorial_wrapper/3_user_asynchronous.cpp @@ -19,7 +19,12 @@ #include // `std::chrono::` functions and classes, e.g. std::chrono::milliseconds #include // std::this_thread // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies #include diff --git a/examples_beta/openpose3d/openpose3d.cpp b/examples_beta/openpose3d/openpose3d.cpp index 535fc2268367f1e049a4b133a263bbf5083dc13d..7f5567fe570ab5648328d221f27bd23bc76d7f1f 100644 --- a/examples_beta/openpose3d/openpose3d.cpp +++ b/examples_beta/openpose3d/openpose3d.cpp @@ -19,7 +19,12 @@ #include // std::this_thread #include // Other 3rdparty dependencies -#include // DEFINE_bool, DEFINE_int32, DEFINE_int64, DEFINE_uint64, DEFINE_double, DEFINE_string +// GFlags: DEFINE_bool, _int32, _int64, _uint64, _double, _string +#include +// Allow Google Flags in Ubuntu 14 +#ifndef GFLAGS_GFLAGS_H_ + namespace gflags = google; +#endif #include // google::InitGoogleLogging // OpenPose dependencies diff --git a/include/openpose/utilities/fileSystem.hpp b/include/openpose/utilities/fileSystem.hpp index 2a585f320854945874f24f2d9e80855f1bc8c7d1..3e8cf4cde58aae9778ee7c7474706ff118f9d145 100644 --- a/include/openpose/utilities/fileSystem.hpp +++ b/include/openpose/utilities/fileSystem.hpp @@ -7,7 +7,9 @@ namespace op { OP_API void mkdir(const std::string& directoryPath); - OP_API bool exist(const std::string& directoryPath); + OP_API bool existDir(const std::string& directoryPath); + + OP_API bool existFile(const std::string& filePath); OP_API bool isDirectory(const std::string& directoryPath); diff --git a/src/openpose/core/netCaffe.cpp b/src/openpose/core/netCaffe.cpp index ac8c99818f71c6e2b2b96ff47c805c71d1272091..f6cdb11722d2970f4da4dba0ec710e6e1f4a26f0 100644 --- a/src/openpose/core/netCaffe.cpp +++ b/src/openpose/core/netCaffe.cpp @@ -3,6 +3,7 @@ #include #endif #include +#include #include namespace op @@ -32,6 +33,14 @@ namespace op mCaffeTrainedModel{caffeTrainedModel}, mLastBlobName{lastBlobName} { + const std::string message{".\nPossible causes:\n\t1. Not downloading the OpenPose trained models." + "\n\t2. Not running OpenPose from the same directory where the `model`" + " folder is located.\n\t3. Using paths with spaces."}; + if (!existFile(mCaffeProto)) + error("Prototxt file not found: " + mCaffeProto + message, __LINE__, __FUNCTION__, __FILE__); + if (!existFile(mCaffeTrainedModel)) + error("Caffe trained model file not found: " + mCaffeTrainedModel + message, + __LINE__, __FUNCTION__, __FILE__); } #endif }; diff --git a/src/openpose/utilities/fileSystem.cpp b/src/openpose/utilities/fileSystem.cpp index 67a02ba34b3b321c2e5797307f2dbe97e5837600..d1f62a49bdafbd0e791f8f81bbb5d58b909bc76f 100644 --- a/src/openpose/utilities/fileSystem.cpp +++ b/src/openpose/utilities/fileSystem.cpp @@ -1,7 +1,8 @@ +#include // fopen #include #include -#include #include +#include namespace op { @@ -23,10 +24,11 @@ namespace op } } - bool exist(const std::string& directoryPath) + bool existDir(const std::string& directoryPath) { try { + // Maybe existFile also works for directories in Ubuntu/Windows/Mac? return boost::filesystem::exists(directoryPath); } catch (const std::exception& e) @@ -36,6 +38,25 @@ namespace op } } + bool existFile(const std::string& filePath) + { + try + { + if (auto* file = fopen(filePath.c_str(), "r")) + { + fclose(file); + return true; + } + else + return false; + } + catch (const std::exception& e) + { + error(e.what(), __LINE__, __FUNCTION__, __FILE__); + return false; + } + } + bool isDirectory(const std::string& directoryPath) { try @@ -153,7 +174,7 @@ namespace op try { // Check folder exits - if (!exist(directoryPath)) + if (!existDir(directoryPath)) error("Folder " + directoryPath + " does not exist.", __LINE__, __FUNCTION__, __FILE__); // Read images std::vector filePaths;