patrikhuber / eos

A lightweight 3D Morphable Face Model library in modern C++
Apache License 2.0
1.89k stars 596 forks source link

Wrong modelview when using pip version #219

Open d4nst opened 5 years ago

d4nst commented 5 years ago

I am using eos 3D model to generate 2D depth maps. Initially, I used the python bindings compiled from source and everything worked fine. However, when using the version from pip, there is a problem with the modelview matrix that makes my code not work properly. Below you can see the difference between executing demo.py using the bindings compiled from source and the ones from pip (both of them are version 0.16.1):

patrikhuber commented 5 years ago

Hi, thanks for the report!

I think this needs further investigation. I don't think I currently have time to investigate. Can you just use the source-compiled version in the meantime?

patrikhuber commented 5 years ago

I've had one more person report issues with the projection being wrong in Release builds of the Python bindings. I am marking this as potential bug and will try to find the time to debug.

rstar000 commented 5 years ago

Hi! Maybe i'm a bit late, but it seems like the model-view matrix is actually inverted. This is the result of projecting model-space axes using the returned model-view matrix, but inverted. image

Code for reference:

def project_axis(matrix):   
    axis = np.float32([[500,0,0], 
                          [0,500,0], 
                          [0,0,500]])
    proj_points = matrix[:3,:3].T @ axis
    return proj_points[:3,:2]
patrikhuber commented 5 years ago

Hi @rstar000,

I think this is a different (potential) issue from the one that was originally reported here.

With "inverted", do you mean transposed? I would be quite surprised if the model-view matrix was transposed. Is it possible that you got fooled by the depiction of the three coloured drawn axes? They can often look like they point in the "wrong" direction, our brain's interpretation can fool us when only looking at a static image. I would suggest that you run it on a video where someone turns their head (or e.g. the live cam), it's much easier to see then whether the axes are drawn correctly.

If you still think there is an issue, could you open a separate issue for it to continue the discussion there?

Thanks!

rstar000 commented 5 years ago

@patrikhuber Hey, sorry, I just found a silly bug in my projection code. I was using row vectors instead of column vectors for some reason. The matrix returned from pose.get_modelview() is absolutely correct!

patrikhuber commented 5 years ago

@rstar000 Great! :-)