Update the changelog
[opencv] / tests / python / highgui / size_test.py
1 """
2 This script will test HighGUI's cvGetCaptureProperty functionality
3 for correct returnvalues of width and height information 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
11
12 # path to images and videos  we need
13 PREFIX          =os.environ["top_srcdir"]+"/tests/python/testdata/"
14
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
22 # testing routine, seeks through file and compares read images with frames in COMPARISON
23 def size_ok(FILENAME):
24   # create a video reader using the tiny videofile VIDEOS+FILENAME
25   video=cvCreateFileCapture(VIDEOS+FILENAME)
26
27   if video is None:
28     # couldn't open video (FAIL)
29     return 1
30
31   # get width and height information via HighGUI's cvGetCaptureProperty function
32   w=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_WIDTH)
33   h=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_HEIGHT)
34
35   # get an image to compare
36   image=cvQueryFrame(video)
37
38   if (w!=image.width) or (h!=image.height):
39     # dimensions don't match parameters (FAIL)
40     return 1
41
42   del video
43   del image
44   # everything is fine (PASS)
45   return 0
46
47