OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Sun, 29 Mar 2020 06:33:36 -0500Inverse Matrix from a Decomposehomographyhttp://answers.opencv.org/question/228224/inverse-matrix-from-a-decomposehomography/I need to obtain the inverse of a rotation matrix I get from decomposehomography() but I'm having some trouble as it looks like the type of the matrix I obtain from that function does not seem to work with .inv(). Here's an example where Prev_rot_matrix is another matrix
int solutions = decomposeHomographyMat(H, cameraMatrix, Rs_decomp, ts_decomp, normals_decomp);
for (int i = 0; i < solutions; i++)
{
if(normals_decomp[i].at<double>(2)>0)
{
aux=FrameVar(Rs_decomp[i], Prev_rot_matrix); /*Prev_rot_matrix has the same structure as Rs_decomp[i]*/
if(aux<Var)
{
Var=aux;
SOL=i;
}
}
}
double FrameVar(Mat Rot_Curr, Mat Rot_Prev)
{
//Previous rotation: Rot_Prev ;
current rotation: Rot_Curr
double NewAngle, OldAngle, aux;
Mat Rot_Curr_vect, Rot_Prev_vect;
Mat VarAngle(cv::Size(1,1), CV_64FC1);
Rodrigues(Rot_Curr, Rot_Curr_vect);
Rot_Prev_vect=Rot_Prev.inv()*Rodrigues(Rot_Prev, Rot_Prev_vect);
...
So when I try to compile it I get:
> ‘cv::MatExpr’ is not derived from
> ‘const cv::Affine3<T>’
> Rot_Prev_vect=Rot_Prev.inv()*Rodrigues(Rot_Prev,
> Rot_Prev_vect);
and a bunch of other errors.
In case that that meant Rot_Prev class does not have .inv(), how can I obtain its inverse matrix? I want to get the previous rotation vector in the new frame coordinatesAquasSun, 29 Mar 2020 06:33:36 -0500http://answers.opencv.org/question/228224/Meaning of rectified beforePoints for filterHomographyDecompByVisibleRefpoints()http://answers.opencv.org/question/228027/meaning-of-rectified-beforepoints-for-filterhomographydecompbyvisiblerefpoints/Hello,
The filterHomographyDecompByVisibleRefpoints() doc reference says:
"beforePoints Vector of (rectified) visible reference points before the homography is applied".
Can someone explain what rectified means if the homography is not applied?
Is it to multiply by the inverse of the camera intrinsic matrix?
Thanks in advance!snowmaniaWed, 25 Mar 2020 06:10:20 -0500http://answers.opencv.org/question/228027/decomposeHomographyMat isn't workinghttp://answers.opencv.org/question/210199/decomposehomographymat-isnt-working/ I used findHomography, then:
int solutions = decomposeHomographyMat (H, K, R, T, N);
But this doesn't work properly. Rotation matrix has only "-nan" values. Homography martix is ok. It has values like:
> 2.44486e-39, 0.0466184, 1.25152e+23
I've tried to use unit matrix instead of homography, but it also didn't work.viohhWed, 13 Mar 2019 03:20:44 -0500http://answers.opencv.org/question/210199/How to find rotation angle from homography matrix?http://answers.opencv.org/question/203890/how-to-find-rotation-angle-from-homography-matrix/I have 2 images and i am finding simliar key points by SURF.
I want to find rotation angle between the two images from homograpohy matrix.
Can someone please tell me how to find rotation angle between two images from homography matrix.
if len(good)>MIN_MATCH_COUNT:
src_pts = np.float32([ kp1[m.queryIdx].pt for m in good ]).reshape(-1,1,2)
dst_pts = np.float32([ kp2[m.trainIdx].pt for m in good ]).reshape(-1,1,2)
M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
Thank you.ronak.dedhiaThu, 22 Nov 2018 23:30:21 -0600http://answers.opencv.org/question/203890/homography vs SolvePNP for pose detection, how and why?http://answers.opencv.org/question/201340/homography-vs-solvepnp-for-pose-detection-how-and-why/I have mutiple planar markers where I can detect 100-200 points each in a reliable manner.
In each frame I see one or two markers at most; I need to calculate the camera pose.
I am not sure whether I should use solvePNP or findhomography for the pose detection.
1) OpenCV homography page states that solvePnp should be used for planar objects as well, and findhomography is just for demo in terms of pose detection. See https://docs.opencv.org/3.4.1/d9/dab/tutorial_homography.html
On the other hand, solvePNP is using POSIT, right? Which should be less accurate on planar features, please correct me here if the implementation is actually taking care of the planar case. So, should I ever consider findHomography or not for pose estimation?
2) In case findhomography still makes sense, how should I use it? Should I use two frames and feed 2d-2d coordinates to the findhomography, or use the "3d object coordinates without Z" as the source?
Thanks for any hint.
klaymanWed, 17 Oct 2018 11:54:43 -0500http://answers.opencv.org/question/201340/