# Make a camera stream cap = cv2.VideoCapture(-1) cap.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS, BRIGHTNESS) cap.set(cv2.cv.CV_CAP_PROP_CONTRAST, CONTRAST) cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, WIDTH) cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, HEIGHT) while True: # Get an image from the camera if args.file: image = cv2.imread("img/target/" + args.file, -1) else: ret, image = cap.read() to_send, processed_image = findTarget(image) if not to_send['w']: if args.verbose: print "No target found" else: if args.verbose: print "X:" + str(to_send['x']) + " Y:" + str(to_send['y']) + " Width:" + str(to_send['w']) + " Height:" + str(to_send['h']) + " Angle:" + str(to_send['angle']) server.udp_send(to_send.values()) if args.live or args.file: cv2.imshow("Live Capture", processed_image) if cv2.waitKey(1) & 0xFF == ord('q'): break if args.stream: sys.stdout.write( processed_image.tostring() )
from server import udp_send import time while True: packet = [5, 8, 3] udp_send(packet) print "sent" time.sleep(0.1)