Skip to content

Commit 616ba21

Browse files
Coco JSON extractor now working any coco folder
1 parent d0cdf44 commit 616ba21

File tree

7 files changed

+33
-15
lines changed

7 files changed

+33
-15
lines changed

doc/release_notes.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,17 @@ OpenPose Library - Release Notes
8585

8686
## Current version (future OpenPose 1.0.2)
8787
1. Main improvements:
88-
1. Caffe turned into DLL library.
89-
2. OpenPose is now completely portable across Windows 10 computers (with Nvidia graphic card).
90-
3. Added OpenPose 1.0.1 portable demo.
91-
4. Removed Python and some unnecessary boost dependencies on the VS project.
92-
5. Replaced all double quotes by angle brackets in include statements (issue #61).
93-
6. Added 3-D reconstruction demo.
94-
7. Auto-detection of the camera index.
88+
1. Added OpenCV 3.3 compatibility.
89+
2. Caffe turned into DLL library.
90+
3. OpenPose is now completely portable across Windows 10 computers (with Nvidia graphic card).
91+
4. Added OpenPose 1.0.1 portable demo.
92+
5. Removed Python and some unnecessary boost dependencies on the VS project.
93+
6. Replaced all double quotes by angle brackets in include statements (issue #61).
94+
7. Added 3-D reconstruction demo.
95+
8. Auto-detection of the camera index.
96+
9. Speed up of ~30% in op::floatPtrToUCharCvMat.
97+
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.
98+
11. Changed display texts, added `OpenPose` name.
9599
2. Main bugs fixed:
96100
1. Pycaffe can now be imported from Python.
97101
2. Fixed `Tutorial/Wrapper` VS linking errors.

examples/tests/pose_accuracy_coco_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# ./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
2020

2121
# # 4 scales
22-
# ./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
22+
# ./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
2323

2424
# Debugging - Rendered frames saved
2525
# ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_images ../evaluation/coco/results/openpose/frameOutput --no_display

include/openpose/filestream/cocoJsonSaver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace op
2020

2121
~CocoJsonSaver();
2222

23-
void record(const Array<float>& poseKeypoints, const unsigned long long imageId);
23+
void record(const Array<float>& poseKeypoints, const std::string& imageName);
2424

2525
private:
2626
JsonOfstream mJsonOfstream;

include/openpose/filestream/wCocoJsonSaver.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ namespace op
6060
// T* to T
6161
const auto& tDatum = tDatums->at(0);
6262
// Record json in COCO format
63-
const std::string stringToRemove = "COCO_val2014_";
64-
const auto stringToRemoveEnd = tDatum.name.find(stringToRemove) + stringToRemove.size();
65-
const auto imageId = std::stoull(tDatum.name.substr(stringToRemoveEnd, tDatum.name.size() - stringToRemoveEnd));
66-
// Record json in COCO format if file within desired range of images
67-
spCocoJsonSaver->record(tDatum.poseKeypoints, imageId);
63+
spCocoJsonSaver->record(tDatum.poseKeypoints, tDatum.name);
6864
// Profiling speed
6965
Profiler::timerEnd(profilerKey);
7066
Profiler::printAveragedTimeMsOnIterationX(profilerKey, __LINE__, __FUNCTION__, __FILE__, Profiler::DEFAULT_X);

include/openpose/utilities/string.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace op
77
{
8+
OP_API unsigned long long getLastNumber(const std::string& string);
9+
810
/**
911
* This template function turns an integer number into a fixed-length std::string.
1012
* @param number T integer corresponding to the integer to be formatted.

src/openpose/filestream/cocoJsonSaver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <openpose/utilities/string.hpp>
12
#include <openpose/filestream/cocoJsonSaver.hpp>
23

34
namespace op
@@ -27,12 +28,13 @@ namespace op
2728
}
2829
}
2930

30-
void CocoJsonSaver::record(const Array<float>& poseKeypoints, const unsigned long long imageId)
31+
void CocoJsonSaver::record(const Array<float>& poseKeypoints, const std::string& imageName)
3132
{
3233
try
3334
{
3435
const auto numberPeople = poseKeypoints.getSize(0);
3536
const auto numberBodyParts = poseKeypoints.getSize(1);
37+
const auto imageId = getLastNumber(imageName);
3638
for (auto person = 0 ; person < numberPeople ; person++)
3739
{
3840
// Comma at any moment but first element

src/openpose/utilities/string.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33

44
namespace op
55
{
6+
unsigned long long getLastNumber(const std::string& string)
7+
{
8+
try
9+
{
10+
const auto stringNumber = string.substr(string.find_last_not_of("0123456789") + 1);
11+
return std::stoull(stringNumber);
12+
}
13+
catch (const std::exception& e)
14+
{
15+
error(e.what(), __LINE__, __FUNCTION__, __FILE__);
16+
return 0ull;
17+
}
18+
}
19+
620
template<typename T>
721
std::string toFixedLengthString(const T number, const unsigned long long stringLength)
822
{

0 commit comments

Comments
 (0)