-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcv.py
33 lines (29 loc) · 941 Bytes
/
testcv.py
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
import pvlib
import cv
import numpy as np
import time
if __name__ == "__main__":
try:
pv = pvlib.PvLib()
cams = pv.getCameras()
if not cams:
print "error getting camera list"
else:
cam = cams[0]
cam.startCapture()
while True:
frame = cam.capture()
cv.NamedWindow('capture', 1)
if frame.ImageSize == cam.frameSize:
im = np.array([ord(frame.ImageBuffer[x]) for x in range(frame.ImageSize)], dtype=np.int8)
print im.shape
im.shape = (frame.Height, frame.Width)
#print im
cv.ShowImage("capture", cv.fromarray(im))
cv.WaitKey(1)
print time.time()
else:
print "Bad frame"
finally:
if cam:
cam.stopCapture()