X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=tests%2Fswig_python%2Fhighgui%2FcvSaveImage.py;fp=tests%2Fswig_python%2Fhighgui%2FcvSaveImage.py;h=c12cb94ab95d24b0b20ee21f8003889e57633910;hb=e4c14cdbdf2fe805e79cd96ded236f57e7b89060;hp=0000000000000000000000000000000000000000;hpb=454138ff8a20f6edb9b65a910101403d8b520643;p=opencv diff --git a/tests/swig_python/highgui/cvSaveImage.py b/tests/swig_python/highgui/cvSaveImage.py new file mode 100755 index 0000000..c12cb94 --- /dev/null +++ b/tests/swig_python/highgui/cvSaveImage.py @@ -0,0 +1,50 @@ +#! /usr/bin/env python +""" +This script will test highgui's image saving functionality +""" + +# name if this test and it's requirements +TESTNAME = "cvSaveImage" +REQUIRED = ["cvLoadImagejpg"] + +#needed for sys.exit(int), filehandling and .works file checks +import os +import sys +import works + +# path to imagefiles we need +PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/") + +# delete old .works file and check requirements +if not works.check_files(REQUIRED,TESTNAME): + sys.exit(77) + +# import the necessary things for OpenCV +from highgui import * +from cv import * + +# our temporary test file +file_name = "./highgui_testfile.bmp" + +# try to load an image from a file +image = cvLoadImage(PREFIX+"baboon.jpg") + +# if the returned object is not Null, loading was successful. +if image==0: + print "(INFO) Couldn't load test image. Skipping rest of this test." + sys.exit(77) + +res = cvSaveImage("./highgui_testfile.bmp", image) + +if res == 0: + print "(ERROR) Couldn't save image to '"+file_name+"'." + sys.exit(1) + +# remove temporary file +os.remove(file_name) + +# create flag file +works.set_file(TESTNAME) + +# return 0 ('PASS') +sys.exit(0)