Ask Your Question
0

How to decompose homography transformation matrix in opencv

asked 2016-10-19 02:00:37 -0500

Hello, I have found feature points detection and matching using SURF and based on homography transformation matrix. Now, I want to decompose homography transformation matrix to retrieve rotation and translation parameters. I have tried in opencv2.4.9 and all higher version. there is function for decomposePerspectiveMat but not for homography transformation matrix. This function is available for opencv3.0 and higher version. But before to use this function, I have to find feature points using SURF and xfeature2d as per documentation is required. But when we installed opencv3.1.0, then no file available like xfeature2d.hpp.

Can you please help to decompose homgraphy transformation matrix?

Thank you,

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2016-10-19 17:50:52 -0500

Tetragramm gravatar image

updated 2016-10-19 17:53:21 -0500

In any 3.X version: decomposeHomographyMat

And the SURF methods are still in xfeatures2d, in the contrib modules.

edit flag offensive delete link more
0

answered 2016-11-05 04:08:10 -0500

Hello, decomposeHomographyMat is stored in OpenCv's source/modules/calib3d/src file.

When I use in my .cpp file using preprocessing directives in #include to use decomposeHomographyMat, I got errors

Error 1 error C1189: #error : this is a private header which should not be used from outside of the OpenCV library D:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 48 1 OM_Opencv_3_1 2 IntelliSense: #error directive: this is a private header which should not be used from outside of the OpenCV library d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 48 4 OM_Opencv_3_1 3 IntelliSense: cannot open source file "ipp.h" d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 194 1 OM_Opencv_3_1 4 IntelliSense: identifier "IppiSize" is undefined d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 212 15 OM_Opencv_3_1 5 IntelliSense: identifier "IppiSize" is undefined d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 218 15 OM_Opencv_3_1 6 IntelliSense: identifier "IppiBorderType" is undefined d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 224 15 OM_Opencv_3_1 7 IntelliSense: identifier "IppDataType" is undefined d:\Darshana\Opencv_3_1_0\opencv\build\include\opencv2\core\private.hpp 233 15 OM_Opencv_3_1

Can you please help me to resolve these errors?

Thank you,

edit flag offensive delete link more

Comments

what header files are you trying to include ?

berak gravatar imageberak ( 2016-11-05 04:28:14 -0500 )edit

I am using header files as

include <stdio.h>

include<math.h>

include <iostream>

include<fstream>

include "opencv2/core.hpp"

include "opencv2/imgproc.hpp"

include "opencv2/features2d.hpp"

include "opencv2/highgui.hpp"

include "opencv2/calib3d.hpp"

//#include "D:/Darshana/Opencv_3_1_0/opencv/sources/modules/calib3d/src/precomp.hpp"

include "D:/Darshana/Opencv_3_1_0/opencv/sources/modules/calib3d/src/homography_decomp.cpp"

include <memory>

darshana.mistry gravatar imagedarshana.mistry ( 2016-11-05 04:44:31 -0500 )edit

well, you must not use anything from the src/modules folder, they're for internal use only. (please remove them from your program)

#include "opencv2/calib3d.hpp"

is the one you need here.

berak gravatar imageberak ( 2016-11-05 04:54:50 -0500 )edit

Thank you for valuable suggestions. Now my file is build but I got run time exception.

decomposeHomographyMat() return integer value. But when I use in my program as int nsols; nsols=cv::decomposeHomographyMat(H, camera_int_parameters, Rs, Ts, noArray()); cout << "Total solutions are as " << nsols << endl;

I got unhandled exception at run time.

Can you please help me for this?

Thank you.

darshana.mistry gravatar imagedarshana.mistry ( 2016-11-05 05:04:16 -0500 )edit

Can I change src folder's any file of Opencv?

darshana.mistry gravatar imagedarshana.mistry ( 2016-11-05 06:11:12 -0500 )edit

you need: vector<Mat> Rs, Ts; (not a simple Mat) here.

berak gravatar imageberak ( 2016-11-05 06:22:01 -0500 )edit

Yes. it works. Now I want to display Rs and Ts. I have tried to display as vector. But it is not working. Do you know how to display vector<mat> value? Thank you,

darshana.mistry gravatar imagedarshana.mistry ( 2016-11-05 06:49:33 -0500 )edit

make a loop, and cout << Rs[i] << endl;

berak gravatar imageberak ( 2016-11-05 08:12:44 -0500 )edit

Thank you for your great support. Do you know using decomposeHomographyMat() function display 4 different rotation matrix and translation vector? Why? Which we consider for our hands on. Thank you.

darshana.mistry gravatar imagedarshana.mistry ( 2016-11-05 12:50:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-10-19 02:00:37 -0500

Seen: 1,927 times

Last updated: Nov 05 '16