2

The setMin and setMax methods of the pcl::CropBox filter each take an Eigen::Vector4f as a parameter.

Why 4f and not 3f? What's the fourth dimension for?

Alex
  • 3,316
  • 4
  • 26
  • 52

1 Answers1

5

What's the Vector4F for?

The Vector4f corresponds to the homogeneous coordinate. For example, (3, 4, 5, 1) and (6, 8, 10, 2) is the same point in homogeneous coordinates system. You can normalize(a, b, c, d) to (a/d, b/d, c/d, 1) in this case.

Easy answer is: Just set the last digit to 1

Why PCL CropBox needs Vector4f?

It's because PCL CropBox can handle any box transformation via setTransform

Transformation matrix usually contains a 4x4 matrix, example shown below where r is a 3x3 rotation matrix and t is a 3-d vector

[[r0, r1, r2, t0],
 [r3, r4, r5, t1],
 [r6, r7, r8, t2],
 [ 0,  0,  0,  1]]

It's just easier to matrix multiply a homogeneous coordinate (1x4) vector with (4x4) matrix.

Feel free to ask more question, as I can update this answer.

Ardiya
  • 677
  • 6
  • 19
  • Great answer, thanks a lot! I guess it would be more convenient for the user if there was an overload where the method just converted a Vector3f to homogeneous coordinates internally, but this clarifies it! – Alex Apr 02 '20 at 08:43
  • 1
    I just checked CropBox's source code and it does not seem to use the fourth coordinates, so it seems that it assumes normalized coordinates (i.e. fourth element equal to 1). – Gabriel Devillers Aug 13 '20 at 07:18
  • As PCL has updated the website, I think the link for **`setTransform`** needs to be updated. The updated on is this: https://pointclouds.org/documentation/classpcl_1_1_crop_box_3_01pcl_1_1_p_c_l_point_cloud2_01_4.html#a32a787e9470224662c400c3a10d877de right? – Milan Sep 15 '20 at 21:24
  • I have other queries as well: (1) I have been trying to understand how `setTransform` work but so far haven't got a solid understanding. So, to confirm, when I specify `setMin`, `setMax`, by default, my `cropBox` would be **parallelogram**, right? (2) Through `setRotation` & `setTranslate` I can rotate & translate, respectively, that parallelogram w.r.t. the coordinate system of the point cloud not the coordinate system of cropBox itself, right? But even in this case my parallelogram would remain parallelogram only, right? – Milan Sep 15 '20 at 21:31
  • (3) Through `setTransform` can I transform my parallelogram cropBox to **parallelepiped** cropBox? If yes then how? (4) If yes then I have another doubt: as per the link I mentioned above, " `setTransform` sets a transformation that should be applied to the cloud before filtering." So, it transforms the point cloud not the cropBox, right? – Milan Sep 15 '20 at 21:34
  • If possible, could you & @GabrielDevillers please take a look at my detailed question about these confusions: https://stackoverflow.com/q/63569343/10358768 – Milan Sep 15 '20 at 21:35