3 This script will test highgui's image saving functionality
6 # name if this test and it's requirements
7 TESTNAME = "cvSaveImage"
8 REQUIRED = ["cvLoadImagejpg"]
10 #needed for sys.exit(int), filehandling and .works file checks
15 # path to imagefiles we need
16 PREFIX=os.environ["top_srcdir"]+"/tests/python/testdata/images/"
18 # delete old .works file and check requirements
19 if not works.check_files(REQUIRED,TESTNAME):
22 # import the necessary things for OpenCV
24 from python.highgui import *
25 from python.cv import *
27 # our temporary test file
28 file_name = "./highgui_testfile.bmp"
30 # try to load an image from a file
31 image = cvLoadImage(PREFIX+"baboon.jpg")
33 # if the returned object is not Null, loading was successful.
35 print "(INFO) Couldn't load test image. Skipping rest of this test."
38 res = cvSaveImage("./highgui_testfile.bmp", image)
41 print "(ERROR) Couldn't save image to '"+file_name+"'."
44 # remove temporary file
48 works.set_file(TESTNAME)