Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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..

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();

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();

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();