Segmentation using bodypix in Python. But got better results only when person is in front of wall rather than other objects.
from tf_bodypix.api import download_model, load_model, BodyPixModelPaths
import cv2
bodypix_model = load_model(download_model(BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16))
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret, frame = cap.read()
# BodyPix Segmentation
result = bodypix_model.predict_single(frame)
mask = result.get_mask(threshold=0.5).numpy().astype(np.uint8)
seg = result.get_colored_part_mask(mask)
tf.keras.preprocessing.image.save_img(
pwd+"\\output-colored-mask.jpg",
seg
)