Having problem with using grabcut algorithm in pictureBox of Visual C++ CLR project
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..
After declaring the variable:
IplImage* frame;
//Displaying the image
pictureBox1->Image = gcnew System::Drawing::Bitmap
(frame->width,frame->height,frame->widthStep,
System::Drawing::Imaging::PixelFormat::Format24bppRgb,(System::IntPtr) frame->imageData);
pictureBox1->Refresh();
",it's not working" -- .. if that's all you can say, you clearly have no idea, what you're doing
(and we cannot help you)
I mean to say that the rectangle is not being drawn on the image (i.e displayed in the picturebox) when applying the grabcut function in order to separate the foreground from background ..
how do we know, what you display in your picturebox ?
An image showing hand palm ..i want to extract it from the background ..
you misread me:
how do we know, you're actually displaying imge , (not "foreground", or anything else ?)