2 This script will compare tho images and decides with a threshold
3 if these to images are "equal enough"
6 # import the necessary things for OpenCV
8 from python.cv import *
9 from python.highgui import *
14 PREFIX=os.environ["top_srcdir"]+"/tests/python/testdata/images/"
21 referencewindow="reference"
22 cvNamedWindow(videowindow,CV_WINDOW_AUTOSIZE)
23 cvNamedWindow(referencewindow,CV_WINDOW_AUTOSIZE)
25 # returns True/False if match/non-match
26 def match( image, index, thres ):
28 # load image from comparison set
29 QCIFcompare=cvLoadImage(PREFIX+frames.QCIF[index])
31 if QCIFcompare is None:
32 print "Couldn't open image "+PREFIX+frames.QCIF[index]+" for comparison!"
35 # resize comparison image to input image dimensions
36 size=cvSize(image.width,image.height)
37 compare=cvCreateImage(size,IPL_DEPTH_8U,image.nChannels)
38 cvResize(QCIFcompare,compare)
41 diff=cvNorm( image, compare, CV_RELATIVE_L2 )
44 cvShowImage(videowindow,image)
45 cvShowImage(referencewindow,compare)
49 print "index==",index,": max==",thres," is==",diff
52 cvReleaseImage(QCIFcompare)
53 cvReleaseImage(compare)