# def register_feed():
import os
import cv2
path = '/UserImage'
cam = cv2.VideoCapture(0)
name=input("Name: ")

cv2.namedWindow("test")

img_counter = 0

while True:
    ret, frame = cam.read()
    if not ret:
        print("failed to grab frame")
        break
    else:
        cv2.imshow("test", frame)

        k = cv2.waitKey(1)
        if k%256 == 27:
            # ESC pressed
            print("Escape hit, closing...")
            break
        elif k%256 == 32:
            # SPACE pressed
            # img_name = "opencv_frame_{}.png".format(img_counter)
            cv2.imwrite(name + ".jpg", frame)
            # print("{} written!".format(img_name))
            print("Image Captured! Proceed...")
            img_counter += 1

cam.release()

cv2.destroyAllWindows()
[((70, 89), 'cv2.VideoCapture', 'cv2.VideoCapture', (['(0)'], {}), '(0)\n', (86, 89), False, 'import cv2\n'), ((112, 135), 'cv2.namedWindow', 'cv2.namedWindow', (['"""test"""'], {}), "('test')\n", (127, 135), False, 'import cv2\n'), ((758, 781), 'cv2.destroyAllWindows', 'cv2.destroyAllWindows', ([], {}), '()\n', (779, 781), False, 'import cv2\n'), ((280, 305), 'cv2.imshow', 'cv2.imshow', (['"""test"""', 'frame'], {}), "('test', frame)\n", (290, 305), False, 'import cv2\n'), ((319, 333), 'cv2.waitKey', 'cv2.waitKey', (['(1)'], {}), '(1)\n', (330, 333), False, 'import cv2\n'), ((579, 612), 'cv2.imwrite', 'cv2.imwrite', (["(name + '.jpg')", 'frame'], {}), "(name + '.jpg', frame)\n", (590, 612), False, 'import cv2\n')]