Commit fd56933d authored by Michael Murtaugh's avatar Michael Murtaugh

continuous loop

parent bc31dee7
This diff is collapsed.
......@@ -132,12 +132,14 @@ if __name__ == "__main__":
ap.add_argument("--width", type=int, default=640)
ap.add_argument("--height", type=int, default=480)
ap.add_argument("--rotate", type=int, default=0)
ap.add_argument("--vflip", default=False, action="store_true")
ap.add_argument("--models", default="./models", help="location of the cascade XML files, default: ./models")
ap.add_argument('--gpiobutton', type=int, default=None, help="use given gpio pin as button")
ap.add_argument("--button", default=False, action="store_true")
ap.add_argument('--usb', action="store_true", default=False)
ap.add_argument("--serial", default="/dev/serial0")
ap.add_argument("--baud", default=19200)
ap.add_argument("--sleep", default=5, type=int, help="time to sleep between photos")
ap.add_argument("--minsize", default=50, type=int, help="minsize of detected faces")
#ap.add_argument("--baud", default=19200)
# escpos.printer.Serial(devfile=u'/dev/ttyS0', baudrate=9600, bytesize=8, timeout=1, parity='N', stopbits=1, xonxoff=False, dsrdtr=True, *args, **kwargs)
......@@ -176,17 +178,20 @@ if __name__ == "__main__":
GPIO.output(19, True)
GPIO.output(19, False)
elif args.button:
raw_input("Press THE BUTTON to take a photo")
current_image, current_image_bgr = take_photo(, args.rotate, args.width, args.height)
current_faces = get_faces(face_cascade, current_image_bgr)
current_faces = [x for x in current_faces if x['width'] >= args.minsize]
n =
base = n.strftime("%Y%m%d_%H%M%S")
print (
print ("detected {0} faces".format(len(current_faces)))
image_fname = os.path.join("images", base + ".jpg")
if len(current_faces) > 0:
cv2.imwrite(image_fname, current_image)
print ("image saved to {0}".format(image_fname), file=sys.stderr)
......@@ -200,15 +205,17 @@ if __name__ == "__main__":
current_face = current_image[y1:y2, x1:x2]
current_face_bgr = current_image_bgr[y1:y2, x1:x2]
fname = os.path.join("images", base+"_f{0}.jpg".format(i))
# cv2.imwrite(fname, current_face)
# print ("Face saved to {0}".format(fname), file=sys.stderr)
current_face_pil = Image.fromarray(cv2.cvtColor(current_face_bgr,cv2.COLOR_BGR2RGB))
current_face_pil = make_print_version(current_face_pil)
fname = os.path.join("images", base+"_f{0}.jpg".format(i))
if args.usb:
printer.printImage(current_face_pil, LaaT=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment