Skip to content

Commit fa5595e

Browse files
authored
Add python script to take a image
1 parent 22c4a36 commit fa5595e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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()

0 commit comments

Comments
 (0)