-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencv_test.py
executable file
·48 lines (38 loc) · 953 Bytes
/
opencv_test.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import cv2 as cv
from picamera import PiCamera
import time
def loop():
global frame, rval
# capture.set(15, -8.0)
# time.sleep(2)
rval, frame1 = capture.read()
# capture.set(15, -3.0)
# time.sleep(2)
# rval, frame2 = capture.read()
# rval, frame3 = capture.read()
# frame1 = frame1[0:100, 0:-1]
# frame2 = frame2[100:-1, 0:-1]
#
# frame[0:100,0:-1] = frame1
# frame[100:-1,0:-1] = frame2
cv.imshow('preview', frame1)
key = cv.waitKey(20)
if key == 27:
return False #break
return rval
#camera = PiCamera()
cv.namedWindow('preview')
capture = cv.VideoCapture(0)
camera = PiCamera()
if capture.isOpened():
rval, frame = capture.read()
else:
print('Could not open camera')
print("Have you tried running 'sudo modprobe bcm2835-v4l2' ?")
rval = False
if rval:
while loop():
continue
cv.destroyWindow('preview')
capture.release()