def take_registration_photo(userId): # takes and saves ONE of a user's registration photos # see line 50 onwards rawCapture = PiRGBArray(CAMERA) time.sleep(0.1) CAMERA.capture(rawCapture, format="bgr") image = rawCapture.array() grayImage = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) faces = FACE_CASCADE.detectMultiScale(grayImage, 1.4) # gets the faces for this image # If face is detected, save that specific face for (x, y, w, h) in faces: croppedImage = grayImage[y: y + h, x: x + w] # crops it to be only the face tools.save_new_image(userId, croppedImage)
print("_______________________________________________CV Test________________________________________________") test.live_Detection(0, True) print("_______________________________________________rpi Test________________________________________________") test.rpi_live_Detection(True) from picamera.array import PiRGBArray from picamera import PiCamera camera = PiCamera() rawCapture = PiRGBArray(camera) camera.resolution = resolution print("______________________________________________RPI Displess test________________________________________________") time_rpi = timer(True) for i in range(250): camera.capture(rawCapture, "rgb") test.run_Detection(rawCapture.array()) time_rpi.toc() camera.close() print(time_rpi.average) print("_______________________________________________CV Displess test________________________________________________") time_cv = timer(True) cam = cv2.VideoCapture(0) for i in range(250): _, cap = cam.read() test.run_Detection(cap) time_cv.toc() cap.release() print(time_cv.average)