mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
"atomic bomb" commit. Reorganized OpenCV directory structure
This commit is contained in:
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
import unittest
|
||||
import cvtestutils
|
||||
from cv import *
|
||||
|
||||
class cmp_test(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.w=17
|
||||
self.h=17
|
||||
self.x0 = cvCreateMat(self.w,self.h,CV_32F)
|
||||
self.x1 = cvCreateMat(self.w,self.h,CV_32F)
|
||||
cvSet(self.x0, cvScalarAll(0.0))
|
||||
cvSet(self.x1, cvScalarAll(1.0))
|
||||
def check_format(self, y):
|
||||
assert( y.rows == self.h )
|
||||
assert( y.cols == self.w )
|
||||
assert( CV_MAT_DEPTH(y.type)==CV_8U )
|
||||
def check_allzero(self, y):
|
||||
assert( cvCountNonZero(y)==0 )
|
||||
def check_all255(self, y):
|
||||
nonzero=cvCountNonZero(y)
|
||||
assert( nonzero==self.w*self.h )
|
||||
sum = cvSum(y)[0]
|
||||
assert( sum == self.w*self.h*255 )
|
||||
|
||||
def test_CvMat_gt(self):
|
||||
y=self.x1>0
|
||||
self.check_format( y )
|
||||
self.check_all255( y )
|
||||
y=self.x0>0
|
||||
self.check_format( y )
|
||||
self.check_allzero( y )
|
||||
|
||||
def test_CvMat_gte(self):
|
||||
y=self.x1>=0
|
||||
self.check_format( y )
|
||||
self.check_all255( y )
|
||||
y=self.x0>=0
|
||||
self.check_format( y )
|
||||
self.check_all255( y )
|
||||
|
||||
def test_CvMat_lt(self):
|
||||
y=self.x1<1
|
||||
self.check_format( y )
|
||||
self.check_allzero( y )
|
||||
y=self.x0<1
|
||||
self.check_format( y )
|
||||
self.check_all255( y )
|
||||
|
||||
def test_CvMat_lte(self):
|
||||
y=self.x1<=1
|
||||
self.check_format( y )
|
||||
self.check_all255( y )
|
||||
y=self.x0<=1
|
||||
self.check_format( y )
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(cmp_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
@@ -0,0 +1,81 @@
|
||||
# cvtestutils.py
|
||||
#
|
||||
# This module is meant to aid writing and running Python-based tests
|
||||
# within the OpenCV tree.
|
||||
#
|
||||
# 2009-01-23, Roman Stanchak <rstanchak@gmail.com>
|
||||
#
|
||||
#
|
||||
# Upon importing, this module adds the following python module
|
||||
# directories from the dev tree to sys.path (i.e. PYTHON_PATH):
|
||||
# opencv/interfaces/swig/python and opencv/lib
|
||||
#
|
||||
# Using it in a test case is simple, just be sure to import
|
||||
# cvtestutils before cv, highgui, etc
|
||||
#
|
||||
# Usage:
|
||||
# import cvtestutils
|
||||
# import cv
|
||||
|
||||
import os
|
||||
import imp
|
||||
import sys
|
||||
|
||||
def top_srcdir():
|
||||
"""
|
||||
Return a string containing the top-level source directory in the OpenCV tree
|
||||
"""
|
||||
dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
# top level dir should be two levels up from this file
|
||||
return os.path.realpath( os.path.join( dir, '..', '..' ) )
|
||||
|
||||
def top_builddir():
|
||||
"""
|
||||
Return a string containing the top-level build directory in the OpenCV tree.
|
||||
Either returns realpath(argv[1]) or top_srcdir();
|
||||
"""
|
||||
if len(sys.argv)>1: return os.path.realpath( sys.argv[1] );
|
||||
else: return top_srcdir();
|
||||
|
||||
def initpath():
|
||||
"""
|
||||
Prepend the python module directories from the dev tree to sys.path
|
||||
(i.e. PYTHON_PATH)
|
||||
"""
|
||||
|
||||
# add path for OpenCV source directory (for adapters.py)
|
||||
moduledir = os.path.join(top_srcdir(), 'interfaces','swig','python')
|
||||
moduledir = os.path.realpath(moduledir)
|
||||
sys.path.insert(0, moduledir)
|
||||
|
||||
# add path for OpenCV build directory
|
||||
moduledir = os.path.join(top_builddir(), 'interfaces','swig','python')
|
||||
moduledir = os.path.realpath(moduledir)
|
||||
sys.path.insert(0, moduledir)
|
||||
|
||||
libdir = os.path.join(top_builddir(), 'lib' )
|
||||
libdir = os.path.realpath(libdir)
|
||||
sys.path.insert(0, libdir)
|
||||
|
||||
def which():
|
||||
"""
|
||||
Print the directory containing cv.py
|
||||
"""
|
||||
import cv
|
||||
print "Using OpenCV Python in: " + os.path.dirname(cv.__file__)
|
||||
|
||||
def datadir():
|
||||
"""
|
||||
Return a string containing the full path to the python testdata directory
|
||||
"""
|
||||
return os.path.sep.join([top_srcdir(), '..', 'opencv_extra', 'testdata', 'python'])
|
||||
|
||||
### Module Initialization
|
||||
try:
|
||||
if MODULE_LOADED:
|
||||
pass
|
||||
except NameError:
|
||||
initpath()
|
||||
which()
|
||||
MODULE_LOADED=1
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 2009-01-16, Xavier Delacour <xavier.delacour@gmail.com>
|
||||
|
||||
import unittest
|
||||
from numpy import *;
|
||||
from numpy.linalg import *;
|
||||
import sys;
|
||||
import cvtestutils
|
||||
from cv import *;
|
||||
from adaptors import *;
|
||||
|
||||
def planted_neighbors(query_points, R = .4):
|
||||
n,d = query_points.shape
|
||||
data = zeros(query_points.shape)
|
||||
for i in range(0,n):
|
||||
a = random.rand(d)
|
||||
a = random.rand()*R*a/sqrt(sum(a**2))
|
||||
data[i] = query_points[i] + a
|
||||
return data
|
||||
|
||||
class feature_tree_test(unittest.TestCase):
|
||||
|
||||
def test_kdtree_basic(self):
|
||||
n = 1000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d)*2-1;
|
||||
data = planted_neighbors(query_points)
|
||||
|
||||
tr = cvCreateKDTree(data);
|
||||
indices,dist = cvFindFeatures(tr, query_points, 1, 100);
|
||||
|
||||
correct = sum([i == j for j,i in enumerate(indices)])
|
||||
assert(correct >= n * .75);
|
||||
|
||||
def test_spilltree_basic(self):
|
||||
n = 1000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d)*2-1;
|
||||
data = planted_neighbors(query_points)
|
||||
|
||||
tr = cvCreateSpillTree(data);
|
||||
indices,dist = cvFindFeatures(tr, query_points, 1, 100);
|
||||
|
||||
correct = sum([i == j for j,i in enumerate(indices)])
|
||||
assert(correct >= n * .75);
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(feature_tree_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
suite = suite()
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for a given parameter RAW formats.
|
||||
"""
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
from works import *
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# some defines
|
||||
TESTNAME = "cvCreateFileCapture"
|
||||
REQUIRED = []
|
||||
PREFIX = os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/qcif_")
|
||||
EXTENSION= ".avi"
|
||||
|
||||
|
||||
# this functions tries to open a videofile
|
||||
# using the filename PREFIX+FORMAT+.EXTENSION and returns True/False
|
||||
# on success/fail.
|
||||
|
||||
def video_ok( FORMAT ):
|
||||
|
||||
# check requirements and delete old .works file
|
||||
if not works.check_files( REQUIRED, TESTNAME+FORMAT ):
|
||||
return false
|
||||
|
||||
filename = PREFIX+FORMAT+EXTENSION
|
||||
video = cvCreateFileCapture(PREFIX+FORMAT+EXTENSION)
|
||||
if video is None:
|
||||
sys.exit(1)
|
||||
works.set_file( TESTNAME+FORMAT )
|
||||
return True
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW RGB .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "RGB"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW RGBA (dummy alpha channel) .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "RGBA"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW UYVY .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "UYVY"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW Y8 (luminance only) .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "Y8"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW YUY2 .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "YUY2"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW YV12 .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "YV12"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW YV16 .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "YV16"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
for RAW YVU9 .avi files
|
||||
"""
|
||||
|
||||
# pixel format to check
|
||||
FORMAT = "YVU9"
|
||||
|
||||
# import check routine
|
||||
import cvCreateFileCapture
|
||||
|
||||
# check video file of format FORMAT,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
cvCreateFileCapture.video_ok(FORMAT)
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's trackbar functionality
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "cvCreateTrackbar"
|
||||
REQUIRED = ["cvShowImage"]
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# some definitions
|
||||
win_name = "testing..."
|
||||
bar_name = "brightness"
|
||||
bar_count= 100
|
||||
|
||||
|
||||
# position of imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
|
||||
|
||||
# 'moved' indicates if trackbar has been moved
|
||||
moved = False
|
||||
|
||||
# 'range' indicates if trackbar was outside range [0..bar_count]
|
||||
range = False
|
||||
|
||||
|
||||
# function to call on a trackbar event
|
||||
def trackcall( p ):
|
||||
# Trackbar position must be in [0..bar_count]
|
||||
if (p > bar_count or p < 0):
|
||||
globals()["range"] = True
|
||||
|
||||
cvConvertScale( image, image2,float(p)/float(bar_count) )
|
||||
cvShowImage( win_name, image2 );
|
||||
globals()["moved"] = True
|
||||
|
||||
|
||||
# create output window
|
||||
cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
|
||||
image = cvLoadImage(PREFIX+"cvCreateTrackbar.jpg")
|
||||
image2 = cvLoadImage(PREFIX+"cvCreateTrackbar.jpg")
|
||||
cvShowImage(win_name,image)
|
||||
|
||||
# create the trackbar and save return value
|
||||
res = cvCreateTrackbar( bar_name, win_name, 0, bar_count, trackcall )
|
||||
|
||||
# check return value
|
||||
if res == 0:
|
||||
# something went wrong, so return an error code
|
||||
print "(ERROR) Couldn't create trackbar."
|
||||
sys.exit(1)
|
||||
|
||||
# init. window with image
|
||||
trackcall(bar_count/2)
|
||||
# reset 'moved' indicator
|
||||
moved = False
|
||||
|
||||
# now give the user 20 seconds to do some input
|
||||
print "(INFO) Please move trackbar within the next 20 SECONDS to 'PASS' this test."
|
||||
print "(HINT) You can complete this test prematurely by pressing any key."
|
||||
print "(INFO) In the case of no user input, the test will be remarked as 'FAIL'."
|
||||
|
||||
key = cvWaitKey(20000)
|
||||
|
||||
if range:
|
||||
# trackbar position value was outside allowed range [0..bar_count]
|
||||
print "(ERROR) Trackbar position was outside range."
|
||||
sys.exit(1)
|
||||
|
||||
if not moved and (key==-1):
|
||||
# trackbar has not been moved
|
||||
print "(ERROR) No user input detected."
|
||||
sys.exit(1)
|
||||
elif not moved and (key>0):
|
||||
# 20sec. passed, trackbar has been moved
|
||||
print "(INFO) No trackbar movement detected (but key pressed)."
|
||||
sys.exit(77)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's cvGetCaptureProperty() function
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvGetCaptureProperty"
|
||||
REQUIRED = ["cvCreateFileCapture"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/")
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# create a video reader using the tiny video 'vd_uncompressed.avi'
|
||||
video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
|
||||
|
||||
# retrieve video dimensions and compare with known values
|
||||
print str(cvGetCaptureProperty( video, CV_CAP_PROP_FOURCC ))
|
||||
|
||||
print "Checking image dimensions"
|
||||
if cvGetCaptureProperty( video, CV_CAP_PROP_FRAME_WIDTH ) != 720:
|
||||
sys.exit(1)
|
||||
if cvGetCaptureProperty( video, CV_CAP_PROP_FRAME_HEIGHT ) != 576:
|
||||
sys.exit(1)
|
||||
print "pass"
|
||||
|
||||
print "Checking framerate"
|
||||
if cvGetCaptureProperty( video, CV_CAP_PROP_FPS ) != 25:
|
||||
sys.exit(1)
|
||||
print "pass"
|
||||
|
||||
print str(cvGetCaptureProperty( video, CV_CAP_PROP_FOURCC ) )
|
||||
|
||||
# ATTENTION: We do not release the video reader, window or any image.
|
||||
# This is bad manners, but Python and OpenCV don't care...
|
||||
|
||||
# create flag file for sollowing tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's Get/Set functionality for the trackbar
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvGetSetTrackbarPos"
|
||||
REQUIRED = ["cvCreateTrackbar"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# some definitions
|
||||
win_name = "testing..."
|
||||
bar_name = "foo"
|
||||
|
||||
|
||||
# little dummy function as callback for trackbar
|
||||
def dummy(value):
|
||||
pass
|
||||
|
||||
|
||||
# create output window
|
||||
cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# create our trackbar
|
||||
cvCreateTrackbar( bar_name, win_name, 127, 255, dummy )
|
||||
|
||||
# trackbar pos must be 127
|
||||
if cvGetTrackbarPos( bar_name, win_name ) != 127:
|
||||
print "(ERROR) cvGetTrackbarPos() returned wrong value (!=127)."
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# set the trackbar to new position 255 and compare it
|
||||
cvSetTrackbarPos( bar_name, win_name, 255 )
|
||||
|
||||
if cvGetTrackbarPos( bar_name, win_name ) != 255:
|
||||
print "(ERROR) cvSetTrackbarPos() didn't set value correctly (!=255)."
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 (success)
|
||||
sys.exit(0)
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's window handle/name functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvGetWindowHandleName"
|
||||
REQUIRED = ["cvNamedWindow"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# some definitions
|
||||
win_name = "testing..."
|
||||
|
||||
# create a window ( 'cvNamedWindow.works' says: "Ok, go for it!" )
|
||||
cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# check if the window handle and the according name are correct
|
||||
win_name_2 = cvGetWindowName( cvGetWindowHandle(win_name) )
|
||||
if win_name_2!=win_name:
|
||||
# print "(ERROR) Incorrect window handle/name."
|
||||
sys.exit(1)
|
||||
|
||||
# destroy the window
|
||||
cvDestroyWindow( win_name )
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's video reading functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvGrabFrame"
|
||||
REQUIRED = ["cvCreateFileCaptureRGBA"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/")
|
||||
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# create a video reader using the tiny video 'uncompressed.avi'
|
||||
video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
|
||||
|
||||
# call cvGrabFrame to grab a frame and save return value
|
||||
res = cvGrabFrame(video)
|
||||
|
||||
if res==0:
|
||||
print "(ERROR) Couldn't call cvGrabFrame()."
|
||||
sys.exit(1)
|
||||
|
||||
# ATTENTION: We do not release the video reader, window or any image.
|
||||
# This is bad manners, but Python and OpenCV don't care...
|
||||
|
||||
# create flag file for sollowing tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script will test highgui's InitSystem function
|
||||
ATTENTION: This test doesn't do much, yet, but cvInitSystem
|
||||
is called with default parameters on the first highgui function call anyway.
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvInitSystem"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED, TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
import highgui
|
||||
|
||||
# try to initialize the highgui system
|
||||
# res = highgui.cvInitSystem(globals["0,characs)
|
||||
# if res != 0:
|
||||
# sys.exit(1)
|
||||
|
||||
# create flag file for the following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for a given parameter of a file extension.
|
||||
"""
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
from works import *
|
||||
|
||||
#import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# some defines
|
||||
TESTNAME = "cvLoadImage"
|
||||
REQUIRED = []
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/baboon_256x256")
|
||||
|
||||
|
||||
# this functions tries to open an imagefile
|
||||
# using the filename PREFIX.EXTENSION and returns True/False
|
||||
# on success/fail.
|
||||
|
||||
def image_ok( EXTENSION ):
|
||||
|
||||
# check requirements and delete old .works file
|
||||
WORKSNAME = TESTNAME+'.'+EXTENSION
|
||||
|
||||
if not works.check_files( REQUIRED, WORKSNAME ):
|
||||
print "worksfile "+WORKSNAME+" not found."
|
||||
return False
|
||||
|
||||
image = cvLoadImage(PREFIX+'.'+EXTENSION)
|
||||
|
||||
if image is None:
|
||||
return False
|
||||
else:
|
||||
works.set_file( TESTNAME+EXTENSION )
|
||||
return True
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .bmp files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "bmp"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .jpg files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "jpg"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .png files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "png"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .ppm files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "ppm"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .sr files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "sr"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's image loading functionality
|
||||
for .tiff files
|
||||
"""
|
||||
|
||||
# file extension to check
|
||||
EXTENSION = "tiff"
|
||||
|
||||
# import check routine
|
||||
import cvLoadImage
|
||||
import sys
|
||||
|
||||
# check image file of extension EXTENSION,
|
||||
# the function also exits and returns
|
||||
# 0,1 or 77 accordingly.
|
||||
|
||||
if cvLoadImage.image_ok(EXTENSION):
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's window move/resize functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvMoveResizeWindow"
|
||||
REQUIRED = ["cvNamedWindow"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# create a window
|
||||
cvNamedWindow(TESTNAME, CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# move the window around
|
||||
cvMoveWindow(TESTNAME, 0, 0)
|
||||
cvMoveWindow(TESTNAME, 100, 0)
|
||||
cvMoveWindow(TESTNAME, 100, 100)
|
||||
cvMoveWindow(TESTNAME, 0, 100)
|
||||
|
||||
# resize the window
|
||||
for i in range(1,10):
|
||||
cvResizeWindow(TESTNAME, i*100, i*100)
|
||||
|
||||
# destroy the window
|
||||
cvDestroyWindow(TESTNAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 (success)
|
||||
sys.exit(0)
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's window functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvNamedWindow"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete flag file if it exists
|
||||
if not works.check_files( REQUIRED, TESTNAME ):
|
||||
sys.exit(77)
|
||||
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# some definitions
|
||||
win_name = "testing..."
|
||||
|
||||
# create a window and save return code
|
||||
res = cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# if returncode is ok, window creation was sucessful
|
||||
if res == 0:
|
||||
# something went wrong, so return an errorcode
|
||||
sys.exit(1)
|
||||
|
||||
# destroy the window
|
||||
cvDestroyWindow( win_name )
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's cvQueryFrame() function
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvQueryFrame"
|
||||
REQUIRED = ["cvGrabFrame","cvRetrieveFrame"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/")
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# create a video reader using the tiny video 'uncompressed.avi'
|
||||
video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
|
||||
|
||||
# call cvQueryFrame for 30 frames and check if the returned image is ok
|
||||
for k in range(0,30):
|
||||
image = cvQueryFrame( video )
|
||||
|
||||
if image is None:
|
||||
# returned image is not a correct IplImage (pointer),
|
||||
# so return an error code
|
||||
sys.exit(77)
|
||||
|
||||
# ATTENTION: We do not release the video reader, window or any image.
|
||||
# This is bad manners, but Python and OpenCV don't care...
|
||||
|
||||
# create flag file for sollowing tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's cvRetrieveFrame function
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvRetrieveFrame"
|
||||
REQUIRED = ["cvGrabFrame"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/videos/")
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
|
||||
# create a video reader using the tiny video 'uncompressed.avi'
|
||||
video = cvCreateFileCapture(PREFIX+"uncompressed.avi")
|
||||
|
||||
# call cvGrabFrame to grab a frame from video
|
||||
res=cvGrabFrame(video)
|
||||
|
||||
if res==0:
|
||||
print "(ERROR) Couldn't call cvGrabFrame()"
|
||||
sys.exit(1)
|
||||
# call cvRetrieveFrame and check if returned image is valid
|
||||
image = cvRetrieveFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is not a correct IplImage (pointer),
|
||||
# so return an error code
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
# ATTENTION: We do not release the video reader or image.
|
||||
# This is bad manners, but Python and OpenCV don't care...
|
||||
|
||||
# create flag file for sollowing tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+50
@@ -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)
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's mouse functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvSetMouseCallback"
|
||||
REQUIRED = ["cvShowImage"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# global variable which stores information about the pressed mousebuttons
|
||||
mouse_events = [False,False,False,False,False,False,False,False,False,False]
|
||||
event_detected = False
|
||||
|
||||
# some definitions
|
||||
win_name = "testing..."
|
||||
EVENTS = ['CV_EVENT_MOUSEMOVE', 'CV_EVENT_LBUTTONDOWN', 'CV_EVENT_RBUTTONDOWN', 'CV_EVENT_MBUTTONDOWN', 'CV_EVENT_LBUTTONUP',
|
||||
'CV_EVENT_RBUTTONUP', 'CV_EVENT_MBUTTONUP' , 'CV_EVENT_LBUTTONDBLCLK','CV_EVENT_RBUTTONDBLCLK','CV_EVENT_MBUTTONDBLCLK']
|
||||
|
||||
|
||||
# our callback function, 5th parameter not used here.
|
||||
def callback_function(event,x,y,flag,param):
|
||||
globals()["event_detected"] = True
|
||||
# check if event already occured; if not, output info about new event.
|
||||
if globals()["mouse_events"][event] == False:
|
||||
print "Event "+globals()["EVENTS"][event]+" detected."
|
||||
globals()["mouse_events"][event] = True
|
||||
return
|
||||
|
||||
|
||||
# create a window ('cvNamedWindow.works' exists, so it must work)
|
||||
cvNamedWindow(win_name,CV_WINDOW_AUTOSIZE)
|
||||
# show the baboon in the window
|
||||
PREFIX = os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
|
||||
cvShowImage(win_name, cvLoadImage(PREFIX+"cvSetMouseCallback.jpg"))
|
||||
# assign callback function 'callback_function' to window, no parameters used here
|
||||
cvSetMouseCallback( win_name, callback_function )
|
||||
|
||||
# give the user information about the test and wait for input
|
||||
print "(INFO) Please hover the mouse over the baboon image and press"
|
||||
print "(INFO) your available mousebuttons inside the window to 'PASS' this test."
|
||||
print "(INFO) You may also perform double-clicks."
|
||||
print "(INFO) Press a key on your keyboard ot wait 20 seconds to continue."
|
||||
print "(HINT) If no mouseevent was detected this test will be remarked as 'FAIL'."
|
||||
|
||||
# now wait 20 seconds for user to press a key
|
||||
cvWaitKey(20000)
|
||||
|
||||
# reset mouse callback
|
||||
cvSetMouseCallback( win_name, 0 )
|
||||
# destroy the window
|
||||
cvDestroyWindow( win_name )
|
||||
|
||||
# check if a mouse event had beed detected
|
||||
if not event_detected:
|
||||
# user didn't interact properly or mouse functionality doesn't work correctly
|
||||
print "(ERROR) No mouse event detected."
|
||||
sys.exit(1)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 (success)
|
||||
sys.exit(0)
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's window functionality
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvShowImage"
|
||||
REQUIRED = ["cvLoadImagejpg", "cvNamedWindow"]
|
||||
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# defined window name
|
||||
win_name = "testing..."
|
||||
|
||||
# we expect a window to be createable, thanks to 'cvNamedWindow.works'
|
||||
cvNamedWindow(win_name, CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# we expect the image to be loadable, thanks to 'cvLoadImage.works'
|
||||
image = cvLoadImage(PREFIX+"cvShowImage.jpg")
|
||||
|
||||
if image is None:
|
||||
print "(ERROR) Couldn't load image "+PREFIX+"cvShowImage.jpg"
|
||||
sys.exit(1)
|
||||
|
||||
# try to show image in window
|
||||
res = cvShowImage( win_name, image )
|
||||
cvWaitKey(0)
|
||||
|
||||
|
||||
if res == 0:
|
||||
cvReleaseImage(image)
|
||||
cvDestroyWindow(win_name)
|
||||
sys.exit(1)
|
||||
|
||||
# destroy window
|
||||
cvDestroyWindow(win_name)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
This script will test highgui's cvWaitKey(int) function
|
||||
"""
|
||||
|
||||
# name of this test and it's requirements
|
||||
TESTNAME = "cvWaitKey"
|
||||
REQUIRED = ["cvShowImage"]
|
||||
|
||||
# needed for sys.exit(int) and .works file handling
|
||||
import os
|
||||
import sys
|
||||
import works
|
||||
|
||||
# path to imagefiles we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED, TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from highgui import *
|
||||
|
||||
# request some user input
|
||||
print "(INFO) Press anykey within the next 20 seconds to 'PASS' this test."
|
||||
|
||||
# create a dummy window which reacts on cvWaitKey()
|
||||
cvNamedWindow(TESTNAME, CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# display an image
|
||||
cvShowImage(TESTNAME, cvLoadImage(PREFIX+"cvWaitKey.jpg"))
|
||||
|
||||
# wait 20 seconds using cvWaitKey(20000),
|
||||
# return 'FAIL' if no key has been pressed.
|
||||
if cvWaitKey(20000) == -1:
|
||||
print "(ERROR) No key pressed, remarking as 'FAIL'."
|
||||
sys.exit(1)
|
||||
|
||||
#create flag file for the following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return 0 ('PASS')
|
||||
sys.exit(0)
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
QCIF=["QCIF_00.bmp","QCIF_01.bmp","QCIF_02.bmp","QCIF_03.bmp","QCIF_04.bmp","QCIF_05.bmp",
|
||||
"QCIF_06.bmp","QCIF_07.bmp","QCIF_08.bmp","QCIF_09.bmp","QCIF_10.bmp","QCIF_11.bmp",
|
||||
"QCIF_12.bmp","QCIF_13.bmp","QCIF_14.bmp","QCIF_15.bmp","QCIF_16.bmp","QCIF_17.bmp",
|
||||
"QCIF_18.bmp","QCIF_19.bmp","QCIF_20.bmp","QCIF_21.bmp","QCIF_22.bmp","QCIF_23.bmp",
|
||||
"QCIF_24.bmp","QCIF_25.bmp","QCIF_26.bmp","QCIF_27.bmp","QCIF_28.bmp","QCIF_29.bmp"]
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
"""
|
||||
This script will compare tho images and decides with a threshold
|
||||
if these to images are "equal enough"
|
||||
"""
|
||||
|
||||
# import the necessary things for OpenCV
|
||||
from cv import *
|
||||
from highgui import *
|
||||
|
||||
import frames
|
||||
import sys
|
||||
import os
|
||||
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/images/")
|
||||
|
||||
|
||||
DisplayImages=False
|
||||
|
||||
if DisplayImages:
|
||||
videowindow="video"
|
||||
referencewindow="reference"
|
||||
cvNamedWindow(videowindow,CV_WINDOW_AUTOSIZE)
|
||||
cvNamedWindow(referencewindow,CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# returns True/False if match/non-match
|
||||
def match( image, index, thres ):
|
||||
|
||||
# load image from comparison set
|
||||
QCIFcompare=cvLoadImage(PREFIX+frames.QCIF[index])
|
||||
|
||||
if QCIFcompare is None:
|
||||
print "Couldn't open image "+PREFIX+frames.QCIF[index]+" for comparison!"
|
||||
sys.exit(1)
|
||||
|
||||
# resize comparison image to input image dimensions
|
||||
size=cvSize(image.width,image.height)
|
||||
compare=cvCreateImage(size,IPL_DEPTH_8U,image.nChannels)
|
||||
cvResize(QCIFcompare,compare)
|
||||
|
||||
# compare images
|
||||
diff=cvNorm( image, compare, CV_RELATIVE_L2 )
|
||||
|
||||
if DisplayImages:
|
||||
cvShowImage(videowindow,image)
|
||||
cvShowImage(referencewindow,compare)
|
||||
if diff<=thres:
|
||||
cvWaitKey(200)
|
||||
else:
|
||||
print "index==",index,": max==",thres," is==",diff
|
||||
cvWaitKey(5000)
|
||||
|
||||
cvReleaseImage(QCIFcompare)
|
||||
cvReleaseImage(compare)
|
||||
|
||||
if diff<=thres:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a 3GP-compressed .3gp file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_3gp"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.043,0.031,0.032,0.031,0.029,0.030,0.030,0.031,0.030,0.029,0.034,0.027,0.029,0.029,0.029,0.029,0.029,0.028,0.031,0.030,0.035,0.031,0.031,0.032,0.031,0.032,0.033,0.031,0.033]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='3gp.3gp'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on an .avi file containing uncompressed 24bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_bmp24"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp24.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on an .avi file containing uncompressed 32bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_bmp32"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp32.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a DV-compressed .dv file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_cinepak"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.086,0.082,0.087,0.085,0.086,0.085,0.086,0.086,0.086,0.086,0.089,0.087,0.090,0.088,0.088,0.088,0.089,0.088,0.089,0.088,0.091,0.089,0.092,0.091,0.091,0.090,0.091,0.090,0.091]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='cinepak.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a DivX-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_divx"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.084,0.081,0.085,0.083,0.085,0.083,0.085,0.085,0.084,0.084,0.087,0.086,0.088,0.086,0.087,0.086,0.086,0.086,0.087,0.086,0.089,0.087,0.090,0.089,0.089,0.088,0.089,0.089,0.089]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='divx.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a DV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_dv_pal_progressive_avi"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.051,0.047,0.051,0.050,0.052,0.049,0.051,0.050,0.050,0.051,0.054,0.052,0.053,0.052,0.055,0.052,0.053,0.052,0.053,0.052,0.056,0.055,0.056,0.055,0.058,0.055,0.056,0.055,0.056]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a DV-compressed .dv file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_dv_pal_progressive_dv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.288,0.288,0.290,0.289,0.290,0.288,0.288,0.289,0.288,0.289,0.293,0.290,0.293,0.291,0.292,0.290,0.291,0.292,0.292,0.292,0.293,0.290,0.294,0.292,0.292,0.291,0.292,0.293,0.293]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.dv'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a HuffYUV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_huffyuv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='huffyuv.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on an Intel Indeo-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_indeo"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='indeo.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a MPEG4-compressed .mp4 file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_mpeg4"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.042,0.025,0.026,0.025,0.024,0.024,0.026,0.024,0.025,0.024,0.028,0.023,0.024,0.024,0.024,0.024,0.025,0.023,0.027,0.024,0.030,0.025,0.026,0.026,0.026,0.026,0.026,0.024,0.027]
|
||||
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='mpeg4.mp4'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
"""
|
||||
This script will test highgui's cvQueryFrame() function
|
||||
for different video formats
|
||||
"""
|
||||
|
||||
# import the necessary things for OpenCV and comparson routine
|
||||
import os
|
||||
from highgui import *
|
||||
from cv import *
|
||||
import match
|
||||
|
||||
# path to videos and images we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/")
|
||||
|
||||
# this is the folder with the videos and images
|
||||
# and name of output window
|
||||
IMAGES = PREFIX+"images/"
|
||||
VIDEOS = PREFIX+"videos/"
|
||||
|
||||
# testing routine, called for each entry in FILENAMES
|
||||
# and compares each frame with corresponding frame in COMPARISON
|
||||
def query_ok(FILENAME,ERRORS):
|
||||
|
||||
# create a video reader using the tiny videofile VIDEOS+FILENAME
|
||||
video=cvCreateFileCapture(VIDEOS+FILENAME)
|
||||
|
||||
if video is None:
|
||||
# couldn't open video (FAIL)
|
||||
return 1
|
||||
|
||||
# call cvQueryFrame for 29 frames and check if the returned image is ok
|
||||
for k in range(29):
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is NULL (FAIL)
|
||||
return 1
|
||||
|
||||
if not match.match(image,k,ERRORS[k]):
|
||||
return 1
|
||||
|
||||
cvReleaseCapture(video)
|
||||
# everything is fine (PASS)
|
||||
return 0
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on an uncompressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_uncompressed"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='uncompressed.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvQueryFrame function
|
||||
on a WMV9-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "query_wmv9"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.084,0.088,0.086,0.086,0.089,0.085,0.090,0.088,0.087,0.090,0.095,0.088,0.090,0.091,0.092,0.088,0.090,0.090,0.090,0.091,0.095,0.093,0.093,0.094,0.097,0.090,0.094,0.092,0.092]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import query_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='wmv9.avi'
|
||||
|
||||
# run check routine
|
||||
result=query_test.query_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a 3GP-compressed .3gp file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_3gp"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.043,0.031,0.032,0.031,0.029,0.030,0.030,0.031,0.030,0.029,0.034,0.027,0.029,0.029,0.029,0.029,0.029,0.028,0.031,0.030,0.035,0.031,0.031,0.032,0.031,0.032,0.033,0.031,0.033]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='3gp.3gp'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on an .avi file containing uncompressed 24bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_bmp24"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp24.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on an .avi file containing uncompressed 32bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_bmp32"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp32.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a CinePak-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_cinepak"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.086,0.082,0.087,0.085,0.086,0.085,0.086,0.086,0.086,0.086,0.089,0.087,0.090,0.088,0.088,0.088,0.089,0.088,0.089,0.088,0.091,0.089,0.092,0.091,0.091,0.090,0.091,0.090,0.091]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='cinepak.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a DivX-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_divx"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.084,0.081,0.085,0.083,0.085,0.083,0.085,0.085,0.084,0.084,0.087,0.086,0.088,0.086,0.087,0.086,0.086,0.086,0.087,0.086,0.089,0.087,0.090,0.089,0.089,0.088,0.089,0.089,0.089]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='divx.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a DV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_dv_pal_progressive_avi"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.051,0.047,0.051,0.050,0.052,0.049,0.051,0.050,0.050,0.051,0.054,0.052,0.053,0.052,0.055,0.052,0.053,0.052,0.053,0.052,0.056,0.055,0.056,0.055,0.058,0.055,0.056,0.055,0.056]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a DV-compressed .dv file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_dv_pal_progressive_dv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.288,0.288,0.290,0.289,0.290,0.288,0.288,0.289,0.288,0.289,0.293,0.290,0.293,0.291,0.292,0.290,0.291,0.292,0.292,0.292,0.293,0.290,0.294,0.292,0.292,0.291,0.292,0.293,0.293]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.dv'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a HuffYUV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_huffyuv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='huffyuv.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on an Intel Indeo-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_indeo"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='indeo.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a MPEG4-compressed .mp4 file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_mp4"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.042,0.025,0.026,0.025,0.024,0.024,0.026,0.024,0.025,0.024,0.028,0.023,0.024,0.024,0.024,0.024,0.025,0.023,0.027,0.024,0.030,0.025,0.026,0.026,0.026,0.026,0.026,0.024,0.027]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='mpeg4.mp4'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on an uncompressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_uncompressed"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='uncompressed.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's frame seeking functionality
|
||||
on a WMV9-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_frame_wmv9"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='wmv9.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_frame_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+146
@@ -0,0 +1,146 @@
|
||||
"""
|
||||
This script will test highgui's seek functionality
|
||||
for different video formats
|
||||
"""
|
||||
|
||||
# import the necessary things for OpenCV and comparson routine
|
||||
import os
|
||||
#import python
|
||||
#from python.highgui import *
|
||||
#from python.cv import *
|
||||
import match
|
||||
from highgui import *
|
||||
from cv import *
|
||||
|
||||
# path to videos and images we need
|
||||
PREFIX=os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/")
|
||||
|
||||
# this is the folder with the videos and images
|
||||
# and name of output window
|
||||
IMAGES = PREFIX+"images/"
|
||||
VIDEOS = PREFIX+"videos/"
|
||||
|
||||
|
||||
|
||||
show_frames=False
|
||||
|
||||
# testing routine, seeks through file and compares read images with frames in frames.QCIF[]
|
||||
def seek_frame_ok(FILENAME,ERRORS):
|
||||
# create a video reader using the tiny videofile VIDEOS+FILENAME
|
||||
video=cvCreateFileCapture(VIDEOS+FILENAME)
|
||||
|
||||
if video is None:
|
||||
# couldn't open video (FAIL)
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvNamedWindow("test", CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# skip 2 frames and read 3rd frame each until EOF and check if the read image is ok
|
||||
for k in [0,3,6,9,12,15,18,21,24,27]:
|
||||
cvSetCaptureProperty(video, CV_CAP_PROP_POS_FRAMES, k)
|
||||
|
||||
# try to query frame
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is NULL (FAIL)
|
||||
return 1
|
||||
|
||||
compresult = match.match(image,k,ERRORS[k])
|
||||
if not compresult:
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvShowImage("test",image)
|
||||
cvWaitKey(200)
|
||||
|
||||
# same as above, just backwards...
|
||||
for k in [27,24,21,18,15,12,9,6,3,0]:
|
||||
|
||||
cvSetCaptureProperty(video, CV_CAP_PROP_POS_FRAMES, k)
|
||||
|
||||
# try to query frame
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is NULL (FAIL)
|
||||
return 1
|
||||
|
||||
compresult = match.match(image,k,ERRORS[k])
|
||||
if not compresult:
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvShowImage("test",image)
|
||||
cvWaitKey(200)
|
||||
|
||||
# ATTENTION: We do not release the video reader, window or any image.
|
||||
# This is bad manners, but Python and OpenCV don't care,
|
||||
# the whole memory segment will be freed on finish anyway...
|
||||
|
||||
del video
|
||||
# everything is fine (PASS)
|
||||
return 0
|
||||
|
||||
|
||||
# testing routine, seeks through file and compares read images with frames in frames.QCIF[]
|
||||
def seek_time_ok(FILENAME,ERRORS):
|
||||
|
||||
# create a video reader using the tiny videofile VIDEOS+FILENAME
|
||||
video=cvCreateFileCapture(VIDEOS+FILENAME)
|
||||
|
||||
if video is None:
|
||||
# couldn't open video (FAIL)
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvNamedWindow("test", CV_WINDOW_AUTOSIZE)
|
||||
|
||||
# skip 2 frames and read 3rd frame each until EOF and check if the read image is ok
|
||||
for k in [0,3,6,9,12,15,18,21,24,27]:
|
||||
|
||||
cvSetCaptureProperty(video, CV_CAP_PROP_POS_MSEC, k*40)
|
||||
|
||||
# try to query frame
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is NULL (FAIL)
|
||||
return 1
|
||||
|
||||
compresult = match.match(image,k,ERRORS[k])
|
||||
if not compresult:
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvShowImage("test",image)
|
||||
cvWaitKey(200)
|
||||
|
||||
# same as above, just backwards...
|
||||
for k in [27,24,21,18,15,12,9,6,3,0]:
|
||||
|
||||
cvSetCaptureProperty(video, CV_CAP_PROP_POS_MSEC, k*40)
|
||||
|
||||
# try to query frame
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
# returned image is NULL (FAIL)
|
||||
return 1
|
||||
|
||||
compresult = match.match(image,k,ERRORS[k])
|
||||
if not compresult:
|
||||
return 1
|
||||
|
||||
if show_frames:
|
||||
cvShowImage("test",image)
|
||||
cvWaitKey(200)
|
||||
|
||||
# ATTENTION: We do not release the video reader, window or any image.
|
||||
# This is bad manners, but Python and OpenCV don't care,
|
||||
# the whole memory segment will be freed on finish anyway...
|
||||
|
||||
del video
|
||||
# everything is fine (PASS)
|
||||
return 0
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a 3GP-compressed .3gp file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_3gp"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.043,0.031,0.032,0.031,0.029,0.030,0.030,0.031,0.030,0.029,0.034,0.027,0.029,0.029,0.029,0.029,0.029,0.028,0.031,0.030,0.035,0.031,0.031,0.032,0.031,0.032,0.033,0.031,0.033]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='3gp.3gp'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on an .avi file containing uncompressed 24bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_bmp24"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp24.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on an .avi file containing uncompressed 32bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_bmp32"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp32.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a CinePak-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_cinepak"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.086,0.082,0.087,0.085,0.086,0.085,0.086,0.086,0.086,0.086,0.089,0.087,0.090,0.088,0.088,0.088,0.089,0.088,0.089,0.088,0.091,0.089,0.092,0.091,0.091,0.090,0.091,0.090,0.091]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='cinepak.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a DivX-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_divx"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.084,0.081,0.085,0.083,0.085,0.083,0.085,0.085,0.084,0.084,0.087,0.086,0.088,0.086,0.087,0.086,0.086,0.086,0.087,0.086,0.089,0.087,0.090,0.089,0.089,0.088,0.089,0.089,0.089]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='divx.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a DV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_dv_pal_progressive_avi"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.051,0.047,0.051,0.050,0.052,0.049,0.051,0.050,0.050,0.051,0.054,0.052,0.053,0.052,0.055,0.052,0.053,0.052,0.053,0.052,0.056,0.055,0.056,0.055,0.058,0.055,0.056,0.055,0.056]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a DV-compressed .dv file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_dv_pal_progressive_dv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.288,0.288,0.290,0.289,0.290,0.288,0.288,0.289,0.288,0.289,0.293,0.290,0.293,0.291,0.292,0.290,0.291,0.292,0.292,0.292,0.293,0.290,0.294,0.292,0.292,0.291,0.292,0.293,0.293]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.dv'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a HuffYUV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_huffyuv"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='huffyuv.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on an Intel Indeo-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_indeo"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='indeo.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on an MPEG4-compressed .mp4 file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_mpeg4"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.042,0.025,0.026,0.025,0.024,0.024,0.026,0.024,0.025,0.024,0.028,0.023,0.024,0.024,0.024,0.024,0.025,0.023,0.027,0.024,0.030,0.025,0.026,0.026,0.026,0.026,0.026,0.024,0.027]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='mpeg4.mp4'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a uncompressed avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_uncompressed"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.085,0.082,0.086,0.084,0.086,0.084,0.085,0.085,0.085,0.086,0.088,0.087,0.089,0.088,0.088,0.087,0.088,0.087,0.088,0.087,0.091,0.089,0.091,0.090,0.090,0.090,0.090,0.090,0.090]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='uncompressed.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's time seeking functionality
|
||||
on a WMV9-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "seek_time_wmv9"
|
||||
REQUIRED = []
|
||||
ERRORS=[0.043,0.031,0.032,0.031,0.029,0.030,0.030,0.031,0.030,0.029,0.034,0.027,0.029,0.029,0.029,0.029,0.029,0.028,0.031,0.030,0.035,0.031,0.031,0.032,0.031,0.032,0.033,0.031,0.033]
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import seek_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='wmv9.avi'
|
||||
|
||||
# run check routine
|
||||
result=seek_test.seek_time_ok(FILENAME,ERRORS)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a 3GP-compressed .3gp file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_3gp"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='3gp.3gp'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of an .avi file containing uncompressed 24bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_bmp24"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp24.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of an .avi file containing uncompressed 32bit Bitmap frames.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_bmp32"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='bmp32.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a CinePak-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_cinepak"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='cinepak.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a DivX-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_divx"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='divx.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a DV-compressed .avi file file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_dv_pal_progressive_avi"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a DV-compressed .dv file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_dv_pal_progressive_dv"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='dv_pal_progressive.dv'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a HuffYUV-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_huffyuv"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='huffyuv.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of an Intel Indeo-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_indeo"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='indeo.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of an MPEG4-compressed .mp4 file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_mpeg4"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='mpeg4.mp4'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
This script will test HighGUI's cvGetCaptureProperty functionality
|
||||
for correct returnvalues of width and height information for different video formats
|
||||
"""
|
||||
|
||||
# import the necessary things for OpenCV and comparson routine
|
||||
import os
|
||||
from cv import *
|
||||
from highgui import *
|
||||
#import python
|
||||
#from python.highgui import *
|
||||
|
||||
|
||||
# path to images and videos we need
|
||||
PREFIX =os.path.join(os.environ["srcdir"],"../../opencv_extra/testdata/python/")
|
||||
|
||||
|
||||
# this is the folder with the videos and images
|
||||
# and name of output window
|
||||
IMAGES = PREFIX+"images/"
|
||||
VIDEOS = PREFIX+"videos/"
|
||||
|
||||
|
||||
# testing routine, seeks through file and compares read images with frames in COMPARISON
|
||||
def size_ok(FILENAME):
|
||||
# create a video reader using the tiny videofile VIDEOS+FILENAME
|
||||
video=cvCreateFileCapture(VIDEOS+FILENAME)
|
||||
|
||||
if video is None:
|
||||
# couldn't open video (FAIL)
|
||||
return 1
|
||||
|
||||
# get width and height information via HighGUI's cvGetCaptureProperty function
|
||||
w=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_WIDTH)
|
||||
h=cvGetCaptureProperty(video,CV_CAP_PROP_FRAME_HEIGHT)
|
||||
|
||||
# get an image to compare
|
||||
image=cvQueryFrame(video)
|
||||
|
||||
if image is None:
|
||||
return 1
|
||||
|
||||
image = cvCloneImage (image)
|
||||
|
||||
if (w!=image.width) or (h!=image.height):
|
||||
# dimensions don't match parameters (FAIL)
|
||||
return 1
|
||||
|
||||
del video
|
||||
del image
|
||||
# everything is fine (PASS)
|
||||
return 0
|
||||
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of an uncompressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_uncompressed"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='uncompressed.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
"""
|
||||
This script checks HighGUI's cvGetCaptureProperty functionality for correct return
|
||||
of the frame width and height of a WMV9-compressed .avi file.
|
||||
"""
|
||||
|
||||
# name if this test and it's requirements
|
||||
TESTNAME = "size_wmv9"
|
||||
REQUIRED = []
|
||||
|
||||
# needed for sys.exit(int), .works file handling and check routine
|
||||
import sys
|
||||
import works
|
||||
import size_test
|
||||
|
||||
# check requirements and delete old flag file, if it exists
|
||||
if not works.check_files(REQUIRED,TESTNAME):
|
||||
sys.exit(77)
|
||||
|
||||
# name of file we check here
|
||||
FILENAME='wmv9.avi'
|
||||
|
||||
# run check routine
|
||||
result=size_test.size_ok(FILENAME)
|
||||
|
||||
# create flag file for following tests
|
||||
works.set_file(TESTNAME)
|
||||
|
||||
# return result of test routine
|
||||
sys.exit(result)
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
# needed for access() and remove()
|
||||
import os
|
||||
|
||||
# check for required featurest listet in 'filelist' and removes the old .works file of 'testname'
|
||||
def check_files( filelist, testname ):
|
||||
# delete old .works file of the calling test, if it exists
|
||||
filename = "./"+testname+".works"
|
||||
|
||||
if os.access(filename,os.F_OK):
|
||||
os.remove(filename)
|
||||
|
||||
# now check for existint .works files
|
||||
if len(filelist) > 0:
|
||||
for i in range(0,len(filelist)):
|
||||
tmpname = "./"+filelist[i]+".works"
|
||||
if not os.access(tmpname,os.F_OK):
|
||||
print "(INFO) Skipping '"+testname+"' due to SKIP/FAIL of '"+filelist[i]+"'"
|
||||
return False
|
||||
|
||||
# either the filelist is empty (no requirements) or all requirements match
|
||||
return True
|
||||
|
||||
|
||||
# create the .works file for test 'testname'
|
||||
def set_file( testname ):
|
||||
# create .works file of calling test
|
||||
works_file = file("./"+testname+".works", 'w',1)
|
||||
works_file.close
|
||||
return
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
import unittest
|
||||
import sys
|
||||
import os
|
||||
import cvtestutils
|
||||
from cv import cvCreateHist, cvGetSize, cvCreateImage, cvCvtColor, cvSplit, cvCalcHist, cvCalcArrHist, CV_HIST_ARRAY
|
||||
from highgui import cvLoadImage
|
||||
|
||||
image_fname = os.path.join( cvtestutils.datadir(), 'images', 'baboon_256x256.bmp' )
|
||||
class HistogramTestCase( unittest.TestCase ):
|
||||
def setUp(self):
|
||||
frame = cvLoadImage( image_fname )
|
||||
frame_size = cvGetSize( frame )
|
||||
r = cvCreateImage (frame_size, 8, 1)
|
||||
g = cvCreateImage (frame_size, 8, 1)
|
||||
b = cvCreateImage (frame_size, 8, 1)
|
||||
|
||||
cvSplit( frame, r, g, b, None)
|
||||
self.rgb = (r,g,b)
|
||||
assert(frame is not None)
|
||||
|
||||
hist_size = [64, 64, 64]
|
||||
ranges = [ [0, 255], [0, 255], [0, 255] ]
|
||||
self.hist = cvCreateHist( hist_size, CV_HIST_ARRAY, ranges, 1 )
|
||||
|
||||
def test_cvCreateHist( self ):
|
||||
assert( self.hist is not None )
|
||||
|
||||
def test_cvCalcArrHist(self):
|
||||
cvCalcArrHist( self.rgb, self.hist, 0, None)
|
||||
|
||||
def test_cvCalcHist(self):
|
||||
cvCalcHist( self.rgb, self.hist, 0, None)
|
||||
|
||||
def suite():
|
||||
tests = ['test_cvCreateHist', 'test_cvCalcArrHist', 'test_cvCalcHist']
|
||||
return unittest.TestSuite( map(HistogramTestCase, tests))
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
Executable
+97
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 2009-01-16, Xavier Delacour <xavier.delacour@gmail.com>
|
||||
|
||||
import unittest
|
||||
from numpy import *;
|
||||
from numpy.linalg import *;
|
||||
import sys;
|
||||
|
||||
import cvtestutils
|
||||
from cv import *;
|
||||
from adaptors import *;
|
||||
|
||||
def transform(H,x):
|
||||
x1 = H * asmatrix(r_[x[0],x[1],1]).transpose()
|
||||
x1 = asarray(x1).flatten()
|
||||
return r_[x1[0]/x1[2],x1[1]/x1[2]]
|
||||
|
||||
class homography_test(unittest.TestCase):
|
||||
|
||||
def test_ransac_identity(self):
|
||||
pts1 = random.rand(100,2);
|
||||
result,H = cvFindHomography(pts1, pts1, CV_RANSAC, 1e-5);
|
||||
assert(result and all(abs(Ipl2NumPy(H) - eye(3)) < 1e-5));
|
||||
|
||||
def test_ransac_0_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
result,H = cvFindHomography(pts1, pts2, CV_RANSAC, 1e-5);
|
||||
assert(result and all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_ransac_30_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
pts2[0:30] = random.rand(30,2)
|
||||
result,H = cvFindHomography(pts1, pts2, CV_RANSAC, 1e-5);
|
||||
assert(result and all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_ransac_70_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
pts2[0:70] = random.rand(70,2)
|
||||
result,H = cvFindHomography(pts1, pts2, CV_RANSAC, 1e-5);
|
||||
assert(result and all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_ransac_90_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
pts2[0:90] = random.rand(90,2)
|
||||
result,H = cvFindHomography(pts1, pts2, CV_RANSAC, 1e-5);
|
||||
assert(not result or not all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_lmeds_identity(self):
|
||||
pts1 = random.rand(100,2);
|
||||
result,H = cvFindHomography(pts1, pts1, CV_LMEDS);
|
||||
assert(result and all(abs(Ipl2NumPy(H) - eye(3)) < 1e-5));
|
||||
|
||||
def test_lmeds_0_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
result,H = cvFindHomography(pts1, pts2, CV_LMEDS);
|
||||
assert(result and all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_lmeds_30_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = [transform(H1,x) for x in pts1]
|
||||
pts2[0:30] = random.rand(30,2)
|
||||
result,H = cvFindHomography(pts1, pts2, CV_LMEDS);
|
||||
assert(result and all(abs(H1-H)<1e-5))
|
||||
|
||||
def test_lmeds_70_outliers(self):
|
||||
pts1 = random.rand(100,2);
|
||||
H1 = asmatrix(random.rand(3,3));
|
||||
H1 = H1 / H1[2,2]
|
||||
pts2 = vstack([transform(H1,x) for x in pts1])
|
||||
pts2[0:70] = random.rand(70,2)
|
||||
result,H = cvFindHomography(pts1, pts2, CV_LMEDS);
|
||||
assert(not result or not all(abs(H1-H)<1e-5))
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(homography_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
|
||||
Executable
+122
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 2009-01-12, Xavier Delacour <xavier.delacour@gmail.com>
|
||||
|
||||
# gdb --cd ~/opencv-lsh/tests/python --args /usr/bin/python lsh_tests.py
|
||||
# set env PYTHONPATH /home/x/opencv-lsh/debug/interfaces/swig/python:/home/x/opencv-lsh/debug/lib
|
||||
# export PYTHONPATH=/home/x/opencv-lsh/debug/interfaces/swig/python:/home/x/opencv-lsh/debug/lib
|
||||
|
||||
import unittest
|
||||
from numpy import *;
|
||||
from numpy.linalg import *;
|
||||
import sys;
|
||||
|
||||
import cvtestutils
|
||||
from cv import *;
|
||||
from adaptors import *;
|
||||
|
||||
def planted_neighbors(query_points, R = .4):
|
||||
n,d = query_points.shape
|
||||
data = zeros(query_points.shape)
|
||||
for i in range(0,n):
|
||||
a = random.rand(d)
|
||||
a = random.rand()*R*a/sqrt(sum(a**2))
|
||||
data[i] = query_points[i] + a
|
||||
return data
|
||||
|
||||
class lsh_test(unittest.TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
n = 10000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d)*2-1;
|
||||
data = planted_neighbors(query_points)
|
||||
|
||||
lsh = cvCreateMemoryLSH(d, n);
|
||||
cvLSHAdd(lsh, data);
|
||||
indices,dist = cvLSHQuery(lsh, query_points, 1, 100);
|
||||
correct = sum([i == j for j,i in enumerate(indices)])
|
||||
assert(correct >= n * .75);
|
||||
|
||||
def test_sensitivity(self):
|
||||
n = 10000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d);
|
||||
data = random.rand(n,d);
|
||||
|
||||
lsh = cvCreateMemoryLSH(d, 1000, 10, 10);
|
||||
cvLSHAdd(lsh, data);
|
||||
|
||||
good = 0
|
||||
trials = 20
|
||||
print
|
||||
for x in query_points[0:trials]:
|
||||
x1 = asmatrix(x) # PyArray_to_CvArr doesn't like 1-dim arrays
|
||||
indices,dist = cvLSHQuery(lsh, x1, n, n);
|
||||
indices = Ipl2NumPy(indices)
|
||||
indices = unique(indices[where(indices>=0)])
|
||||
|
||||
brute = vstack([(sqrt(sum((a-x)**2)),i,0) for i,a in enumerate(data)])
|
||||
lshp = vstack([(sqrt(sum((x-data[i])**2)),i,1) for i in indices])
|
||||
combined = vstack((brute,lshp))
|
||||
combined = combined[argsort(combined[:,0])]
|
||||
|
||||
spread = [i for i,a in enumerate(combined[:,2]) if a==1]
|
||||
spread = histogram(spread,bins=4,new=True)[0]
|
||||
print spread, sum(diff(spread)<0)
|
||||
if sum(diff(spread)<0) == 3: good = good + 1
|
||||
print good,"pass"
|
||||
assert(good > trials * .75);
|
||||
|
||||
def test_remove(self):
|
||||
n = 10000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d)*2-1;
|
||||
data = planted_neighbors(query_points)
|
||||
lsh = cvCreateMemoryLSH(d, n);
|
||||
indices = cvLSHAdd(lsh, data);
|
||||
assert(LSHSize(lsh)==n);
|
||||
cvLSHRemove(lsh,indices[0:n/2])
|
||||
assert(LSHSize(lsh)==n/2);
|
||||
|
||||
def test_destroy(self):
|
||||
n = 10000;
|
||||
d = 64;
|
||||
lsh = cvCreateMemoryLSH(d, n);
|
||||
|
||||
def test_destroy2(self):
|
||||
n = 10000;
|
||||
d = 64;
|
||||
query_points = random.rand(n,d)*2-1;
|
||||
data = planted_neighbors(query_points)
|
||||
lsh = cvCreateMemoryLSH(d, n);
|
||||
indices = cvLSHAdd(lsh, data);
|
||||
|
||||
|
||||
# move this to another file
|
||||
|
||||
# img1 = cvLoadImage(img1_fn);
|
||||
# img2 = cvLoadImage(img2_fn);
|
||||
# pts1,desc1 = cvExtractSURF(img1); # * make util routine to extract points and descriptors
|
||||
# pts2,desc2 = cvExtractSURF(img2);
|
||||
# lsh = cvCreateMemoryLSH(d, n);
|
||||
# cvLSHAdd(lsh, desc1);
|
||||
# indices,dist = cvLSHQuery(lsh, desc2, 2, 100);
|
||||
# matches = [((pts1[x[0]].pt.x,pts1[x[0]].pt.y),(pts2[j].pt.x,pts2[j].pt.y)) \
|
||||
# for j,x in enumerate(hstack((indices,dist))) \
|
||||
# if x[2] and (not x[3] or x[2]/x[3]>.6)]
|
||||
# out = cvCloneImage(img1);
|
||||
# for p1,p2 in matches:
|
||||
# cvCircle(out,p1,3,CV_RGB(255,0,0));
|
||||
# cvLine(out,p1,p2,CV_RGB(100,100,100));
|
||||
# cvNamedWindow("matches");
|
||||
# cvShowImage("matches",out);
|
||||
# cvWaitKey(0);
|
||||
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(lsh_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env python
|
||||
import cvtestutils
|
||||
import unittest
|
||||
from cv import *
|
||||
|
||||
class moments_test(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# create an image
|
||||
img = cvCreateMat(100,100,CV_8U);
|
||||
|
||||
cvZero( img )
|
||||
# draw a rectangle in the middle
|
||||
cvRectangle( img, cvPoint( 25, 25 ), cvPoint( 75, 75 ), CV_RGB(255,255,255), -1 );
|
||||
|
||||
self.img = img
|
||||
|
||||
# create the storage area
|
||||
self.storage = cvCreateMemStorage (0)
|
||||
|
||||
# find the contours
|
||||
nb_contours, self.contours = cvFindContours (img,
|
||||
self.storage,
|
||||
sizeof_CvContour,
|
||||
CV_RETR_LIST,
|
||||
CV_CHAIN_APPROX_SIMPLE,
|
||||
cvPoint (0,0))
|
||||
|
||||
def test_cvMoments_CvMat( self ):
|
||||
m = CvMoments()
|
||||
cvMoments( self.img, m, 1 )
|
||||
def test_cvMoments_CvSeq( self ):
|
||||
m = CvMoments()
|
||||
# Now test with CvSeq
|
||||
for contour in self.contours.hrange():
|
||||
cvMoments( contour, m, 1 )
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(moments_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
Executable
+51
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# 2009-01-16, Xavier Delacour <xavier.delacour@gmail.com>
|
||||
|
||||
import unittest
|
||||
from numpy import *;
|
||||
from numpy.linalg import *;
|
||||
import sys;
|
||||
|
||||
import cvtestutils
|
||||
from cv import *;
|
||||
from adaptors import *;
|
||||
|
||||
## these are mostly to test bindings, since there are more/better tests in tests/cxcore
|
||||
|
||||
def verify(x,y):
|
||||
x = Ipl2NumPy(x);
|
||||
assert(all(abs(x - y)<1e-4));
|
||||
|
||||
class roots_test(unittest.TestCase):
|
||||
|
||||
def test_cvSolvePoly(self):
|
||||
|
||||
verify(cvSolvePoly(asmatrix([-1,1]).astype(float64)),
|
||||
array([[(1.000000, 0.000000)]]));
|
||||
|
||||
verify(cvSolvePoly(asmatrix([-1,1]).astype(float32)),
|
||||
array([[(1.000000, 0.000000)]]));
|
||||
|
||||
verify(cvSolvePoly(asmatrix([-1,0,0,0,0,1]).astype(float64)),
|
||||
array([[(1, 0)],[(0.309017, 0.951057)],[(0.309017, -0.951057)],
|
||||
[(-0.809017, 0.587785)],[(-0.809017, -0.587785)]]))
|
||||
|
||||
verify(cvSolvePoly(asmatrix([-1,0,0,0,0,1]).astype(float32)),
|
||||
array([[(1, 0)],[(0.309017, 0.951057)],[(0.309017, -0.951057)],
|
||||
[(-0.809017, 0.587785)],[(-0.809017, -0.587785)]]))
|
||||
|
||||
def test_cvSolveCubic(self):
|
||||
|
||||
verify(cvSolveCubic(asmatrix([-1,0,0,1]).astype(float32))[1],
|
||||
array([[1],[0],[0]]));
|
||||
|
||||
verify(cvSolveCubic(asmatrix([-1,0,0,1]).astype(float64))[1],
|
||||
array([[1],[0],[0]]));
|
||||
|
||||
def suite():
|
||||
return unittest.TestLoader().loadTestsFromTestCase(roots_test)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
|
||||
Executable
+113
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""A simple TestCase class for testing the adaptors.py module.
|
||||
|
||||
2007-11-xx, Vicent Mas <vmas@carabos.com> Carabos Coop. V.
|
||||
2007-11-08, minor modifications for distribution, Mark Asbach <asbach@ient.rwth-aachen.de>
|
||||
"""
|
||||
|
||||
import unittest
|
||||
import os
|
||||
|
||||
import PIL.Image
|
||||
import numpy
|
||||
|
||||
import cvtestutils
|
||||
import cv
|
||||
import highgui
|
||||
import adaptors
|
||||
|
||||
import sys
|
||||
|
||||
class AdaptorsTestCase(unittest.TestCase):
|
||||
def test00_array_interface(self):
|
||||
"""Check if PIL supports the array interface."""
|
||||
self.assert_(PIL.Image.VERSION>='1.1.6',
|
||||
"""The installed PIL library doesn't support the array """
|
||||
"""interface. Please, update to version 1.1.6b2 or higher.""")
|
||||
|
||||
|
||||
def test01_PIL2NumPy(self):
|
||||
"""Test the adaptors.PIL2NumPy function."""
|
||||
|
||||
a = adaptors.PIL2NumPy(self.pil_image)
|
||||
self.assert_(a.flags['WRITEABLE'] == True,
|
||||
'PIL2NumPy should return a writeable array.')
|
||||
b = numpy.asarray(self.pil_image)
|
||||
self.assert_((a == b).all() == True,
|
||||
'The returned numpy array has not been properly constructed.')
|
||||
|
||||
|
||||
def test02_NumPy2PIL(self):
|
||||
"""Test the adaptors.NumPy2PIL function."""
|
||||
|
||||
a = numpy.asarray(self.pil_image)
|
||||
b = adaptors.NumPy2PIL(a)
|
||||
self.assert_(self.pil_image.tostring() == b.tostring(),
|
||||
'The returned image has not been properly constructed.')
|
||||
|
||||
|
||||
def test03_Ipl2PIL(self):
|
||||
"""Test the adaptors.Ipl2PIL function."""
|
||||
|
||||
i = adaptors.Ipl2PIL(self.ipl_image)
|
||||
self.assert_(self.pil_image.tostring() == i.tostring(),
|
||||
'The returned image has not been properly constructed.')
|
||||
|
||||
|
||||
def test04_PIL2Ipl(self):
|
||||
"""Test the adaptors.PIL2Ipl function."""
|
||||
|
||||
i = adaptors.PIL2Ipl(self.pil_image)
|
||||
self.assert_(self.ipl_image.imageData == i.imageData,
|
||||
'The returned image has not been properly constructed.')
|
||||
|
||||
|
||||
def test05_Ipl2NumPy(self):
|
||||
"""Test the adaptors.Ipl2NumPy function."""
|
||||
|
||||
a = adaptors.Ipl2NumPy(self.ipl_image)
|
||||
a_1d = numpy.reshape(a, (a.size, ))
|
||||
# For 3-channel IPL images the order of channels will be BGR
|
||||
# but NumPy array order of channels will be RGB so a conversion
|
||||
# is needed before we can compare both images
|
||||
if self.ipl_image.nChannels == 3:
|
||||
rgb = cv.cvCreateImage(cv.cvSize(self.ipl_image.width, self.ipl_image.height), self.ipl_image.depth, 3)
|
||||
cv.cvCvtColor(self.ipl_image, rgb, cv.CV_BGR2RGB)
|
||||
self.assert_(a_1d.tostring() == rgb.imageData,
|
||||
'The returned image has not been properly constructed.')
|
||||
else:
|
||||
self.assert_(a_1d.tostring() == self.ipl_image.imageData,
|
||||
'The returned image has not been properly constructed.')
|
||||
|
||||
|
||||
def test06_NumPy2Ipl(self):
|
||||
"""Test the adaptors.NumPy2Ipl function."""
|
||||
|
||||
a = adaptors.Ipl2NumPy(self.ipl_image)
|
||||
b = adaptors.NumPy2Ipl(a)
|
||||
self.assert_(self.ipl_image.imageData == b.imageData,
|
||||
'The returned image has not been properly constructed.')
|
||||
|
||||
def load_image( self, fname ):
|
||||
self.ipl_image = highgui.cvLoadImage(fname, 4|2)
|
||||
self.pil_image = PIL.Image.open(fname, 'r')
|
||||
|
||||
class AdaptorsTestCase1(AdaptorsTestCase):
|
||||
def setUp( self ):
|
||||
self.load_image( os.path.join(cvtestutils.datadir(),'images','cvSetMouseCallback.jpg'))
|
||||
|
||||
class AdaptorsTestCase2(AdaptorsTestCase):
|
||||
def setUp( self ):
|
||||
self.load_image( os.path.join(cvtestutils.datadir(),'images','baboon.jpg'))
|
||||
|
||||
def suite():
|
||||
cases=[]
|
||||
cases.append( unittest.TestLoader().loadTestsFromTestCase( AdaptorsTestCase1 ) )
|
||||
cases.append( unittest.TestLoader().loadTestsFromTestCase( AdaptorsTestCase2 ) )
|
||||
|
||||
return unittest.TestSuite(cases)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
||||
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This script uses the unittest module to find all the tests in the
|
||||
# same directory and run them.
|
||||
#
|
||||
# 2009-01-23, Roman Stanchak (rstanchak@gmail.com)
|
||||
#
|
||||
#
|
||||
# For a test to be detected and run by this script, it must
|
||||
# 1. Use unittest
|
||||
# 2. define a suite() method that returns a unittest.TestSuite containing
|
||||
# the tests to be run
|
||||
|
||||
import cvtestutils
|
||||
import unittest
|
||||
import types
|
||||
import os
|
||||
import imp
|
||||
|
||||
def suites( dirname ):
|
||||
suite_list=[]
|
||||
|
||||
for fn in os.listdir( dirname ):
|
||||
# tests must be named test_*.py or *_tests.py
|
||||
if not ( fn.lower().endswith('.py') and
|
||||
(fn.lower().startswith('test_') or fn.lower().endswith('_tests.py')) ):
|
||||
continue
|
||||
|
||||
module_name = fn[0:-3]
|
||||
fullpath = os.path.realpath( dirname + os.path.sep + fn )
|
||||
test_module = None
|
||||
try:
|
||||
test_module = imp.load_source( module_name, fullpath )
|
||||
except:
|
||||
print "Error importing python code in '%s'" % fn
|
||||
if test_module:
|
||||
try:
|
||||
suite_list.append( test_module.suite() )
|
||||
print "Added tests from %s" % fn
|
||||
except:
|
||||
print "%s does not contain a suite() method, skipping" % fn
|
||||
return unittest.TestSuite(suite_list)
|
||||
|
||||
|
||||
def col2( c1, c2, w=72 ):
|
||||
return "%s%s" % (c1, c2.rjust(w-len(c1)))
|
||||
|
||||
if __name__ == "__main__":
|
||||
print '----------------------------------------------------------------------'
|
||||
print 'Searching for tests...'
|
||||
print '----------------------------------------------------------------------'
|
||||
suite = suites( os.path.dirname( os.path.realpath(__file__) ))
|
||||
print '----------------------------------------------------------------------'
|
||||
print 'Running tests...'
|
||||
print '----------------------------------------------------------------------'
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
Reference in New Issue
Block a user