Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Selfie_with_Python/Selfie_with_Python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import cv2
cam = cv2.VideoCapture(0)
cv2.namedWindow("Take selfie with python")
img=0
while True:
ret, frame = cam.read()

if not ret:
print("Failed to grab frame")
break

cv2.imshow("Take selfie with python",frame)
k = cv2.waitKey(1)
if k%256 == 27:
print("Escape hit, closing the window")
break
if k%256 == 32:
img_name = f"Selfie_{img}.jpg"
cv2.imwrite(img_name,frame)
print("Selfie taken!")
img+=1
cam.release
cv2.destroyAllWindows()