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
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.