WarpAffine for 3D

Hello All,

  1. I am looking for “getRotationMatrix3D” function in cpp implementation to utilize it for 3D rotation although 2D is available but 3D is not visible.
  2. Kindly confirm if WarpAffine for 3D rotation is available or not in cpp.

no, none of it is builtin.

what are you trying to do, exactly ?

use Rodrigues to convert between a “rotation vector” (length encodes angle) and a 3x3 rotation matrix.

a 3D affine transformation is a 4x4 matrix that has no projective component (4th row is exactly [0,0,0,1]). you can build such matrices yourself.

warpAffine is an operation on raster images. the 3D equivalent would have to work on voxel data.

if you just want to apply a transformation to 3D points, there’s OpenCV: Operations on arrays docs aren’t clear on whether it is expected to support 4x4 transformation matrices. my bet it that it does.

Thanks Crackwitz,

I will explore more on your suggestion. Can you help me with remaining elements of the matrix for 3D rotation?
Thanks in advance.

Hi @Gorakh22

There is a getRotationMatrix2D because images are 2D. By going into 3D world from images, you rising the complexity of the problem, so there is no getRotationMatrix3D, there are many non trivial geometric ways to get it instead, and they depend on context.

It will help us to help you help everyone if you provide some images of what you are trying to achieve.

For example, in the particular case of a rotated plane with texture, you can use homography, aka perspective transformation, like in this tutorial (on this link fist go to the bottom and see the videos).