Ask Your Question
3

How to recognize detection fact

asked 2012-08-14 10:19:57 -0600

xsender gravatar image

Hello everyone. I'm new with opencv. I read tutorials and forums, related to opencv, but still have some problem...

My task is to find object on the photo using Keypoint descriptors scheme (Feature Detection/ Descriptor Extraction / Matcher). How can I determine that object is found on the image?

For now, I found method of calculating SVD ratio of singular values of homography. But when the image is rotated close to 180 degrees clockwise it's singular ratio becomes very large. Is there any way to fix this?

Maybe this task has other standard solution?

Thanks in advance!

edit retag flag offensive close merge delete

Comments

1

Hi, can you point the source for that "method of calculating SVD ratio" that you mentioned?

Rui Marques gravatar imageRui Marques ( 2012-08-14 10:55:24 -0600 )edit

SVD::compute(homogramma, w, u, vt);

expr = w.at<double>(0,0) / w.at<double>(0,2);

dt = determinant(homogramma);

homogramma_is_good = abs(dt)<2 && expr<600000;

xsender gravatar imagexsender ( 2012-08-15 03:33:15 -0600 )edit

Sorry, when I said the source I meant, where did you read about it? :)

Rui Marques gravatar imageRui Marques ( 2012-08-16 03:56:51 -0600 )edit
1
1

Hi, your question is a little bit confusing to me.

One way to test if you found the object in a given image is indeed try to extract the homography (using findHomography) and then test its singular values, just like you are doing. Another way is to see if at least you have a minimum number of matches.

If your question is about why the homography is not good after a rotation, please tell us what kind of points are your using (SIFT, SURF, ORB, etc.) and what are the descriptors. Some descriptor are not rotation invariant, so...

gfuhr gravatar imagegfuhr ( 2012-08-16 11:48:17 -0600 )edit

I think i can`t definitely determine if we found image by counting matches. That's why I didn't test it. If you can link me to the good method how it must be done - it would be great. Or maybe you know some other good methods without using homography?

For testing I use two methods: 1) visual: I draw rectangle around matched object and if it's proportions are the same as of source image rectangle - object is found. For drawing I use homography. 2) programmatically: as I described above by checking SVD and determinant.

But when I tested this on rotated image - visual rectangle is good, but program checking fails: determinant is good, but SVD is bad.

For testing I used different descriptors and detectors. For example, ORB + ORB and ORB + FREAK. Problem is found in both variants.

xsender gravatar imagexsender ( 2012-08-17 03:54:11 -0600 )edit

Another problem is to find the limits for SVD and determinant to check the matching. For now I use values, which founded from the set of experiments. Maybe there is some way to get them from object image size/quality or something else?

xsender gravatar imagexsender ( 2012-08-17 03:54:53 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-08-17 09:09:36 -0600

gfuhr gravatar image

Hi again, let me try to complement my answer.

One way to test if you found the object in a given image is indeed try to extract the homography (using findHomography) and then test its singular values, just like mentioned in the source you gave.

Another way is to see if at least you have a minimum number of matches. You need to specify the threshold yourself experimentally.

A third way to check the quality of the homography if you're working with planar objects (which I am going to assume that you are) is to compute the ZNCC (Zero Normalized Cross Correlation) between the object warped-back to the reference coordinate frame and the model you used. This ZNCC value is going to be very small if the homography is badly estimated. I used this method some time ago and it worked just fine. Also there is a function in OpenCV that you can use to compute that: matchTemplate().

These last two techniques are indeed used here: A realtime tracking system combining template-based and feature-based approaches (2007) - Ladikos et at.

I hope this can help.

edit flag offensive delete link more

Comments

Thank you.

Finally I slightly modify algorithm for homography checking - determinant value must be more then 0.1:

dt = abs(determinant(homogramma));

if(dt < 3 && dt > 0.1){

SVD::compute(homogramma, w);

svd_expr = w.at<double>(0,0) / w.at<double>(0,2);

homogramma_is_good = svd_expr < 1700000;

}

afterall I check correspondence by matchTemplate

Mat tmp_mat(homogramma.inv(DECOMP_SVD));

Mat tmp_img;

Mat compare_res;

warpPerspective(tested_img, tmp_img, tmp_mat, Size(etalon.cols, etalon.rows));

matchTemplate(etalon, tmp_img, compare_res, CV_TM_CCOEFF_NORMED);

xsender gravatar imagexsender ( 2012-08-20 07:58:04 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-08-14 10:19:57 -0600

Seen: 1,722 times

Last updated: Aug 17 '12