Skip to content

chandra-ps612/Stack_Foreground_Segmentation_Model

Repository files navigation

Stack_Foreground_Segmentation_Model

  1. In this project, I used the GrabCut Algorithm to extract the foreground segmentation of the stack in a video input.
  2. I implemented the GrabCut in OpenCV via cv2.grabCut and initialize it with bounding boxes instead of mask approximation.
  3. I resized the video as 720*720.

Frame- The input, which GrabCut assumes to be an 8-bit, 3-channel frame

Mask- The input/output mask. This mask is assumed to be a single-channel frame with an unsigned 8-bit integer data type. This mask is initialized automatically if I use bounding box initialization with cv2.GC_INIT_WITH_RECT otherwise Grabcut assumes you are performing mask initialization with cv2.GC_INIT_WITH_MASK.

bgModel: Temporary array used by GrabCut internally when modeling the background.

fgModel: Temporary array used by GrabCut when modeling the foreground.

iterCount: Number of iterations GrabCut will perform when modeling the foreground versus background. The more iterations, the longer GrabCut will run, and ideally, the results will be better. I used iterCount=3 in my code.

I used the rectangle mode in my code. Also, I set the rectangle parameters e.g. (startingPoint_x, startingPoint_y, width, height) manually. mode=cv2.GC_INIT_WITH_RECT

OpenCV's GrabCut implementation returns 3 tuples namely-

  1. mask- The output mask after applying GrabCut
  2. bgModel
  3. fgModel At last, I saved the post-processed video in mp4 format with width=720 and height=720. I am also attaching the output of frontal.png which is extracted with the same algorithm.

Releases

No releases published

Packages

 
 
 

Contributors

Languages