microsoft / Deep3DFaceReconstruction

Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set (CVPRW 2019)
MIT License
2.18k stars 443 forks source link

Why minus 1 when converting image plane coordinates to 3D sapce coordinates? #154

Closed JiSuanJiDaWang closed 3 years ago

JiSuanJiDaWang commented 3 years ago

Hi , I couldn't understand why minus 1 in lm = np.stack([lm[:,0],h0 - 1 - lm[:,1]], axis = 1) in function align_img(img,lm,lm3D). From my points of view, its lm = np.stack([lm[:,0],h0 - lm[:,1]], axis = 1). Thanks.

YuDeng commented 3 years ago

Originally, I used h-1-lm[:,1] to ensure that the point with zero value correspond to the last pixel of the image. However, a more accurate way should neither be h-1-lm[:,1] nor h-lm[:,1], but h-0.5-lm[:,1]. Let's just consider the pixel (0,0) on the image. It is actually a box of length 1 which centered at (0.5,h-0.5). Therefore, we should really use h-0.5-lm[:,1] to transfer between landmark coordinates and pixel coordinates.