OpenCV C++ - findHomography values meaning

lilouch picture lilouch · Jul 8, 2014 · Viewed 14k times · Source

I've already check on stackOverflaw and especially in this link but it didn't answer to my question.

I compute an homography using Ransac with OpenCv in order to match two pictures. Here the code corresponding :

Mat H = findHomography( obj, scene, CV_RANSAC,3);

std::cout << "Size of homography " << *H.size << std::endl ;

//Print homography
for (int i=0;i<H.rows;i++){
    for (int j=0;j<H.cols;j++){

        std::cout << "valeur H : "  << (int)H.at<double>(i,j) << endl;
    }
}
int N=1;
const double det = H.at<double>(0, 0) * H.at<double>(1, 1) - H.at<double>(1, 0) * H.at<double>(0, 1);
std::cout << "Determinant homography : " << det << std::endl;

For a good match (exactly the same picture), i have on my terminal this :

Size of homography 3

valeur H : 1

valeur H : 0

valeur H : 0

valeur H : 0

valeur H : 1

valeur H : 0

valeur H : 0

valeur H : 0

valeur H : 1

Determinant homography : 1

For a bad match (two differents pictures),i have this :

Size of homography 3

valeur H : 0

valeur H : 0

valeur H : 241

valeur H : 0

valeur H : 0

valeur H : 277

valeur H : 0

valeur H : 0

valeur H : 1

Determinant homography : 0.00533235

I don't understand this result. Can someone explain me ? I would like to use these values to determine if this a good match or not. I expected to have only 1 in the first case but not.

I think,I'm using Homography and Ransaw without really understand. I've checked on the internet but it's complicated so if you have also good explanation, i take it.

Thank.

Answer

Nallath picture Nallath · Jul 8, 2014

Acording to the openCV documentation, the findHomography 'Finds a perspective transformation between two planes'. This means that it's able to compute the perspective transformation of two images (of the same (calibration) board) taken from different positions.

If you are comparing two completely different sets of image points, it will not be able to find such a transformation.