removed the obsolete tests from the trunk as well.

pull/13383/head
Vadim Pisarevsky 14 years ago
parent 832262e376
commit 25887e693b
  1. 9
      tests/CMakeLists.txt
  2. 358
      tests/python/camera_calibration.py
  3. 34
      tests/python/goodfeatures.py
  4. 7
      tests/python/leak1.py
  5. 10
      tests/python/leak2.py
  6. 6
      tests/python/leak3.py
  7. 9
      tests/python/leak4.py
  8. 2177
      tests/python/test.py
  9. 61
      tests/python/test_functions.py
  10. 16
      tests/python/ticket_6.py
  11. 89
      tests/python/tickets.py
  12. 1705
      tests/python/transformations.py
  13. 61
      tests/swig_python/cmp_tests.py
  14. 81
      tests/swig_python/cvtestutils.py
  15. 54
      tests/swig_python/feature_tree_tests.py
  16. 39
      tests/swig_python/highgui/cvCreateFileCapture.py
  17. 18
      tests/swig_python/highgui/cvCreateFileCaptureRGB.py
  18. 17
      tests/swig_python/highgui/cvCreateFileCaptureRGBA.py
  19. 17
      tests/swig_python/highgui/cvCreateFileCaptureUYVY.py
  20. 17
      tests/swig_python/highgui/cvCreateFileCaptureY8.py
  21. 17
      tests/swig_python/highgui/cvCreateFileCaptureYUY2.py
  22. 17
      tests/swig_python/highgui/cvCreateFileCaptureYV12.py
  23. 17
      tests/swig_python/highgui/cvCreateFileCaptureYV16.py
  24. 17
      tests/swig_python/highgui/cvCreateFileCaptureYVU9.py
  25. 95
      tests/swig_python/highgui/cvCreateTrackbar.py
  26. 55
      tests/swig_python/highgui/cvGetCaptureProperty.py
  27. 57
      tests/swig_python/highgui/cvGetSetTrackbarPos.py
  28. 43
      tests/swig_python/highgui/cvGetWindowHandleName.py
  29. 46
      tests/swig_python/highgui/cvGrabFrame.py
  30. 33
      tests/swig_python/highgui/cvInitSystem.py
  31. 45
      tests/swig_python/highgui/cvLoadImage.py
  32. 22
      tests/swig_python/highgui/cvLoadImageBMP.py
  33. 22
      tests/swig_python/highgui/cvLoadImageJPG.py
  34. 22
      tests/swig_python/highgui/cvLoadImagePNG.py
  35. 22
      tests/swig_python/highgui/cvLoadImagePPM.py
  36. 22
      tests/swig_python/highgui/cvLoadImageSR.py
  37. 22
      tests/swig_python/highgui/cvLoadImageTIFF.py
  38. 43
      tests/swig_python/highgui/cvMoveResizeWindow.py
  39. 41
      tests/swig_python/highgui/cvNamedWindow.py
  40. 47
      tests/swig_python/highgui/cvQueryFrame.py
  41. 53
      tests/swig_python/highgui/cvRetrieveFrame.py
  42. 50
      tests/swig_python/highgui/cvSaveImage.py
  43. 77
      tests/swig_python/highgui/cvSetMouseCallback.py
  44. 61
      tests/swig_python/highgui/cvShowImage.py
  45. 45
      tests/swig_python/highgui/cvWaitKey.py
  46. 5
      tests/swig_python/highgui/frames.py
  47. 60
      tests/swig_python/highgui/match.py
  48. 32
      tests/swig_python/highgui/query_3gp.py
  49. 32
      tests/swig_python/highgui/query_bmp24.py
  50. 32
      tests/swig_python/highgui/query_bmp32.py
  51. 32
      tests/swig_python/highgui/query_cinepak.py
  52. 32
      tests/swig_python/highgui/query_divx.py
  53. 32
      tests/swig_python/highgui/query_dv_pal_progressive_avi.py
  54. 32
      tests/swig_python/highgui/query_dv_pal_progressive_dv.py
  55. 33
      tests/swig_python/highgui/query_huffyuv.py
  56. 32
      tests/swig_python/highgui/query_indeo.py
  57. 33
      tests/swig_python/highgui/query_mpeg4.py
  58. 44
      tests/swig_python/highgui/query_test.py
  59. 32
      tests/swig_python/highgui/query_uncompressed.py
  60. 32
      tests/swig_python/highgui/query_wmv9.py
  61. 32
      tests/swig_python/highgui/seek_frame_3gp.py
  62. 32
      tests/swig_python/highgui/seek_frame_bmp24.py
  63. 32
      tests/swig_python/highgui/seek_frame_bmp32.py
  64. 32
      tests/swig_python/highgui/seek_frame_cinepak.py
  65. 32
      tests/swig_python/highgui/seek_frame_divx.py
  66. 32
      tests/swig_python/highgui/seek_frame_dv_pal_progressive_avi.py
  67. 32
      tests/swig_python/highgui/seek_frame_dv_pal_progressive_dv.py
  68. 32
      tests/swig_python/highgui/seek_frame_huffyuv.py
  69. 32
      tests/swig_python/highgui/seek_frame_indeo.py
  70. 32
      tests/swig_python/highgui/seek_frame_mpeg4.py
  71. 32
      tests/swig_python/highgui/seek_frame_uncompressed.py
  72. 32
      tests/swig_python/highgui/seek_frame_wmv9.py
  73. 146
      tests/swig_python/highgui/seek_test.py
  74. 32
      tests/swig_python/highgui/seek_time_3gp.py
  75. 32
      tests/swig_python/highgui/seek_time_bmp24.py
  76. 32
      tests/swig_python/highgui/seek_time_bmp32.py
  77. 32
      tests/swig_python/highgui/seek_time_cinepak.py
  78. 32
      tests/swig_python/highgui/seek_time_divx.py
  79. 32
      tests/swig_python/highgui/seek_time_dv_pal_progressive_avi.py
  80. 32
      tests/swig_python/highgui/seek_time_dv_pal_progressive_dv.py
  81. 32
      tests/swig_python/highgui/seek_time_huffyuv.py
  82. 32
      tests/swig_python/highgui/seek_time_indeo.py
  83. 32
      tests/swig_python/highgui/seek_time_mpeg4.py
  84. 32
      tests/swig_python/highgui/seek_time_uncompressed.py
  85. 32
      tests/swig_python/highgui/seek_time_wmv9.py
  86. 31
      tests/swig_python/highgui/size_3gp.py
  87. 31
      tests/swig_python/highgui/size_bmp24.py
  88. 31
      tests/swig_python/highgui/size_bmp32.py
  89. 31
      tests/swig_python/highgui/size_cinepak.py
  90. 31
      tests/swig_python/highgui/size_divx.py
  91. 31
      tests/swig_python/highgui/size_dv_pal_progressive_avi.py
  92. 31
      tests/swig_python/highgui/size_dv_pal_progressive_dv.py
  93. 31
      tests/swig_python/highgui/size_huffyuv.py
  94. 31
      tests/swig_python/highgui/size_indeo.py
  95. 31
      tests/swig_python/highgui/size_mpeg4.py
  96. 54
      tests/swig_python/highgui/size_test.py
  97. 31
      tests/swig_python/highgui/size_uncompressed.py
  98. 31
      tests/swig_python/highgui/size_wmv9.py
  99. 29
      tests/swig_python/highgui/works.py
  100. 40
      tests/swig_python/histogram_tests.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,9 +0,0 @@
#ENABLE_TESTING()
#add_subdirectory(cv)
#add_subdirectory(cxcore)
#add_subdirectory(ml)
#add_subdirectory(cxts)
#add_subdirectory(gpu)

@ -1,358 +0,0 @@
import sys
import math
import time
import random
import numpy
import transformations
import cv
def clamp(a, x, b):
return numpy.maximum(a, numpy.minimum(x, b))
def norm(v):
mag = numpy.sqrt(sum([e * e for e in v]))
return v / mag
class Vec3:
def __init__(self, x, y, z):
self.v = (x, y, z)
def x(self):
return self.v[0]
def y(self):
return self.v[1]
def z(self):
return self.v[2]
def __repr__(self):
return "<Vec3 (%s,%s,%s)>" % tuple([repr(c) for c in self.v])
def __add__(self, other):
return Vec3(*[self.v[i] + other.v[i] for i in range(3)])
def __sub__(self, other):
return Vec3(*[self.v[i] - other.v[i] for i in range(3)])
def __mul__(self, other):
if isinstance(other, Vec3):
return Vec3(*[self.v[i] * other.v[i] for i in range(3)])
else:
return Vec3(*[self.v[i] * other for i in range(3)])
def mag2(self):
return sum([e * e for e in self.v])
def __abs__(self):
return numpy.sqrt(sum([e * e for e in self.v]))
def norm(self):
return self * (1.0 / abs(self))
def dot(self, other):
return sum([self.v[i] * other.v[i] for i in range(3)])
def cross(self, other):
(ax, ay, az) = self.v
(bx, by, bz) = other.v
return Vec3(ay * bz - by * az, az * bx - bz * ax, ax * by - bx * ay)
class Ray:
def __init__(self, o, d):
self.o = o
self.d = d
def project(self, d):
return self.o + self.d * d
class Camera:
def __init__(self, F):
R = Vec3(1., 0., 0.)
U = Vec3(0, 1., 0)
self.center = Vec3(0, 0, 0)
self.pcenter = Vec3(0, 0, F)
self.up = U
self.right = R
def genray(self, x, y):
""" -1 <= y <= 1 """
r = numpy.sqrt(x * x + y * y)
if 0:
rprime = r + (0.17 * r**2)
else:
rprime = (10 * numpy.sqrt(17 * r + 25) - 50) / 17
print "scale", rprime / r
x *= rprime / r
y *= rprime / r
o = self.center
r = (self.pcenter + (self.right * x) + (self.up * y)) - o
return Ray(o, r.norm())
class Sphere:
def __init__(self, center, radius):
self.center = center
self.radius = radius
def hit(self, r):
# a = mag2(r.d)
a = 1.
v = r.o - self.center
b = 2 * r.d.dot(v)
c = self.center.mag2() + r.o.mag2() + -2 * self.center.dot(r.o) - (self.radius ** 2)
det = (b * b) - (4 * c)
pred = 0 < det
sq = numpy.sqrt(abs(det))
h0 = (-b - sq) / (2)
h1 = (-b + sq) / (2)
h = numpy.minimum(h0, h1)
pred = pred & (h > 0)
normal = (r.project(h) - self.center) * (1.0 / self.radius)
return (pred, numpy.where(pred, h, 999999.), normal)
def pt2plane(p, plane):
return p.dot(plane) * (1. / abs(plane))
class Plane:
def __init__(self, p, n, right):
self.D = -pt2plane(p, n)
self.Pn = n
self.right = right
self.rightD = -pt2plane(p, right)
self.up = n.cross(right)
self.upD = -pt2plane(p, self.up)
def hit(self, r):
Vd = self.Pn.dot(r.d)
V0 = -(self.Pn.dot(r.o) + self.D)
h = V0 / Vd
pred = (0 <= h)
return (pred, numpy.where(pred, h, 999999.), self.Pn)
def localxy(self, loc):
x = (loc.dot(self.right) + self.rightD)
y = (loc.dot(self.up) + self.upD)
return (x, y)
# lena = numpy.fromstring(cv.LoadImage("../samples/c/lena.jpg", 0).tostring(), numpy.uint8) / 255.0
def texture(xy):
x,y = xy
xa = numpy.floor(x * 512)
ya = numpy.floor(y * 512)
a = (512 * ya) + xa
safe = (0 <= x) & (0 <= y) & (x < 1) & (y < 1)
if 0:
a = numpy.where(safe, a, 0).astype(numpy.int)
return numpy.where(safe, numpy.take(lena, a), 0.0)
else:
xi = numpy.floor(x * 11).astype(numpy.int)
yi = numpy.floor(y * 11).astype(numpy.int)
inside = (1 <= xi) & (xi < 10) & (2 <= yi) & (yi < 9)
checker = (xi & 1) ^ (yi & 1)
final = numpy.where(inside, checker, 1.0)
return numpy.where(safe, final, 0.5)
def under(vv, m):
return Vec3(*(numpy.dot(m, vv.v + (1,))[:3]))
class Renderer:
def __init__(self, w, h, oversample):
self.w = w
self.h = h
random.seed(1)
x = numpy.arange(self.w*self.h) % self.w
y = numpy.floor(numpy.arange(self.w*self.h) / self.w)
h2 = h / 2.0
w2 = w / 2.0
self.r = [ None ] * oversample
for o in range(oversample):
stoch_x = numpy.random.rand(self.w * self.h)
stoch_y = numpy.random.rand(self.w * self.h)
nx = (x + stoch_x - 0.5 - w2) / h2
ny = (y + stoch_y - 0.5 - h2) / h2
self.r[o] = cam.genray(nx, ny)
self.rnds = [random.random() for i in range(10)]
def frame(self, i):
rnds = self.rnds
roll = math.sin(i * .01 * rnds[0] + rnds[1])
pitch = math.sin(i * .01 * rnds[2] + rnds[3])
yaw = math.pi * math.sin(i * .01 * rnds[4] + rnds[5])
x = math.sin(i * 0.01 * rnds[6])
y = math.sin(i * 0.01 * rnds[7])
x,y,z = -0.5,0.5,1
roll,pitch,yaw = (0,0,0)
z = 4 + 3 * math.sin(i * 0.1 * rnds[8])
print z
rz = transformations.euler_matrix(roll, pitch, yaw)
p = Plane(Vec3(x, y, z), under(Vec3(0,0,-1), rz), under(Vec3(1, 0, 0), rz))
acc = 0
for r in self.r:
(pred, h, norm) = p.hit(r)
l = numpy.where(pred, texture(p.localxy(r.project(h))), 0.0)
acc += l
acc *= (1.0 / len(self.r))
# print "took", time.time() - st
img = cv.CreateMat(self.h, self.w, cv.CV_8UC1)
cv.SetData(img, (clamp(0, acc, 1) * 255).astype(numpy.uint8).tostring(), self.w)
return img
#########################################################################
num_x_ints = 8
num_y_ints = 6
num_pts = num_x_ints * num_y_ints
def get_corners(mono, refine = False):
(ok, corners) = cv.FindChessboardCorners(mono, (num_x_ints, num_y_ints), cv.CV_CALIB_CB_ADAPTIVE_THRESH | cv.CV_CALIB_CB_NORMALIZE_IMAGE)
if refine and ok:
corners = cv.FindCornerSubPix(mono, corners, (5,5), (-1,-1), ( cv.CV_TERMCRIT_EPS+cv.CV_TERMCRIT_ITER, 30, 0.1 ))
return (ok, corners)
def mk_object_points(nimages, squaresize = 1):
opts = cv.CreateMat(nimages * num_pts, 3, cv.CV_32FC1)
for i in range(nimages):
for j in range(num_pts):
opts[i * num_pts + j, 0] = (j / num_x_ints) * squaresize
opts[i * num_pts + j, 1] = (j % num_x_ints) * squaresize
opts[i * num_pts + j, 2] = 0
return opts
def mk_image_points(goodcorners):
ipts = cv.CreateMat(len(goodcorners) * num_pts, 2, cv.CV_32FC1)
for (i, co) in enumerate(goodcorners):
for j in range(num_pts):
ipts[i * num_pts + j, 0] = co[j][0]
ipts[i * num_pts + j, 1] = co[j][1]
return ipts
def mk_point_counts(nimages):
npts = cv.CreateMat(nimages, 1, cv.CV_32SC1)
for i in range(nimages):
npts[i, 0] = num_pts
return npts
def cvmat_iterator(cvmat):
for i in range(cvmat.rows):
for j in range(cvmat.cols):
yield cvmat[i,j]
cam = Camera(3.0)
rend = Renderer(640, 480, 2)
cv.NamedWindow("snap")
#images = [rend.frame(i) for i in range(0, 2000, 400)]
images = [rend.frame(i) for i in [1200]]
if 0:
for i,img in enumerate(images):
cv.SaveImage("final/%06d.png" % i, img)
size = cv.GetSize(images[0])
corners = [get_corners(i) for i in images]
goodcorners = [co for (im, (ok, co)) in zip(images, corners) if ok]
def checkerboard_error(xformed):
def pt2line(a, b, c):
x0,y0 = a
x1,y1 = b
x2,y2 = c
return abs((x2 - x1) * (y1 - y0) - (x1 - x0) * (y2 - y1)) / math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
errorsum = 0.
for im in xformed:
for row in range(6):
l0 = im[8 * row]
l1 = im[8 * row + 7]
for col in range(1, 7):
e = pt2line(im[8 * row + col], l0, l1)
#print "row", row, "e", e
errorsum += e
return errorsum
if True:
from scipy.optimize import fmin
def xf(pt, poly):
x, y = pt
r = math.sqrt((x - 320) ** 2 + (y - 240) ** 2)
fr = poly(r) / r
return (320 + (x - 320) * fr, 240 + (y - 240) * fr)
def silly(p, goodcorners):
# print "eval", p
d = 1.0 # - sum(p)
poly = numpy.poly1d(list(p) + [d, 0.])
xformed = [[xf(pt, poly) for pt in co] for co in goodcorners]
return checkerboard_error(xformed)
x0 = [ 0. ]
#print silly(x0, goodcorners)
print "initial error", silly(x0, goodcorners)
xopt = fmin(silly, x0, args=(goodcorners,))
print "xopt", xopt
print "final error", silly(xopt, goodcorners)
d = 1.0 # - sum(xopt)
poly = numpy.poly1d(list(xopt) + [d, 0.])
print "final polynomial"
print poly
for co in goodcorners:
scrib = cv.CreateMat(480, 640, cv.CV_8UC3)
cv.SetZero(scrib)
cv.DrawChessboardCorners(scrib, (num_x_ints, num_y_ints), [xf(pt, poly) for pt in co], True)
cv.ShowImage("snap", scrib)
cv.WaitKey()
sys.exit(0)
for (i, (img, (ok, co))) in enumerate(zip(images, corners)):
scrib = cv.CreateMat(img.rows, img.cols, cv.CV_8UC3)
cv.CvtColor(img, scrib, cv.CV_GRAY2BGR)
if ok:
cv.DrawChessboardCorners(scrib, (num_x_ints, num_y_ints), co, True)
cv.ShowImage("snap", scrib)
cv.WaitKey()
print len(goodcorners)
ipts = mk_image_points(goodcorners)
opts = mk_object_points(len(goodcorners), .1)
npts = mk_point_counts(len(goodcorners))
intrinsics = cv.CreateMat(3, 3, cv.CV_64FC1)
distortion = cv.CreateMat(4, 1, cv.CV_64FC1)
cv.SetZero(intrinsics)
cv.SetZero(distortion)
# focal lengths have 1/1 ratio
intrinsics[0,0] = 1.0
intrinsics[1,1] = 1.0
cv.CalibrateCamera2(opts, ipts, npts,
cv.GetSize(images[0]),
intrinsics,
distortion,
cv.CreateMat(len(goodcorners), 3, cv.CV_32FC1),
cv.CreateMat(len(goodcorners), 3, cv.CV_32FC1),
flags = 0) # cv.CV_CALIB_ZERO_TANGENT_DIST)
print "D =", list(cvmat_iterator(distortion))
print "K =", list(cvmat_iterator(intrinsics))
mapx = cv.CreateImage((640, 480), cv.IPL_DEPTH_32F, 1)
mapy = cv.CreateImage((640, 480), cv.IPL_DEPTH_32F, 1)
cv.InitUndistortMap(intrinsics, distortion, mapx, mapy)
for img in images:
r = cv.CloneMat(img)
cv.Remap(img, r, mapx, mapy)
cv.ShowImage("snap", r)
cv.WaitKey()

@ -1,34 +0,0 @@
import cv
import unittest
class TestGoodFeaturesToTrack(unittest.TestCase):
def test(self):
arr = cv.LoadImage("../samples/c/lena.jpg", 0)
original = cv.CloneImage(arr)
size = cv.GetSize(arr)
eig_image = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
temp_image = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
threshes = [ x / 100. for x in range(1,10) ]
results = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, use_harris = 1)) for t in threshes])
# Check that GoodFeaturesToTrack has not modified input image
self.assert_(arr.tostring() == original.tostring())
# Check for repeatability
for i in range(10):
results2 = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, use_harris = 1)) for t in threshes])
self.assert_(results == results2)
for t0,t1 in zip(threshes, threshes[1:]):
r0 = results[t0]
r1 = results[t1]
# Increasing thresh should make result list shorter
self.assert_(len(r0) > len(r1))
# Increasing thresh should monly truncate result list
self.assert_(r0[:len(r1)] == r1)
if __name__ == '__main__':
unittest.main()

@ -1,7 +0,0 @@
import cv
import numpy as np
cv.NamedWindow('Leak')
while 1:
leak = np.random.random((480, 640)) * 255
cv.ShowImage('Leak', leak.astype(np.uint8))
cv.WaitKey(10)

@ -1,10 +0,0 @@
import cv
import numpy as np
import time
while True:
for i in range(4000):
a = cv.CreateImage((1024,1024), cv.IPL_DEPTH_8U, 1)
b = cv.CreateMat(1024, 1024, cv.CV_8UC1)
c = cv.CreateMatND([1024,1024], cv.CV_8UC1)
print "pause..."

@ -1,6 +0,0 @@
import cv
import math
import time
while True:
h = cv.CreateHist([40], cv.CV_HIST_ARRAY, [[0,255]], 1)

@ -1,9 +0,0 @@
import cv
import math
import time
N=50000
print "leak4"
while True:
seq=list((i*1., i*1.) for i in range(N))
cv.Moments(seq)

File diff suppressed because it is too large Load Diff

@ -1,61 +0,0 @@
import sys
import cv
def hs_histogram(src):
# Convert to HSV
hsv = cv.CreateImage(cv.GetSize(src), 8, 3)
cv.CvtColor(src, hsv, cv.CV_BGR2HSV)
# Extract the H and S planes
h_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
s_plane = cv.CreateMat(src.rows, src.cols, cv.CV_8UC1)
cv.Split(hsv, h_plane, s_plane, None, None)
planes = [h_plane, s_plane]
h_bins = 30
s_bins = 32
hist_size = [h_bins, s_bins]
# hue varies from 0 (~0 deg red) to 180 (~360 deg red again */
h_ranges = [0, 180]
# saturation varies from 0 (black-gray-white) to
# 255 (pure spectrum color)
s_ranges = [0, 255]
ranges = [h_ranges, s_ranges]
scale = 10
hist = cv.CreateHist([h_bins, s_bins], cv.CV_HIST_ARRAY, ranges, 1)
cv.CalcHist([cv.GetImage(i) for i in planes], hist)
(_, max_value, _, _) = cv.GetMinMaxHistValue(hist)
hist_img = cv.CreateImage((h_bins*scale, s_bins*scale), 8, 3)
for h in range(h_bins):
for s in range(s_bins):
bin_val = cv.QueryHistValue_2D(hist, h, s)
intensity = cv.Round(bin_val * 255 / max_value)
cv.Rectangle(hist_img,
(h*scale, s*scale),
((h+1)*scale - 1, (s+1)*scale - 1),
cv.RGB(intensity, intensity, intensity),
cv.CV_FILLED)
return hist_img
def precornerdetect(image):
# assume that the image is floating-point
corners = cv.CloneMat(image)
cv.PreCornerDetect(image, corners, 3)
dilated_corners = cv.CloneMat(image)
cv.Dilate(corners, dilated_corners, None, 1)
corner_mask = cv.CreateMat(image.rows, image.cols, cv.CV_8UC1)
cv.Sub(corners, dilated_corners, corners)
cv.CmpS(corners, 0, corner_mask, cv.CV_CMP_GE)
return (corners, corner_mask)
def findstereocorrespondence(image_left, image_right):
# image_left and image_right are the input 8-bit single-channel images
# from the left and the right cameras, respectively
(r, c) = (image_left.rows, image_left.cols)
disparity_left = cv.CreateMat(r, c, cv.CV_16S)
disparity_right = cv.CreateMat(r, c, cv.CV_16S)
state = cv.CreateStereoGCState(16, 2)
cv.FindStereoCorrespondenceGC(image_left, image_right, disparity_left, disparity_right, state, 0)
return (disparity_left, disparity_right)

@ -1,16 +0,0 @@
import urllib
import cv
import Image
import unittest
class TestLoadImage(unittest.TestCase):
def setUp(self):
open("large.jpg", "w").write(urllib.urlopen("http://www.cs.ubc.ca/labs/lci/curious_george/img/ROS_bug_imgs/IMG_3560.jpg").read())
def test_load(self):
pilim = Image.open("large.jpg")
cvim = cv.LoadImage("large.jpg")
self.assert_(len(pilim.tostring()) == len(cvim.tostring()))
if __name__ == '__main__':
unittest.main()

@ -1,89 +0,0 @@
import unittest
import random
import time
import math
import sys
import array
import os
import cv
def find_sample(s):
for d in ["../samples/c/", "../doc/pics/"]:
path = os.path.join(d, s)
if os.access(path, os.R_OK):
return path
return s
class TestTickets(unittest.TestCase):
def test_2542670(self):
xys = [(94, 121), (94, 122), (93, 123), (92, 123), (91, 124), (91, 125), (91, 126), (92, 127), (92, 128), (92, 129), (92, 130), (92, 131), (91, 132), (90, 131), (90, 130), (90, 131), (91, 132), (92, 133), (92, 134), (93, 135), (94, 136), (94, 137), (94, 138), (95, 139), (96, 140), (96, 141), (96, 142), (96, 143), (97, 144), (97, 145), (98, 146), (99, 146), (100, 146), (101, 146), (102, 146), (103, 146), (104, 146), (105, 146), (106, 146), (107, 146), (108, 146), (109, 146), (110, 146), (111, 146), (112, 146), (113, 146), (114, 146), (115, 146), (116, 146), (117, 146), (118, 146), (119, 146), (120, 146), (121, 146), (122, 146), (123, 146), (124, 146), (125, 146), (126, 146), (126, 145), (126, 144), (126, 143), (126, 142), (126, 141), (126, 140), (127, 139), (127, 138), (127, 137), (127, 136), (127, 135), (127, 134), (127, 133), (128, 132), (129, 132), (130, 131), (131, 130), (131, 129), (131, 128), (132, 127), (133, 126), (134, 125), (134, 124), (135, 123), (136, 122), (136, 121), (135, 121), (134, 121), (133, 121), (132, 121), (131, 121), (130, 121), (129, 121), (128, 121), (127, 121), (126, 121), (125, 121), (124, 121), (123, 121), (122, 121), (121, 121), (120, 121), (119, 121), (118, 121), (117, 121), (116, 121), (115, 121), (114, 121), (113, 121), (112, 121), (111, 121), (110, 121), (109, 121), (108, 121), (107, 121), (106, 121), (105, 121), (104, 121), (103, 121), (102, 121), (101, 121), (100, 121), (99, 121), (98, 121), (97, 121), (96, 121), (95, 121)]
#xys = xys[:12] + xys[16:]
pts = cv.CreateMat(len(xys), 1, cv.CV_32SC2)
for i,(x,y) in enumerate(xys):
pts[i,0] = (x, y)
storage = cv.CreateMemStorage()
hull = cv.ConvexHull2(pts, storage)
hullp = cv.ConvexHull2(pts, storage, return_points = 1)
defects = cv.ConvexityDefects(pts, hull, storage)
vis = cv.CreateImage((1000,1000), 8, 3)
x0 = min([x for (x,y) in xys]) - 10
x1 = max([x for (x,y) in xys]) + 10
y0 = min([y for (y,y) in xys]) - 10
y1 = max([y for (y,y) in xys]) + 10
def xform(pt):
x,y = pt
return (1000 * (x - x0) / (x1 - x0),
1000 * (y - y0) / (y1 - y0))
for d in defects[:2]:
cv.Zero(vis)
# First draw the defect as a red triangle
cv.FillConvexPoly(vis, [xform(p) for p in d[:3]], cv.RGB(255,0,0))
# Draw the convex hull as a thick green line
for a,b in zip(hullp, hullp[1:]):
cv.Line(vis, xform(a), xform(b), cv.RGB(0,128,0), 3)
# Draw the original contour as a white line
for a,b in zip(xys, xys[1:]):
cv.Line(vis, xform(a), xform(b), (255,255,255))
self.snap(vis)
def test_2686307(self):
lena = cv.LoadImage(find_sample("lena.jpg"), 1)
dst = cv.CreateImage((512,512), 8, 3)
cv.Set(dst, (128,192,255))
mask = cv.CreateImage((512,512), 8, 1)
cv.Zero(mask)
cv.Rectangle(mask, (10,10), (300,100), 255, -1)
cv.Copy(lena, dst, mask)
self.snapL([lena, dst, mask])
m = cv.CreateMat(480, 640, cv.CV_8UC1)
print "ji", m
print m.rows, m.cols, m.type, m.step
def snap(self, img):
self.snapL([img])
def snapL(self, L):
for i,img in enumerate(L):
cv.NamedWindow("snap-%d" % i, 1)
cv.ShowImage("snap-%d" % i, img)
cv.WaitKey()
cv.DestroyAllWindows()
if __name__ == '__main__':
random.seed(0)
if len(sys.argv) == 1:
suite = unittest.TestLoader().loadTestsFromTestCase(TestTickets)
unittest.TextTestRunner(verbosity=2).run(suite)
else:
suite = unittest.TestSuite()
suite.addTest(TestTickets(sys.argv[1]))
unittest.TextTestRunner(verbosity=2).run(suite)

File diff suppressed because it is too large Load Diff

@ -1,61 +0,0 @@
#!/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())

@ -1,81 +0,0 @@
# 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

@ -1,54 +0,0 @@
#!/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)

@ -1,39 +0,0 @@
"""
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

@ -1,18 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,17 +0,0 @@
#! /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)

@ -1,95 +0,0 @@
#! /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)

@ -1,55 +0,0 @@
#! /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)

@ -1,57 +0,0 @@
#! /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)

@ -1,43 +0,0 @@
#! /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)

@ -1,46 +0,0 @@
#! /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)

@ -1,33 +0,0 @@
#! /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)

@ -1,45 +0,0 @@
"""
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

@ -1,22 +0,0 @@
#! /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)

@ -1,22 +0,0 @@
#! /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)

@ -1,22 +0,0 @@
#! /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)

@ -1,22 +0,0 @@
#! /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)

@ -1,22 +0,0 @@
#! /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)

@ -1,22 +0,0 @@
#! /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)

@ -1,43 +0,0 @@
#! /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)

@ -1,41 +0,0 @@
#! /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)

@ -1,47 +0,0 @@
#! /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)

@ -1,53 +0,0 @@
#! /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)

@ -1,50 +0,0 @@
#! /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)

@ -1,77 +0,0 @@
#! /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)

@ -1,61 +0,0 @@
#! /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)

@ -1,45 +0,0 @@
#! /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)

@ -1,5 +0,0 @@
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"]

@ -1,60 +0,0 @@
"""
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

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,33 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,33 +0,0 @@
#! /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)

@ -1,44 +0,0 @@
"""
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

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,146 +0,0 @@
"""
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

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,32 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,54 +0,0 @@
"""
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

@ -1,31 +0,0 @@
#! /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)

@ -1,31 +0,0 @@
#! /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)

@ -1,29 +0,0 @@
# 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

@ -1,40 +0,0 @@
#!/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())

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save