xingyizhou / DeepModel

Code repository for Model-based Deep Hand Pose Estimation
GNU General Public License v3.0
111 stars 43 forks source link

Visualization in demo.py #10

Closed jakeoung closed 4 years ago

jakeoung commented 7 years ago

Hello, I have a question in demo.py. I saw the following code.

      for j in range(J):
        x[j] = joint[joints[j] * 3]
        y[j] = joint[joints[j] * 3 + 1]   
        z[j] = joint[joints[j] * 3 + 2]
        cv2.circle(img, (int((x[j] + 1) / 2 * 128), int((- y[j] + 1) / 2 * 128)), 2, (255, 0, 0), 2)

After computing the joint in 3D, it seems that we just normalize x,y coordinates to [0,128). I reimplement your code to run pytorch, my output for the ground truth (not my prediction of network) is like this:

image

The joints looks wrong and should be positioned left slightly. I wonder that it is normal or not (due to cropping, reisize and so on..)

xingyizhou commented 7 years ago

Hi jakeoung, Sorry for the late reply. You are right, it is normal. It is because I use a simple version (weak perspective projection) to project the 2D joint for visualization. It should be perspective projection (u[i] ~ x[i] / z[i], v[i] ~ y[i] / z[i]), not (u[i] ~ x[i], v[i] ~ y[i]). If you want to plot the 2D joint strictly, you should also consider the x and y focal length of the camera to convert the xyz space to uvd space (you can refer to the official converting code in NYU hand pose dataset).