コード例 #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
ファイル: bodypix.py プロジェクト: benbatya/layered-vision
 def load_bodypix_model(self) -> BodyPixModelWrapper:
     LOGGER.info('loading bodypix model: %s', self.model_path)
     bodypix_model = load_model(
         download_model(self.model_path),
         internal_resolution=self.internal_resolution)
     LOGGER.info('bodypix internal resolution: %s',
                 bodypix_model.internal_resolution)
     return bodypix_model
コード例 #3
0
ファイル: bodypix.py プロジェクト: ReDrawing/cti_image
    def __init__(self):
        super().__init__('bodypix')
        self.pubMask = self.create_publisher(Image, "user/body_mask", 10)
        self.colMask = self.create_publisher(Image, "user/colored_body_mask",
                                             10)

        self.subImg = self.create_subscription(Image, "camera/image",
                                               self.imageCallback, 10)

        self.bodypix_model = load_model(
            download_model(BodyPixModelPaths.MOBILENET_FLOAT_100_STRIDE_16))
コード例 #4
0
import cv2
import numpy as np
import tensorflow as tf
from tf_bodypix.api import download_model, load_model, BodyPixModelPaths

if len(sys.argv) > 1:
    file = sys.argv[1]
else:
    file = "images/persons.jpg"

img = cv2.imread(file)
print(type(img))
print(img.shape)

bodypix_model = load_model(
    download_model(BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16))

# load image file & display it
image = tf.keras.preprocessing.image.load_img(file)
#image.show() # PIL Image

image_array = tf.keras.preprocessing.image.img_to_array(image)
print(type(image_array))
image = np.array(image_array, dtype=np.uint8)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
cv2.imshow('image', image)

result = bodypix_model.predict_single(image_array)

mask = result.get_mask(threshold=0.75)
#tf.keras.preprocessing.image.save_img('out/bodypix-mask.jpg',mask)
コード例 #5
0
ファイル: tf_segmentation.py プロジェクト: Tenfleques/h-track
 def __init__(self,
              model=BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16) -> None:
     self.bodypix_model = load_model(download_model(model))
コード例 #6
0
 def __init__(self):
     self.bodypix_model = load_model(
         download_model(BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16))
     self.background = None
コード例 #7
0
 def __init__(self):
     self.scale_percent = 30
     self.bodypix_model = load_model(
         download_model(BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16))