justHelloWorld
justHelloWorld

Reputation: 6828

Homography matrix in Opencv?

In LATCH_match.cpp in opencv_3.1.0 the homography matrix is defined and used as:

Mat homography;
FileStorage fs("../data/H1to3p.xml", FileStorage::READ);
...
fs.getFirstTopLevelNode() >> homography;
...
Mat col = Mat::ones(3, 1, CV_64F);
col.at<double>(0) = matched1[i].pt.x;
col.at<double>(1) = matched1[i].pt.y;
col = homography * col;
...

Why H1to3p.xml is:

<opencv_storage><H13 type_id="opencv-matrix"><rows>3</rows><cols>3</cols><dt>d</dt><data>
    7.6285898e-01  -2.9922929e-01   2.2567123e+02
    3.3443473e-01   1.0143901e+00  -7.6999973e+01
    3.4663091e-04  -1.4364524e-05   1.0000000e+00 </data></H13></opencv_storage>

With which criteria these numbers were chosen? They can be used for any other homography test for filtering keypoints (as in LATCH_match.cpp)?

Upvotes: 1

Views: 2035

Answers (1)

Alessandro Jacopson
Alessandro Jacopson

Reputation: 18613

I assume that your "LATCH_match.cpp in opencv_3.1.0" is https://github.com/Itseez/opencv/blob/3.1.0/samples/cpp/tutorial_code/xfeatures2D/LATCH_match.cpp

In that file, you find:

// If you find this code useful, please add a reference to the following paper in your work:
// Gil Levi and Tal Hassner, "LATCH: Learned Arrangements of Three Patch Codes", arXiv preprint arXiv:1501.03719, 15 Jan. 2015

And so, looking at http://arxiv.org/pdf/1501.03719v1.pdf you will find

For each set, we compare the first image against each of the remaining five and check for correspondences. Performance is measured using the code from [16, 17]1 , which computes recall and 1-precision using known ground truth homographies between the images.

I think that the image ../data/graf1.png is https://github.com/Itseez/opencv/blob/3.1.0/samples/data/graf1.png that I show here:

enter image description here

According to the comment Homography matrix in Opencv? by Catree the original dataset is at http://www.robots.ox.ac.uk/~vgg/research/affine/det_eval_files/graf.tar.gz where it is said that

Homographies between image pairs included.

So I think that the homography stored in file ../data/H1to3p.xml is the homography between image 1 and image 3.

Upvotes: 4

Related Questions