提交 616ba21d 编写于 作者: G gineshidalgo99

Coco JSON extractor now working any coco folder

上级 d0cdf447
...@@ -85,13 +85,17 @@ OpenPose Library - Release Notes ...@@ -85,13 +85,17 @@ OpenPose Library - Release Notes
## Current version (future OpenPose 1.0.2) ## Current version (future OpenPose 1.0.2)
1. Main improvements: 1. Main improvements:
1. Caffe turned into DLL library. 1. Added OpenCV 3.3 compatibility.
2. OpenPose is now completely portable across Windows 10 computers (with Nvidia graphic card). 2. Caffe turned into DLL library.
3. Added OpenPose 1.0.1 portable demo. 3. OpenPose is now completely portable across Windows 10 computers (with Nvidia graphic card).
4. Removed Python and some unnecessary boost dependencies on the VS project. 4. Added OpenPose 1.0.1 portable demo.
5. Replaced all double quotes by angle brackets in include statements (issue #61). 5. Removed Python and some unnecessary boost dependencies on the VS project.
6. Added 3-D reconstruction demo. 6. Replaced all double quotes by angle brackets in include statements (issue #61).
7. Auto-detection of the camera index. 7. Added 3-D reconstruction demo.
8. Auto-detection of the camera index.
9. Speed up of ~30% in op::floatPtrToUCharCvMat.
10. COCO extractor now extracts image ID from the image name itslef (format "string_%d"). Before, only working with validation test, now applicable to e.g. test sets.
11. Changed display texts, added `OpenPose` name.
2. Main bugs fixed: 2. Main bugs fixed:
1. Pycaffe can now be imported from Python. 1. Pycaffe can now be imported from Python.
2. Fixed `Tutorial/Wrapper` VS linking errors. 2. Fixed `Tutorial/Wrapper` VS linking errors.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_coco_json ../evaluation/coco/results/openpose/1_3.json --no_display --render_pose 0 --scale_number 3 --scale_gap 0.25 --frame_last 3558 # ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_coco_json ../evaluation/coco/results/openpose/1_3.json --no_display --render_pose 0 --scale_number 3 --scale_gap 0.25 --frame_last 3558
# # 4 scales # # 4 scales
# ./build/examples/openpose/openpose.bin --num_gpu 1 --image_dir "/home/gines/devel/images/val2014" --write_coco_json ../evaluation/coco/results/openpose/1_4.json --no_display --render_pose 0 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558 # ./build/examples/openpose/openpose.bin --num_gpu 1 --image_dir "/home/gines/devel/images/val2014" --write_coco_json ../evaluation/coco/results/openpose/1_4.json --no_display --render_pose 0 --num_gpu 1 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558
# Debugging - Rendered frames saved # Debugging - Rendered frames saved
# ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_images ../evaluation/coco/results/openpose/frameOutput --no_display # ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_images ../evaluation/coco/results/openpose/frameOutput --no_display
...@@ -20,7 +20,7 @@ namespace op ...@@ -20,7 +20,7 @@ namespace op
~CocoJsonSaver(); ~CocoJsonSaver();
void record(const Array<float>& poseKeypoints, const unsigned long long imageId); void record(const Array<float>& poseKeypoints, const std::string& imageName);
private: private:
JsonOfstream mJsonOfstream; JsonOfstream mJsonOfstream;
......
...@@ -60,11 +60,7 @@ namespace op ...@@ -60,11 +60,7 @@ namespace op
// T* to T // T* to T
const auto& tDatum = tDatums->at(0); const auto& tDatum = tDatums->at(0);
// Record json in COCO format // Record json in COCO format
const std::string stringToRemove = "COCO_val2014_"; spCocoJsonSaver->record(tDatum.poseKeypoints, tDatum.name);
const auto stringToRemoveEnd = tDatum.name.find(stringToRemove) + stringToRemove.size();
const auto imageId = std::stoull(tDatum.name.substr(stringToRemoveEnd, tDatum.name.size() - stringToRemoveEnd));
// Record json in COCO format if file within desired range of images
spCocoJsonSaver->record(tDatum.poseKeypoints, imageId);
// Profiling speed // Profiling speed
Profiler::timerEnd(profilerKey); Profiler::timerEnd(profilerKey);
Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__, Profiler::DEFAULT_X); Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__, Profiler::DEFAULT_X);
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
namespace op namespace op
{ {
OP_API unsigned long long getLastNumber(const std::string& string);
/** /**
* This template function turns an integer number into a fixed-length std::string. * This template function turns an integer number into a fixed-length std::string.
* @param number T integer corresponding to the integer to be formatted. * @param number T integer corresponding to the integer to be formatted.
......
#include <openpose/utilities/string.hpp>
#include <openpose/filestream/cocoJsonSaver.hpp> #include <openpose/filestream/cocoJsonSaver.hpp>
namespace op namespace op
...@@ -27,12 +28,13 @@ namespace op ...@@ -27,12 +28,13 @@ namespace op
} }
} }
void CocoJsonSaver::record(const Array<float>& poseKeypoints, const unsigned long long imageId) void CocoJsonSaver::record(const Array<float>& poseKeypoints, const std::string& imageName)
{ {
try try
{ {
const auto numberPeople = poseKeypoints.getSize(0); const auto numberPeople = poseKeypoints.getSize(0);
const auto numberBodyParts = poseKeypoints.getSize(1); const auto numberBodyParts = poseKeypoints.getSize(1);
const auto imageId = getLastNumber(imageName);
for (auto person = 0 ; person < numberPeople ; person++) for (auto person = 0 ; person < numberPeople ; person++)
{ {
// Comma at any moment but first element // Comma at any moment but first element
......
...@@ -3,6 +3,20 @@ ...@@ -3,6 +3,20 @@
namespace op namespace op
{ {
unsigned long long getLastNumber(const std::string& string)
{
try
{
const auto stringNumber = string.substr(string.find_last_not_of("0123456789") + 1);
return std::stoull(stringNumber);
}
catch (const std::exception& e)
{
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
return 0ull;
}
}
template<typename T> template<typename T>
std::string toFixedLengthString(const T number, const unsigned long long stringLength) std::string toFixedLengthString(const T number, const unsigned long long stringLength)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册