ret, frame = webcam.read() x = 0 while webcam.isOpened(): ret, frame = webcam.read() frame_1080p = np.zeros((720, 1920, 3)).astype(np.uint8) #Resize Frame BGR inputBGR = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25) #Convert to facial_recogntion encoding BGR -> RGB rgb_small_frame = inputBGR[:, :, ::-1] frame_count += 1 frames.append(rgb_small_frame) if stopButton.read(): break # Only process every other frame of video to save time if x % 4 == 0: # Find all the faces and face encodings in the current frame of video face_locations = face_recognition.face_locations(rgb_small_frame) face_encodings = face_recognition.face_encodings( rgb_small_frame, face_locations) face_names = [] for face_encoding in face_encodings: # See if the face is a match for the known face(s) matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
immaginee = frame[110:180, 140:210] b1, g1, r1 = cv2.split(immaginee) tmp = cv2.matchTemplate(r1, kern, cv2.TM_CCORR_NORMED) tmp = tmp * 254 minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(tmp) y_quad = maxLoc[1] + 8 x_quad = maxLoc[0] + 8 cv2.circle(frame, (x_quad + 140, y_quad + 110), 1, (255, 0, 0), 2) reset=Button(3) #CALIBRATION button = Button(1) if button.read() and acq: b,g,r = cv2.split(frame[110:180,140:210]) r=cv2.GaussianBlur(r,(5,5),0) r=cv2.Laplacian(r,cv2.CV_8U) r=cv2.medianBlur(r,3) circles=cv2.HoughCircles(r,cv2.HOUGH_GRADIENT,2,400,200,10,20) for j in circles[0,:]: j[0]=j[0]+140 j[1]=j[1]+110 cv2.circle(frame,(j[0],j[1]),j[2],(0,0,255),) cv2.circle(frame,(j[0],j[1]),1,(0,255,0),1) c.append([j[0], j[1]]) dist_init_y = -y_quad + j[1]
logger.debug("Starting now") while True: time.sleep(1) if run: LED_1.on() posted = False counter += 1 if worker( counter): # If we get a message successfully, reset timer timer = 0 else: # otherwise, keep track of failed messages (eg when car is off) timer += 1 LED_1.off() elif not posted: LED_POSTING.on() posted = serve_logs() # Stop running when we encounter too many failed messages if timer >= STOP_COUNT: LED_RUNNING.off() logger.debug("Stopped running, serving now") run = False timer = 0 elif rst.read() == 1: # on Button press start running LED_RUNNING.on() LED_POSTING.off() logger.debug("Started running") reset() run = True counter = 0
# Leds&Button assignements button = Button(0) led1 = LED(0) led2 = LED(1) # We have 2 players -- i<2 while (i<2): # Status Led: Ready to start if(i==0): led1.on() else: led2.on() # Wait button push while(button.read() == 0): time.sleep(0.1) # Check if correct if(i==0): led1.off() else: led2.off() values = [] sampling_time = 5 start = time.time() end = start while(end - start < sampling_time): value = pmod_adc.read(0)
cv2.rectangle(frame, (140, 110), (210, 180), (255, 0, 0), 2) immaginee = frame[110:180, 140:210] b1, g1, r1 = cv2.split(immaginee) tmp = cv2.matchTemplate(r1, kern, cv2.TM_CCORR_NORMED) tmp = tmp * 254 minVal, maxVal, minLoc, maxLoc = cv2.minMaxLoc(tmp) y_quad = maxLoc[1] + 8 x_quad = maxLoc[0] + 8 cv2.circle(frame, (x_quad + 140, y_quad + 110), 1, (255, 0, 0), 2) reset = Button(3) #CALIBRATION button = Button(1) if button.read() and acq: b, g, r = cv2.split(frame[110:180, 140:210]) r = cv2.GaussianBlur(r, (5, 5), 0) r = cv2.Laplacian(r, cv2.CV_8U) r = cv2.medianBlur(r, 3) circles = cv2.HoughCircles(r, cv2.HOUGH_GRADIENT, 2, 400, 200, 10, 20) for j in circles[0, :]: j[0] = j[0] + 140 j[1] = j[1] + 110 cv2.circle( frame, (j[0], j[1]),