Healthcare-Robotics / BodyPressure

Inferring Body Pose and Contact Pressure from a Depth Image
Other
28 stars 4 forks source link

Pressure Map Generation #14

Closed Tandon-A closed 11 months ago

Tandon-A commented 1 year ago

Hello Henry,

I am trying to understand the process of mapping pressure image back to vertex coordinates, but stuck a bit.

  1. Getting index coordinates on the pressure map for a SMPL mesh vertex (L211-212 in lib_pyrender_depth)
  2. Check Vertex method in lib_pyrender_functions

I understand the usage of both methods, but I am failing to develop an intuition of the steps inside of check_vertex method, and how you get the color_idx_y, color_idx_x.

henryclever commented 1 year ago

color_idx_y, color_idx_x are the pressure map index where a smpl vertex is directly above. In L209 in lib pyrender depth it loops through all verts of the SMPL - so 68902 or sth if i'm not mistaken. It's multiplied by 2 to create a triangle face for each side of the mesh - recall that a triangle created by the indices to 3 vertices can be in the order [0, 1, 2] or [0, 2, 1] for example, which alters which side that the triangle appear on. This also affects geometry computations, so if you want to make sure* you see the triangle, you need both.

For each vertex in (6890 * 2) it finds the pressure image taxel index underneath that vertex. I think I called it the "color" index because I used this for colorizing the human mesh based on the pressure. not a great convention but oh well.

check_vertex does a bunch of vectorized geometry computations .. and similar to raytracing. it could be done in a for loop but this makes it quicker.

tr_ck_arr[:, 0] contains repeats of the x coordinates of the vertex you are trying to trace. tr_ck_arr[:, 1] contains repeats of the y coordinates of the vertex you are trying to trace. tr_ck_arr[:, 2:8] represent the x,y, of all other vertices in the mesh indexed by the faces.

The rest up to 13 are vectorized geometry ops.

num_passing_faces_before_overlap3 i believe is the number of triangles that a ray passes through, when pointed upward from a particular pressure image location (i.e. pressure mat vertex). If the ray passes through multiple triangles, you need to cancel the pressure on all of them except for the one that is nearest to the pressure image vertex. For example if you had a pressure mat vertex that was directly below both the torso and a hand on top of the torso it would pass through 4 triangle surfaces. Only one of those -- the one underneath the torso -- should be assigned a pressure. otherwise, "cancel_point" is set to True.

Does this make sense?