File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+
3+ import cv2
4+ import click
5+ import os
6+
7+ @click .command ()
8+ @click .option (
9+ "--directory" , default = "None" , help = "Directory in which to store frames"
10+ )
11+ @click .option (
12+ "--name" , default = "person" , help = "Directory in which to store frames"
13+ )
14+ def main (name , directory ):
15+ if directory == "None" :
16+ directory = os .getcwd ()
17+ capture = cv2 .VideoCapture (0 )
18+ frame_count = 0
19+ while True :
20+ ret , frame = capture .read ()
21+ frame = cv2 .resize (frame , (600 ,600 ))
22+ cv2 .imshow ("frame" , frame )
23+ key = cv2 .waitKey (50 )
24+ if key & 0xFF == ord ("q" ):
25+ cv2 .destroyAllWindows ()
26+ break
27+ if key & 0xFF == ord (" " ):
28+ cv2 .imwrite (f"{ directory } /{ name + str (frame_count )} .jpg" , frame )
29+ print (f"got { name + str (frame_count )} " )
30+ frame_count += 1
31+
32+
33+ if __name__ == "__main__" :
34+ main ()
You can’t perform that action at this time.
0 commit comments