Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from cv2 import *
- import serial, time
- namedWindow("webcam")
- vc = VideoCapture(1);
- while True:
- next, frame = vc.read();
- frame = cv2.drawMarker(frame, (300,100), (0,0,255), markerType=cv2.MARKER_TILTED_CROSS, markerSize=20, thickness=2, line_type=cv2.LINE_AA)
- #(200,250)
- #(400,250)
- imshow("webcam", frame);
- if waitKey(50) >= 0:
- break;
- pixel1b, pixel1g, pixel1r= frame[300][100];
- rojo = pixel1r;
- verde = pixel1g;
- azul = pixel1b;
- #print("Rojo: ",rojo, " Verde: ", verde, " Azul: ",azul);
- Rojo = "r"+str(rojo)+"\n";
- Verde = "v"+str(verde)+"\n";
- Azul = "a"+str(azul)+"\n";
- arduino = serial.Serial("COM4", 9600)
- time.sleep(2)
- arduino.write(Rojo)
- arduino.write(Verde)
- arduino.write(Azul)
- arduino.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement