MultiHand-Tracking icon indicating copy to clipboard operation
MultiHand-Tracking copied to clipboard

Mistake in transforming 3D coordinates from cropped image to original image

Open jianweif opened this issue 3 years ago • 0 comments

Hi, thanks for the great work! I would like to point out a small mistake in MultiHandTracker3D.

In multi_hand_tracker.py, line 884-889, it's transforming 2D coordinates from cropped image back to original image with 2D similarity transform Minv. However, here the z coordinates are still in cropped image and not transformed.

            kp_orig_0 = (self._pad1(joints[:,:2]) @ Minv.T)[:,:2]
            kp_orig_0 -= pad[::-1]
            
            # Add back the 3D data
            kp_orig = joints[:,:]
            kp_orig[:,:2] = kp_orig_0[:,:2]

The z coordinates need to be scaled as well, so I did the following:

            kp_orig_0 = (self._pad1(joints[:,:2]) @ Minv.T)[:,:2]
            kp_orig_0 -= pad[::-1]

            scale = np.linalg.norm(Minv[0, :2])

            # Add back the 3D data
            kp_orig = joints[:,:]
            kp_orig[:,:2] = kp_orig_0[:,:2]
            # also scale the z coordinates
            kp_orig[:, 2] *= scale

Thanks!

jianweif avatar Nov 02 '20 19:11 jianweif