Update to 2.0.0 tree from current Fremantle build
[opencv] / tests / swig_python / highgui / cvGrabFrame.py
1 #! /usr/bin/env python
2 """
3 This script will test highgui's video reading functionality
4 """
5
6 # name of this test and it's requirements
7 TESTNAME = "cvGrabFrame"
8 REQUIRED = ["cvCreateFileCaptureRGBA"]
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
20 # check requirements and delete old flag file, if it exists
21 if not works.check_files(REQUIRED,TESTNAME):
22         sys.exit(77)
23
24 # import the necessary things for OpenCV
25 from highgui import *
26 from cv import *
27
28
29 # create a video reader using the tiny video 'uncompressed.avi'
30 video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
31
32 # call cvGrabFrame to grab a frame and save return value
33 res = cvGrabFrame(video)
34
35 if res==0:
36         print "(ERROR) Couldn't call cvGrabFrame()."
37         sys.exit(1)
38
39 # ATTENTION: We do not release the video reader, window or any image.
40 # This is bad manners, but Python and OpenCV don't care...
41         
42 # create flag file for sollowing tests
43 works.set_file(TESTNAME)
44
45 # return 0 ('PASS')
46 sys.exit(0)