forked from sightmachine/SimpleCV
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvcamera_tests.py
More file actions
75 lines (63 loc) · 1.68 KB
/
Copy pathvcamera_tests.py
File metadata and controls
75 lines (63 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
import os, sys
from SimpleCV import *
from nose.tools import with_setup
testimage = "../sampleimages/9dots4lines.png"
testvideo = "../sampleimages/ball.mov"
testoutput = "standard/vc.jpg"
def doFullVCamCoverageTest(vcam):
run = True
count = 0
maxf = 1000
while run:
img = vcam.getImage()
vcam.getFrameNumber()
count = count + 1
if( img is None or count > maxf ):
run = False
vcam.rewind()
run = True
while run:
vcam.skipFrames(2)
img = vcam.getImage()
count = count + 1
if( img is None or count > maxf ):
run = False
return True
def test_camera_constructor():
mycam = VirtualCamera(testimage, "image")
props = mycam.getAllProperties()
for i in props.keys():
print str(i) + ": " + str(props[i]) + "\n"
pass
def test_camera_image():
mycam = VirtualCamera(testimage, "image")
if(doFullVCamCoverageTest(mycam)):
pass
else:
assert False
def test_camera_video():
mycam = VirtualCamera(testvideo, "video")
img = mycam.getImage()
img.save(testoutput)
assert img.size() == (320, 240)
if(doFullVCamCoverageTest(mycam)):
pass
else:
assert False
def test_camera_iset():
iset = ImageSet('./standard/')
mycam = VirtualCamera(iset, "imageset")
img = mycam.getImage()
if(doFullVCamCoverageTest(mycam)):
pass
else:
assert False
def test_camera_iset_directory():
iset = './standard/'
mycam = VirtualCamera(iset, "imageset")
img = mycam.getImage()
if(doFullVCamCoverageTest(mycam)):
pass
else:
assert False