tags:

views:

618

answers:

1

Hi, I am working on a project to capture images via webcam in a predefined time interval, and continuously compare the images to a template (good image) and give an error if the difference is > tolerance set.

I working out using OpenCV. Would like to have advice how should I do it, e.g. best method, etc.

Appreciate if any one can help me on this. Thanks.

+1  A: 

An easy way is to just take the L2-norm between the image pairs:

double l2_norm = cvNorm( img1, img2 );

You'll have to experiment with setting the appropriate threshold. Of course this method is not robust to lighting changes, viewpoint changes, etc but its simple and fast.

jeff7
Hi, I manage to get my project up, utilizing the ROI selected via mouse drag as the template for matching with the continuous running video frames. I would like to ask, how do I output the template matching result, e.g. if template found --> functionA(), if template not found --> functionB().Appreciate if some one can enlighten me on this matter. Thanks in advance!
YS
You need to use cvMatchTemplate() to compare the template against your image and then look in the result image for the min or max location and value (depending if you match based on mse or correlation). You'll need to set a threshold on this value to determine which patch your alogirthm follows next.
jeff7