I need to use the grabcut algorithm in a picturebox where the image is loaded.But i'm having trouble in using the grabcut on the image.It is not working.
Here is the grabcut function :
void grabCut( Mat image, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int i,const int GC_INIT_WITH_RECT)
{
int border = 20;
int border2 = border + border;
Rect rectangle(border, border, image.cols - border2, image.rows - border2);
cv::compare(mask, GC_PR_FGD, mask, CMP_EQ);
// Generate output image
cv::Mat foreground(image.size(), CV_8UC3, cv::Scalar(255, 255, 255));
image.copyTo(foreground, mask); // bg pixels not copied
// draw rectangle on original image
cv::rectangle(image, rect, cv::Scalar(255, 255, 255), 1);
}
I'm using the code found in github that is ,grabcut.cpp which is running successfully, but when applying it in the picture box ,it's not working. Any idea how i can i make it work out?Any piece of code would be of great help.. Thank you in advance..