alexsax / 2D-3D-Semantics

The data skeleton from Joint 2D-3D-Semantic Data for Indoor Scene Understanding
http://3dsemantics.stanford.edu
Apache License 2.0
464 stars 67 forks source link

Cannot align back projected points using given poses. #42

Open otakuxiang opened 2 years ago

otakuxiang commented 2 years ago

I have read #16 and follow the equation x = ARAx' + c, but I still can't align point clouds to exr points. Here is my code

#back projection
    depth = depth / 512
    n,m = np.meshgrid(np.arange(depth.shape[0]),np.arange(depth.shape[1]))
    n = n.reshape(-1)
    m = m.reshape(-1)
    v = (n + 0.5) / depth.shape[0]
    u = (m + 0.5) / depth.shape[1]
    phi = (u - 0.5) * (2 * math.pi)
    cita = (0.5 - v) * math.pi 
    x = np.cos(cita) * np.cos(phi)
    y = np.cos(cita) * np.sin(phi)
    z = np.sin(cita)
    ray = np.stack([x,y,z],axis = 1)
    points = ray * depth[n,m].reshape(-1,1)

And my transformation code:

    pose = json.load(f)
    R = pose["camera_rt_matrix"]
    loc = pose["camera_location"]
    A = np.array(pose["camera_original_rotation"])
    A = A / 180 * math.pi
    A = get_rot_from_xyz(A[0],A[1],A[2])
    R = np.array(R)[0:3,0:3]
    loc = np.array(loc).reshape(1,3)
    fr = np.matmul(np.matmul(A,R),A)
    points = points.transpose(1,0)
    points = np.dot(fr,points).transpose(1,0) + loc

Is there any mistake?

otakuxiang commented 2 years ago

@anita94 How did you align point clouds? Could you please share your code if possible? Thanks a lot.

HalvesChen commented 1 year ago

@otakuxiang Hellow! I have a same problem. How did you solve it? Could you please share your code if possible? Thanks a lot.

xuxiaoxxxx commented 10 months ago

@otakuxiang Hellow! I have a same problem. How did you solve it? Could you please share your code if possible? Thanks a lot.

Do you slove this problem?

Arno-Tu commented 2 months ago

hi otakuxiang,I just discovered that the x-coordinate and y-coordinate are reversed when regenerating a point cloud from a given panoramic depth image using your code. This causes the generated point cloud to appear as a mirror image of the original point cloud, I'm not sure if this is the reason why you can't align the generated point cloud with the original, I'll make some more attempts.

HalvesChen commented 2 months ago

@Arno-Tu Others have solved similar problems, refer to the link.