Skip to content

Commit

Permalink
Changed background image from gray color to blur effect in Selfie Seg…
Browse files Browse the repository at this point in the history
…ementation
  • Loading branch information
rakeshksr committed Feb 15, 2023
1 parent 57b2130 commit d6b248c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions ml_applications.py
Original file line number Diff line number Diff line change
@@ -32,8 +32,6 @@ def __init__(self):
self.mp_pose_detection = mp.solutions.pose
self.pose_detection_model = None

self.segment_bgcolor = (192, 192, 192) # gray
# self.segment_bgcolor = (255, 255, 255) # white
self.mp_selfie_segmentation = mp.solutions.selfie_segmentation
self.selfie_segmentation_model = None

@@ -240,7 +238,6 @@ def selfie_segmention(self, frame):
results = self.selfie_segmentation_model.process(frame_rgb)
frame_rgb.flags.writeable = True
condition = np.stack((results.segmentation_mask,) * 3, axis=-1) > 0.1
bg_image = np.zeros(frame_rgb.shape, dtype=np.uint8)
bg_image[:] = self.segment_bgcolor
bg_image = cv2.blur(frame_rgb, (20,20))
frame_rgb = np.where(condition, frame_rgb, bg_image)
return frame_rgb

0 comments on commit d6b248c

Please # to comment.