summaryrefslogtreecommitdiff
path: root/face-detection/01_face_capture_dataset.py
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-05-09 14:25:25 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-05-09 14:25:25 +0530
commitbaeb2249ee30144b3eb266d53117b6fae5dadb0c (patch)
tree74db9547bbb28d1f446438e682479f33c9fc3154 /face-detection/01_face_capture_dataset.py
parent87c29457ed425d1ff35cdbb684a534678fa29d6a (diff)
Enhanced code to handle creation of 'dataset' & 'trainer' folder for saving images and model
Diffstat (limited to 'face-detection/01_face_capture_dataset.py')
-rw-r--r--face-detection/01_face_capture_dataset.py3
1 files changed, 3 insertions, 0 deletions
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