From baeb2249ee30144b3eb266d53117b6fae5dadb0c Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Tue, 9 May 2023 14:25:25 +0530 Subject: Enhanced code to handle creation of 'dataset' & 'trainer' folder for saving images and model --- face-detection/01_face_capture_dataset.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'face-detection/01_face_capture_dataset.py') diff --git a/face-detection/01_face_capture_dataset.py b/face-detection/01_face_capture_dataset.py index ef40a82..d7ac82c 100644 --- a/face-detection/01_face_capture_dataset.py +++ b/face-detection/01_face_capture_dataset.py @@ -40,6 +40,9 @@ while True: #create a bounding box across the detected face cv2.rectangle(frame, (x,y), (x+w,y+h), (255,0,0), 3) #tuple count += 1 # increment count + # if dataset folder doesnt exist create: + if not os.path.exists("dataset"): + os.makedirs("dataset") # Save the captured bounded-grayscaleimage into the datasets folder cv2.imwrite("dataset/User." + str(face_id) + '.' + str(count) + ".jpg", frameGray[y:y+h,x:x+w]) #req os # Display the original frame to the user -- cgit v1.2.3