Reputation: 1056
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.
Upvotes: 2
Views: 16598
Reputation: 136
H is a matrix. In the first case, H is the identity matrix [[1,0,0],[0,1,0],[0,0,1]. That is, no change.
In the second case, it seems you just made a translation 241 in x, and 277 in y. But there is no representation in x and y, since (H=[[a,0,241],[0,b,277],[0,0,1]]) 'a' and 'b' are zero. Something should have gone wrong.
Upvotes: 2
Reputation: 2106
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.
Upvotes: 3