Move the sources to trunk
[opencv] / tests / 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.environ["top_srcdir"]+"/tests/python/testdata/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 import python
26 from python.highgui import *
27 from python.cv import *
28
29
30 # create a video reader using the tiny video 'uncompressed.avi'
31 video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
32
33 # call cvGrabFrame to grab a frame and save return value
34 res = cvGrabFrame(video)
35
36 if res==0:
37         print "(ERROR) Couldn't call cvGrabFrame()."
38         sys.exit(1)
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)