Advertisement
franciscominajas

CodigoObtenciónImagen

Sep 22nd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. from cv2 import *
  2. import serial, time
  3.  
  4. namedWindow("webcam")
  5. vc = VideoCapture(1);
  6.  
  7. while True:
  8.     next, frame = vc.read();
  9.     frame = cv2.drawMarker(frame, (300,100), (0,0,255), markerType=cv2.MARKER_TILTED_CROSS, markerSize=20, thickness=2, line_type=cv2.LINE_AA)
  10.     #(200,250)
  11.     #(400,250)
  12.     imshow("webcam", frame);
  13.     if waitKey(50) >= 0:
  14.         break;
  15.  
  16.     pixel1b, pixel1g, pixel1r= frame[300][100];
  17.    
  18.     rojo = pixel1r;
  19.     verde = pixel1g;
  20.     azul = pixel1b;
  21.  
  22.     #print("Rojo: ",rojo, " Verde: ", verde, " Azul: ",azul);
  23.    
  24.     Rojo = "r"+str(rojo)+"\n";
  25.     Verde = "v"+str(verde)+"\n";
  26.     Azul = "a"+str(azul)+"\n";
  27.  
  28.     arduino = serial.Serial("COM4", 9600)
  29.     time.sleep(2)
  30.     arduino.write(Rojo)
  31.     arduino.write(Verde)
  32.     arduino.write(Azul)
  33.     arduino.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement