Update to 2.0.0 tree from current Fremantle build
[opencv] / tests / swig_python / highgui / cvLoadImage.py
1 """
2 This script will test highgui's image loading functionality
3 for a given parameter of a file extension.
4 """
5
6
7 # needed for sys.exit(int) and .works file handling
8 import os
9 import sys
10 import works
11 from works import *
12
13 #import the necessary things for OpenCV
14 from highgui import *
15 from cv import *
16
17
18 # some defines
19 TESTNAME = "cvLoadImage"
20 REQUIRED = []
21
22 # path to imagefiles we need
23 PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/baboon_256x256")
24
25
26 # this functions tries to open an imagefile
27 # using the filename PREFIX.EXTENSION  and returns True/False 
28 # on success/fail.
29
30 def image_ok( EXTENSION ):
31         
32         # check requirements and delete old .works file
33         WORKSNAME = TESTNAME+'.'+EXTENSION
34
35         if not works.check_files( REQUIRED, WORKSNAME ):
36                 print "worksfile "+WORKSNAME+" not found."
37                 return False
38         
39         image = cvLoadImage(PREFIX+'.'+EXTENSION)
40
41         if image is None:
42                 return False
43         else:
44                 works.set_file( TESTNAME+EXTENSION )
45                 return True