예제 #1
0
 def __init__(self, fps: int, width: int, height: int, codec: str,
              no_background: bool, background_blur: int,
              background_keep_aspect: bool, use_foreground: bool,
              hologram: bool, tiling: bool, background_image: str,
              foreground_image: str, foreground_mask_image: str,
              webcam_path: str, v4l2loopback_path: str,
              use_akvcam: bool) -> None:
     self.no_background = no_background
     self.use_foreground = use_foreground
     self.hologram = hologram
     self.tiling = tiling
     self.background_blur = background_blur
     self.background_keep_aspect = background_keep_aspect
     self.background_image = background_image
     self.foreground_image = foreground_image
     self.foreground_mask_image = foreground_mask_image
     self.real_cam = RealCam(webcam_path, width, height, fps, codec)
     # In case the real webcam does not support the requested mode.
     self.width = self.real_cam.get_frame_width()
     self.height = self.real_cam.get_frame_height()
     self.use_akvcam = use_akvcam
     if not use_akvcam:
         self.fake_cam = pyfakewebcam.FakeWebcam(v4l2loopback_path,
                                                 self.width, self.height)
     else:
         self.fake_cam = AkvCameraWriter(v4l2loopback_path, self.width,
                                         self.height)
     self.foreground_mask = None
     self.inverted_foreground_mask = None
     self.images: Dict[str, Any] = {}
     self.image_lock = asyncio.Lock()
     self.bodypix_model = load_model(
         download_model(BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16))
예제 #2
0
 def __init__(
     self,
     fps: int,
     width: int,
     height: int,
     codec: str,
     scale_factor: float,
     no_background: bool,
     background_blur: int,
     background_keep_aspect: bool,
     use_foreground: bool,
     hologram: bool,
     tiling: bool,
     bodypix_url: str,
     socket: str,
     background_image: str,
     foreground_image: str,
     foreground_mask_image: str,
     webcam_path: str,
     v4l2loopback_path: str,
     use_akvcam: bool,
 ) -> None:
     self.no_background = no_background
     self.use_foreground = use_foreground
     self.hologram = hologram
     self.tiling = tiling
     self.background_blur = background_blur
     self.background_keep_aspect = background_keep_aspect
     self.background_image = background_image
     self.foreground_image = foreground_image
     self.foreground_mask_image = foreground_mask_image
     self.scale_factor = scale_factor
     self.real_cam = RealCam(webcam_path, width, height, fps, codec)
     # In case the real webcam does not support the requested mode.
     self.width = self.real_cam.get_frame_width()
     self.height = self.real_cam.get_frame_height()
     self.use_akvcam = use_akvcam
     if not use_akvcam:
         self.fake_cam = pyfakewebcam.FakeWebcam(v4l2loopback_path,
                                                 self.width, self.height)
     else:
         self.fake_cam = AkvCameraWriter(v4l2loopback_path, self.width,
                                         self.height)
     self.foreground_mask = None
     self.inverted_foreground_mask = None
     self.session = requests.Session()
     if bodypix_url.startswith("/"):
         print("Looks like you want to use a unix socket")
         # self.session = requests_unixsocket.Session()
         self.bodypix_url = "http+unix:/" + bodypix_url
         self.socket = bodypix_url
         requests_unixsocket.monkeypatch()
     else:
         self.bodypix_url = bodypix_url
         self.socket = ""
         # self.session = requests.Session()
     self.images: Dict[str, Any] = {}
     self.image_lock = asyncio.Lock()
예제 #3
0
 def __init__(
     self,
     fps: int,
     width: int,
     height: int,
     codec: str,
     no_background: bool,
     background_blur: int,
     background_keep_aspect: bool,
     use_foreground: bool,
     hologram: bool,
     tiling: bool,
     socket: str,
     background_image: str,
     foreground_image: str,
     foreground_mask_image: str,
     webcam_path: str,
     v4l2loopback_path: str,
     use_akvcam: bool
 ) -> None:
     self.no_background = no_background
     self.use_foreground = use_foreground
     self.hologram = hologram
     self.tiling = tiling
     self.background_blur = background_blur
     self.background_keep_aspect = background_keep_aspect
     self.background_image = background_image
     self.foreground_image = foreground_image
     self.foreground_mask_image = foreground_mask_image
     self.real_cam = RealCam(webcam_path, width, height, fps, codec)
     # In case the real webcam does not support the requested mode.
     self.width = self.real_cam.get_frame_width()
     self.height = self.real_cam.get_frame_height()
     self.use_akvcam = use_akvcam
     if not use_akvcam:
         self.fake_cam = pyfakewebcam.FakeWebcam(v4l2loopback_path, self.width, self.height)
     else:
         self.fake_cam = AkvCameraWriter(v4l2loopback_path, self.width, self.height)
     self.foreground_mask = None
     self.inverted_foreground_mask = None
     self.images: Dict[str, Any] = {}
     self.classifier = mp.solutions.selfie_segmentation.SelfieSegmentation(model_selection=1)
 def __init__(
     self,
     fps: int,
     width: int,
     height: int,
     scale_factor: float,
     use_foreground: bool,
     hologram: bool,
     tiling: bool,
     bodypix_url: str,
     background_image: str,
     foreground_image: str,
     foreground_mask_image: str,
     webcam_path: str,
     v4l2loopback_path: str,
     use_akvcam: bool
 ) -> None:
     self.use_foreground = use_foreground
     self.hologram = hologram
     self.tiling = tiling
     self.background_image = background_image
     self.foreground_image = foreground_image
     self.foreground_mask_image = foreground_mask_image
     self.scale_factor = scale_factor
     self.bodypix_url = bodypix_url
     self.real_cam = RealCam(webcam_path, width, height, fps)
     # In case the real webcam does not support the requested mode.
     self.width = self.real_cam.get_frame_width()
     self.height = self.real_cam.get_frame_height()
     self.use_akvcam = use_akvcam
     if not use_akvcam:
         self.fake_cam = pyfakewebcam.FakeWebcam(v4l2loopback_path, self.width, self.height)
     else:
         self.fake_cam = AkvCameraWriter(v4l2loopback_path, self.width, self.height)
     self.foreground_mask = None
     self.inverted_foreground_mask = None
     self.session = requests.Session()
     self.images: Dict[str, Any] = {}
     self.image_lock = asyncio.Lock()