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.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
18 # delete old .works file and check requirements
19 if not works.check_files(REQUIRED,TESTNAME):
22 # import the necessary things for OpenCV
26 # our temporary test file
27 file_name = "./highgui_testfile.bmp"
29 # try to load an image from a file
30 image = cvLoadImage(PREFIX+"baboon.jpg")
32 # if the returned object is not Null, loading was successful.
34 print "(INFO) Couldn't load test image. Skipping rest of this test."
37 res = cvSaveImage("./highgui_testfile.bmp", image)
40 print "(ERROR) Couldn't save image to '"+file_name+"'."
43 # remove temporary file
47 works.set_file(TESTNAME)