# 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()
[((5, 6, 5, 25), 'cv2.VideoCapture', 'cv2.VideoCapture', ({(5, 23, 5, 24): '0'}, {}), '(0)', False, 'import cv2\n'), ((8, 0, 8, 23), 'cv2.namedWindow', 'cv2.namedWindow', ({(8, 16, 8, 22): '"""test"""'}, {}), "('test')", False, 'import cv2\n'), ((35, 0, 35, 23), 'cv2.destroyAllWindows', 'cv2.destroyAllWindows', ({}, {}), '()', False, 'import cv2\n'), ((18, 8, 18, 33), 'cv2.imshow', 'cv2.imshow', ({(18, 19, 18, 25): '"""test"""', (18, 27, 18, 32): 'frame'}, {}), "('test', frame)", False, 'import cv2\n'), ((20, 12, 20, 26), 'cv2.waitKey', 'cv2.waitKey', ({(20, 24, 20, 25): '1'}, {}), '(1)', False, 'import cv2\n'), ((28, 12, 28, 45), 'cv2.imwrite', 'cv2.imwrite', ({(28, 24, 28, 37): "(name + '.jpg')", (28, 39, 28, 44): 'frame'}, {}), "(name + '.jpg', frame)", False, 'import cv2\n')]