Update to 2.0.0 tree from current Fremantle build
[opencv] / tests / swig_python / highgui / cvQueryFrame.py
1 #! /usr/bin/env python
2 """
3 This script will test highgui's cvQueryFrame() function
4 """
5
6 # name of this test and it's requirements
7 TESTNAME = "cvQueryFrame"
8 REQUIRED = ["cvGrabFrame","cvRetrieveFrame"]
9
10  
11 # needed for sys.exit(int) and .works file handling
12 import os
13 import sys
14 import works
15
16 # path to imagefiles we need
17 PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/")
18
19 # check requirements and delete old flag file, if it exists
20 if not works.check_files(REQUIRED,TESTNAME):
21         sys.exit(77)
22
23 # import the necessary things for OpenCV
24 from highgui import *
25 from cv import *
26
27
28 # create a video reader using the tiny video 'uncompressed.avi'
29 video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
30
31 # call cvQueryFrame for 30 frames and check if the returned image is ok
32 for k in range(0,30):
33         image = cvQueryFrame( video )
34
35         if image is None:
36         # returned image is not a correct IplImage (pointer),
37         # so return an error code
38                 sys.exit(77)
39
40 # ATTENTION: We do not release the video reader, window or any image.
41 # This is bad manners, but Python and OpenCV don't care...
42         
43 # create flag file for sollowing tests
44 works.set_file(TESTNAME)
45
46 # return 0 ('PASS')
47 sys.exit(0)