Skip to content

Commit 59ae459

Browse files
Slightly improved accuracy with ear-shoulder connection
1 parent 37b1dc5 commit 59ae459

File tree

3 files changed

+37
-28
lines changed

3 files changed

+37
-28
lines changed

doc/release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,6 @@ OpenPose Library - Release Notes
106106
1. Main improvements:
107107
1. Added how to use keypoint data in `examples/tutorial_wrapper/`.
108108
2. Added flag for warnings of type `-Wsign-compare` and removed in code.
109+
3. Slightly improved accuracy by considering ears-shoulder connection (e.g. 0.4 mAP for 1 scale in validation set).
109110
2. Main bugs fixed:
110111
1. Windows version crashing with std::map copy.
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
22

3+
clear && clear
4+
35
# USAGE EXAMPLE
46
# clear && clear && make all -j24 && bash ./examples/tests/pose_accuracy_coco_test.sh
57

68
# # Go back to main folder
79
# cd ../../
810

11+
912
# Write COCO-format JSON
1013
# Note: `--frame_last 3558` --> total = 3559 frames
1114
# Last id:
1215
# ID 20671 <--> #frames = 1471 --> ~ 1.5 min at 15fps
1316
# ID 50006 <--> #frames = 3559 --> ~ 4 min at 15fps
1417

18+
# Parameters
19+
IMAGE_FOLDER=/home/gines/devel/images/val2014/
20+
$JSON_FOLDER=../evaluation/coco/results/openpose/
21+
OP_BIN=./build/examples/openpose/openpose.bin
22+
1523
# 1 scale
16-
./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_coco_json ../evaluation/coco/results/openpose/1.json --no_display --render_pose 0 --frame_last 3558
24+
$OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_test.json --no_display --render_pose 0 --frame_last 3558
1725

1826
# # 3 scales
19-
# ./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
27+
# $OP_BIN --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_3.json --no_display --render_pose 0 --scale_number 3 --scale_gap 0.25 --frame_last 3558
2028

2129
# # 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 --num_gpu 1 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558
30+
# $OP_BIN --num_gpu 1 --image_dir $IMAGE_FOLDER --write_coco_json ${JSON_FOLDER}1_4.json --no_display --render_pose 0 --num_gpu 1 --scale_number 4 --scale_gap 0.25 --net_resolution "1312x736" --frame_last 3558
2331

2432
# Debugging - Rendered frames saved
25-
# ./build/examples/openpose/openpose.bin --image_dir "/home/gines/devel/images/val2014" --write_images ../evaluation/coco/results/openpose/frameOutput --no_display
33+
# $OP_BIN --image_dir $IMAGE_FOLDER --write_images ${JSON_FOLDER}frameOutput --no_display

src/openpose/pose/bodyPartConnectorBase.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ namespace op
1919
const auto numberBodyPartPairs = bodyPartPairs.size() / 2;
2020

2121
std::vector<std::pair<std::vector<int>, double>> subset; // Vector<int> = Each body part + body parts counter; double = subsetScore
22-
const auto subsetCounterIndex = numberBodyParts+1;
23-
const auto subsetSize = numberBodyParts+2;
22+
const auto subsetCounterIndex = numberBodyParts;
23+
const auto subsetSize = numberBodyParts+1;
2424

2525
const auto peaksOffset = 3*(maxPeaks+1);
2626
const auto heatMapOffset = heatMapSize.area();
@@ -38,7 +38,7 @@ namespace op
3838
if (nA == 0 || nB == 0)
3939
{
4040
// Change w.r.t. other
41-
if (nB != 0)
41+
if (nA == 0) // nB == 0 or not
4242
{
4343
if (poseModel == PoseModel::COCO_18 || poseModel == PoseModel::BODY_18 || poseModel == PoseModel::BODY_22)
4444
{
@@ -79,7 +79,7 @@ namespace op
7979
else
8080
error("Unknown model, cast to int = " + std::to_string((int)poseModel), __LINE__, __FUNCTION__, __FILE__);
8181
}
82-
else if (nA != 0)
82+
else // if (nA != 0 && nB == 0)
8383
{
8484
if (poseModel == PoseModel::COCO_18 || poseModel == PoseModel::BODY_18 || poseModel == PoseModel::BODY_22)
8585
{
@@ -121,7 +121,7 @@ namespace op
121121
error("Unknown model, cast to int = " + std::to_string((int)poseModel), __LINE__, __FUNCTION__, __FILE__);
122122
}
123123
}
124-
else
124+
else // if (nA != 0 && nB != 0)
125125
{
126126
std::vector<std::tuple<double, int, int>> temp;
127127
const auto numInter = 10;
@@ -159,7 +159,7 @@ namespace op
159159
}
160160
}
161161

162-
// parts score + cpnnection score
162+
// parts score + connection score
163163
if (count > interMinAboveThreshold)
164164
temp.emplace_back(std::make_tuple(sum/count, i, j));
165165
}
@@ -213,24 +213,24 @@ namespace op
213213
subset.emplace_back(std::make_pair(rowVector, subsetScore));
214214
}
215215
}
216-
// // Add ears connections (in case person is looking to opposite direction to camera)
217-
// else if (poseModel == PoseModel::COCO_18 && (pairIndex==16 || pairIndex==17))
218-
// {
219-
// for (const auto& connectionKI : connectionK)
220-
// {
221-
// const auto indexA = std::get<0>(connectionKI);
222-
// const auto indexB = std::get<1>(connectionKI);
223-
// for (auto& subsetJ : subset)
224-
// {
225-
// auto& subsetJFirst = subsetJ.first[bodyPartA];
226-
// auto& subsetJFirstPlus1 = subsetJFirst[bodyPartB];
227-
// if (subsetJFirst == indexA && subsetJFirstPlus1 == 0)
228-
// subsetJFirstPlus1 = indexB;
229-
// else if (subsetJFirstPlus1 == indexB && subsetJFirst == 0)
230-
// subsetJFirst = indexA;
231-
// }
232-
// }
233-
// }
216+
// Add ears connections (in case person is looking to opposite direction to camera)
217+
else if (poseModel == PoseModel::COCO_18 && (pairIndex==17 || pairIndex==18))
218+
{
219+
for (const auto& connectionKI : connectionK)
220+
{
221+
const auto indexA = std::get<0>(connectionKI);
222+
const auto indexB = std::get<1>(connectionKI);
223+
for (auto& subsetJ : subset)
224+
{
225+
auto& subsetJFirst = subsetJ.first[bodyPartA];
226+
auto& subsetJFirstPlus1 = subsetJ.first[bodyPartB];
227+
if (subsetJFirst == indexA && subsetJFirstPlus1 == 0)
228+
subsetJFirstPlus1 = indexB;
229+
else if (subsetJFirstPlus1 == indexB && subsetJFirst == 0)
230+
subsetJFirst = indexA;
231+
}
232+
}
233+
}
234234
else
235235
{
236236
if (!connectionK.empty())

0 commit comments

Comments
 (0)