Skip to content

Commit 1b0f58a

Browse files
author
Tasha Kim
committed
opencv videocapture added
1 parent 110233c commit 1b0f58a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

mycam.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import numpy as np
2+
import cv2
3+
4+
from Arduino import Arduino
5+
import time
6+
7+
# Python-Arduino Command API
8+
board = Arduino("9600", port="/dev/cu.usbmodem14301")
9+
board.pinMode(13, "OUTPUT")
10+
cap = cv2.VideoCapture(0)
11+
12+
# OpenCV API
13+
while(True):
14+
ret, frame = cap.read()
15+
16+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
17+
if gray[200][200] < 50:
18+
board.digitalWrite(13, "HIGH")
19+
else:
20+
board.digitalWrite(13, "LOW")
21+
cv2.imshow('frame', gray)
22+
if cv2.waitKey(1) & 0xFF == ord('q'):
23+
break
24+
25+
cap.release()
26+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)