Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

Opencv4android mask for matchTemplate()

$
0
0
Hi. I'm trying to speed up matchTemplate() for Android. I have already downsampled the image and template to half the original size, but the matching is still somewhat (understandably) slow on some older devices. I acknowledged that I can pass in a mask to the matchTemplate() method. I'm trying to utilize this in the following way: 1) I know the location of the object from the previous frame, lets say its (180, 30). 2) I want to search only around some specified distance around this point, rather than the whole frame. 3) I create a region of interest based on this distance. My question is, how can I utilize this roi such that I can take the current image being searched, and set everything outside the ROI to 0? I can then pass this in as a mask, and thus matchTemplate() would only search the image where pixel values are not 0 (so everything in the ROI)? I have something such as the following: cameraFrameROI = new Rect(topLeftX, topLeftY, width, height); Mat mask = new Mat(mCameraMatResized); // mask = 0 if not part of ROI, otherwise keep original value Imgproc.matchTemplate(new Mat(mCameraMatResized, cameraFrameROI), mTemplateMatResized, mResult, mMatchMethod); But I now need to utilize the ROI to create the actual mask. Would this speed up template matching, and if so, I'm hoping if anyone can provide pointers. Thanks.

Viewing all articles
Browse latest Browse all 19555

Trending Articles