Organized into python module

This commit is contained in:
Brandon Rozek 2020-05-03 16:32:09 -04:00
parent 97a758bdb3
commit 9042afd82d
6 changed files with 14 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ node_modules/
package-lock.json package-lock.json
.mypy_cache/ .mypy_cache/
.vscode/ .vscode/
*.egg-info

View file

@ -3,6 +3,7 @@ import cv2
from pyfakewebcam import FakeWebcam from pyfakewebcam import FakeWebcam
import numpy as np import numpy as np
from camera import Camera from camera import Camera
from argparse import ArgumentParser
from signal import signal, SIGINT from signal import signal, SIGINT
def process_mask(m, shape): def process_mask(m, shape):
@ -29,7 +30,7 @@ def get_background(uri=None):
backdrop = None backdrop = None
if uri is not None: if uri is not None:
backdrop = cv2.resize( backdrop = cv2.resize(
cv2.UMat(cv2.imread('/home/rozek/Pictures/IMG_20191013_181848.jpg')), cv2.UMat(cv2.imread(uri)),
(h, w) (h, w)
).get().astype(np.uint8) ).get().astype(np.uint8)
else: else:
@ -43,6 +44,14 @@ def stop(signal_received, stack_frame):
running = False running = False
print("Stopping...") print("Stopping...")
parser = ArgumentParser(description="Virtual Backgrounds with Bodypix")
parser.add_argument(
"--background",
type=str,
help="The background to use. If not specified, will be a blur of the initial frame."
)
args = vars(parser.parse_args())
# Start Camera # Start Camera
camera = Camera() camera = Camera()
@ -56,7 +65,7 @@ if __name__ == "__main__":
sock = ctx.socket(zmq.REQ) sock = ctx.socket(zmq.REQ)
sock.connect('ipc:///tmp/bodypix') sock.connect('ipc:///tmp/bodypix')
background, (width, height) = get_background() background, (width, height) = get_background(args['background'])
fake = FakeWebcam('/dev/video20', height, width) fake = FakeWebcam('/dev/video20', height, width)
running = True running = True

Binary file not shown.

Binary file not shown.

View file

@ -7,6 +7,7 @@ setup(name="bodypix-background",
install_requires=[ install_requires=[
"opencv-python~=4.2.0.34", "opencv-python~=4.2.0.34",
"numpy~=1.18.3", "numpy~=1.18.3",
"pyzmq~=19.0.0" "pyzmq~=19.0.0",
"pyfakewebcam==0.1.0"
] ]
) )