Q:

Using a rotation matrix opencv

I have a rotation matrix from the function Core.Rodrigues in opencv. I want to rotate a point located at (0, 0, 1) about the origin by this rotation matrix. How do I do this to get the new location of the point?  
   Mat rmat= new Mat();
   Calib3d.Rodrigues(rvec, rmat); //rvec is the rotation vector from solvepnp
   double[] p= {0, 0, 1};
   Scalar scalar= new Scalar(p);
   Mat point= new Mat(1, 3, CvType.CV_64F, scalar);
   Mat newpoint= new Mat();
   Mat empty= new Mat();
   Core.gemm(point, rmat, 1, empty, 0, newpoint);

newpoint has 0, 0, 0 for the result, when I know that that is wrong
Any help would be appreciated.

A:

The way to rotate a point about the origin is to premultiply it with the rotation matrix.  I am not familiar with Core.gemm.  Here is a more transparent way of doing this.
Mat rmat= new Mat();
Calib3d.Rodrigues(rvec, rmat); //rvec is the rotation vector from solvepnp
Matx33f rotation_matrix = rmat;
Matx31f original_point(0,0,1);
Matx31f rotated_point = rotation_matrix*original_point;

This should be much easier to debug.  Check the values stored in rotation_matrix, make sure they are initialized to reasonable values (the contents of Matx can be seen in debugger).  You can look at the values and do the multiplication yourself to double check if you like.  The process should be entirely transparent. 

