-
Notifications
You must be signed in to change notification settings - Fork 0
/
stealthy.py
40 lines (30 loc) · 973 Bytes
/
stealthy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Capture an Image from webcam without use interaction."""
# flake8: noqa
import datetime
import getpass
import pathlib
import cv2
def filename():
"""
Create a filename based on the username and current date and time.
The file will be stored in the home directory `~/Pictures/login-capture/`.
"""
username = getpass.getuser()
now = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")
path = pathlib.Path.home() / "Pictures" / "login-capture"
path.mkdir(parents=True, exist_ok=True)
return str(path / f"{username}-{now}.png")
# define a video capture object
vid = cv2.VideoCapture(0)
# set the resolution to the maximum value
vid.set(cv2.CAP_PROP_FRAME_WIDTH, 10_000)
vid.set(cv2.CAP_PROP_FRAME_HEIGHT, 10_000)
while True:
success, frame = vid.read()
if success:
cv2.imwrite(filename(), frame)
break
# After the loop release the cap object
vid.release()
# Destroy all the windows
cv2.destroyAllWindows()