Skip to content

Commit d5819e6

Browse files
authored
Merge pull request wasmerio#22 from anju-chhetri/master
Script for taking an image
2 parents 7ed322d + 24de08c commit d5819e6

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

Image Capture/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
This python script is used for taking images from your webcam and saving it on your local device. Path to the folder can be specified using the following command:
2+
3+
> python3 take_pictures_from_webcam.py --directory pathname
4+
5+
The default path would be your current directory.
6+
7+
You can also give name to your image using following command:
8+
> python3 take_pictures_from_webcam.py --name ImageName
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()

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ Create a star pattern pyramid
6161
## Script 13 - compound interest calculator
6262
calculate compound interest
6363

64-
## Script 14 - Mouse mover
65-
Moves your mouse every 15 seconds
64+
## Script 14 - Image Capture
65+
Capture image from your webcam and save it on your local device.
66+
6667
## Script 15 - JSON to YAML converter
6768
Converts JSON file to YAML files. A sample JSON is included for testing.
6869

6970
## Script 16 - AutoCert
70-
A Python script to auto generate e-certificates in bulk.
71+
A Python script to auto generate e-certificates in bulk.
72+
73+
## Script 17 - Mouse mover
74+
Moves your mouse every 15 seconds
75+

0 commit comments

Comments
 (0)