Ask Your Question

DrawMatches img2 shows up blank in outImg.

asked 2013-08-29 12:32:52 -0500

updated 2013-08-30 00:47:59 -0500

Moster gravatar image

I have been testing openCV 2.4.6 on iOS and I have come across a strange error.

Whenever I get the output of cv::DrawMatches the key points are matched just fine, but the img2 that I pass in is never drawn. Even though it's key points are matched.

Here is what the input and outputs look like:

img1: image description

img2: image description

outimg: image description

The code that I am using is pulled directly from the Feature Matching Tutorial with just a few iOS specific changes to handle conversion from UIImage to cv::Mat:

Mat img_matches;
drawMatches(trackingImage, trackingImageKeypoints,
            searchFrame, kp,
            good_matches, img_matches);

NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *pngFilePath = [NSString stringWithFormat:@"%@/searchDetectorTest.png",docDir];
NSData *data = [NSData dataWithData:UIImagePNGRepresentation( [UIImage UIImageFromCVMat:img_matches] )];
[data writeToFile:pngFilePath atomically:YES];
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-08-29 13:48:47 -0500

berak gravatar image

looking at the docs it seems you want DRAW_OVER_OUTIMG for the flags value, not the DEFAULT(0)

edit flag offensive delete link more


I found the answer. (But I can't answer my own question until a day passes.)

cv::DrawMatches expects variables img1 and img2 to be a 1 or 3 channel cv:Mat and I was passing img2 in as a 4 channel cv:Mat. I just wish the documentation was more clear about this.

RubenSandwich gravatar imageRubenSandwich ( 2013-08-29 15:01:20 -0500 )edit

Question Tools


Asked: 2013-08-29 12:32:52 -0500

Seen: 498 times

Last updated: Aug 29 '13