Update the changelog
[opencv] / tests / python / highgui / query_test.py
1 """
2 This script will test highgui's cvQueryFrame() function
3 for different video formats
4 """
5
6 # import the necessary things for OpenCV and comparson routine
7 import os
8 import python
9 from python.highgui import *
10 from python.cv import *
11 import match
12
13 # path to videos and images we need
14 PREFIX=os.environ["top_srcdir"]+"/tests/python/testdata/"
15
16 # this is the folder with the videos and images
17 # and name of output window
18 IMAGES          = PREFIX+"images/"
19 VIDEOS          = PREFIX+"videos/"
20
21 # testing routine, called for each entry in FILENAMES
22 # and compares each frame with corresponding frame in COMPARISON
23 def query_ok(FILENAME,ERRORS):
24
25     # create a video reader using the tiny videofile VIDEOS+FILENAME
26     video=cvCreateFileCapture(VIDEOS+FILENAME)
27
28     if video is None:
29         # couldn't open video (FAIL)
30         return 1
31
32     # call cvQueryFrame for 29 frames and check if the returned image is ok
33     for k in range(29):
34         image=cvQueryFrame(video)
35
36         if image is None:
37         # returned image is NULL (FAIL)
38                 return 1
39
40         if not match.match(image,k,ERRORS[k]):
41                 return 1
42         
43     cvReleaseCapture(video)
44     # everything is fine (PASS)
45     return 0