CMU-Perceptual-Computing-Lab / openpose

OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation
https://cmu-perceptual-computing-lab.github.io/openpose
Other
30.76k stars 7.83k forks source link

datum returns 2.0 for all values. #1291

Open kdemon1011 opened 5 years ago

kdemon1011 commented 5 years ago

I ran following code


import sys
import cv2
import os
from sys import platform
import argparse
import time

sys.path.append('/usr/local/python')
from openpose import pyopenpose as op

params = dict()
params["model_folder"] = "/openpose/models/"
params["write_json"] = "/openpose/results/"
params["num_gpu"] = 0

opWrapper = op.WrapperPython()
opWrapper.configure(params)
opWrapper.start()

image_path = "/openpose/examples/media/COCO_val2014_000000000241.jpg"

datum = op.Datum()
imageToProcess = cv2.imread(image_path)
datum.cvInputData = imageToProcess
opWrapper.emplaceAndPop([datum])

print("Body keypoints: \n" + str(datum.poseKeypoints))
print("Face keypoints: \n" + str(datum.faceKeypoints))
print("Left hand keypoints: \n" + str(datum.handKeypoints[0]))
print("Right hand keypoints: \n" + str(datum.handKeypoints[1]))

And in return i am getting following output.

Body keypoints: 
2.0
Face keypoints: 
2.0
Left hand keypoints: 
2.0
Right hand keypoints: 
2.0

What is 2.0. Is there something wrong in the output?

gineshidalgo99 commented 5 years ago

Do not use num_gpu 0, that only disables OpenPose. If you want CPU version, compile OP for CPU-only.

@soulslicer Still, this should not be returning 2.0, but rather empty arrays, something is buggy here.

soulslicer commented 5 years ago

I will be back to my lab to look into this in a week or two, I will get back to you then. But do check our default tutorial and code those definitely work

Rutulpatel7077 commented 5 years ago

One more thing, I saw here

import sys
import cv2
import os
from sys import platform
import argparse
import time

sys.path.append('/usr/local/python')
from openpose import pyopenpose as op

params = dict()
params["model_folder"] = "/openpose/models/"
params["write_json"] = "/openpose/results/"
params["model_pose"] = "COCO"  // when we use COCO

opWrapper = op.WrapperPython()
opWrapper.configure(params)
opWrapper.start()

image_path = "/openpose/examples/media/COCO_val2014_000000000241.jpg"

datum = op.Datum()
imageToProcess = cv2.imread(image_path)
datum.cvInputData = imageToProcess
opWrapper.emplaceAndPop([datum])

print("keypoints: \n" + str(datum.poseKeypoints)) // 1e-45

So, with COCO it returns 1e-45 where as with BODY_25 or by default it works fine.

naknakLEE commented 5 years ago

I have the same problem. When there is no person, the result is 2.0.

ghost commented 4 years ago

Any updates on this issue?

Raven888888 commented 4 years ago

When there is no skeleton detected in a frame, both poseKeypoints and poseScores default to 2.0. When there is skeleton detected in the previous frame (where its poseScore is x), and no skeleton detected in the current frame, both poseKeypoints and poseScores default to x.

Any explanation?

soulslicer commented 4 years ago

Wow that is quite serious. I will look into that issue this weekend. I wasn't able to solve the 2.0 issue, but it seemed minor initially as this is something one can check easily. The issue you mention though seems a little problematic.

Raven888888 commented 4 years ago

Thanks @soulslicer Please keep us posted

soulslicer commented 4 years ago

When there is no skeleton detected in a frame, both poseKeypoints and poseScores default to 2.0. When there is skeleton detected in the previous frame (where its poseScore is x), and no skeleton detected in the current frame, both poseKeypoints and poseScores default to x.

Any explanation?

I was not able to recreate this. Take a look on the 04_keypoints_from_images.py to see how we operate over multiple images. You have to recreate an empty datum each time

soulslicer commented 4 years ago

As for the empty image returning 2.0:

            return array(buffer_info(
                m.getPseudoConstPtr(),/* Pointer to buffer */
                sizeof(float),        /* Size of one scalar */
                format,               /* Python struct-style format descriptor */
                m.getSize().size(),   /* Number of dimensions */
                m.getSize(),          /* Buffer dimensions */
                m.getStride()         /* Strides (in bytes) for each index */
                )).release();

We are calling the above functions when casting to a numpy array. We are returning a size of 0 which should make sense, but it get's casted to 2.0 and not an empty numpy array. Will have to check this further, but for now the easiest fix is to check the shape of the returning object, and if it is empty, we can say that the image doesn't contain people