The original detectImage function may result in confusing output when not all keypoints are detected, like the following picture:
Such confusing output was reported as a bug in issue #115
Here is how this problem was caused: in the original detectImage function, keypoints that were not detected will be assigned a random coordinate, as follows:
As a result, we see undetected keypoints scattered randomly on the image, and the detected pose is confusing.
I made some change to fix this. Specifically, the position of each undetected keypoint will be determined by its adjacent detected keypoints, rather than being randomly determined. This will improve the detection results.
// bfs propagate
while(li.some(([x,y])=>x===-1&&y===-1)){
for(i=0;i<li.length;i++){
if(li[i][0]===-1){
continue;
}
for(j=0;j<li.length;j++){
if(li[j][0]===-1 && kp_connect(i,j)){
x = li[i][0] + default_relative_keypoints[i][j][0]
y = li[i][1] + default_relative_keypoints[i][j][1]
x = Math.min(Math.max(x, 0), openpose_editor_canvas.width);
y = Math.min(Math.max(y, 0), openpose_editor_canvas.height);
li[j] = [x,y];
}
}
}
}
For more information, please see the code difference in the pull request.
Here is the detection result using the new code, it's much less confusing:
In a word, this pull request improved the detectImage function to avoid confusing output. Please consider accept it.
The original detectImage function may result in confusing output when not all keypoints are detected, like the following picture:
Such confusing output was reported as a bug in issue #115
Here is how this problem was caused: in the original detectImage function, keypoints that were not detected will be assigned a random coordinate, as follows:
As a result, we see undetected keypoints scattered randomly on the image, and the detected pose is confusing.
I made some change to fix this. Specifically, the position of each undetected keypoint will be determined by its adjacent detected keypoints, rather than being randomly determined. This will improve the detection results.
For more information, please see the code difference in the pull request.
Here is the detection result using the new code, it's much less confusing:
In a word, this pull request improved the detectImage function to avoid confusing output. Please consider accept it.