GrabCut is an excellent iterative background/foreground segmentation algorithm that is available since Version 2.1 of OpenCV. GrabCut is especially useful to separate objects from the background with minimal additional information (a bounding rectangle is sufficient in most cases). However, it is computationally intensive, and so it is only appropriate to segment still images.
Note
GrabCut is the underlying algorithm for the Background Removal tool in Microsoft Office 2010. This algorithm was first proposed by researchers at Microsoft Research Cambridge. Starting with a user-provided bounding box of the object to segment, the algorithm estimates the color distributions of both the target object and the background. This estimate is further refined by minimizing an energy function in which connected regions that have the same label receive more weight.
The main function is grabCut(InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int...