Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a interactive Grabcut algorithm which is taken from the Open CV. Iam doing this in c# Emgu 3.0. I was able to draw a rectangle to extract the foreground image using
the below code.

C#
using (Matrix<double> bgdModel = new Matrix<double>(1, 13 * 5))
         using (Matrix<double> fgdModel = new Matrix<double>(1, 13 * 5))
         {
             CvInvoke.GrabCut(original, mask1, new Rectangle(0, 0, original.Width, original.Height), bgdModel, fgdModel, 1, Emgu.CV.CvEnum.GrabcutInitType.InitWithRect);
             CvInvoke.GrabCut(original, mask1, rect, bgdModel, fgdModel, 2, Emgu.CV.CvEnum.GrabcutInitType.Eval);
         }


Now the next part is that, I want to create a Interactive touch but I cannot find any references to use the Grabcut method with mask in c#. Can any one please help me out.

Thanks,
Indra

What I have tried:

I was able to succeed in drawing the mask area and then passing the mask into below section but it is not working.
C#
using (Matrix<double> bgdModel = new Matrix<double>(1, 13 * 5))
         using (Matrix<double> fgdModel = new Matrix<double>(1, 13 * 5))
         {
             CvInvoke.GrabCut(original, mask1, new Rectangle(0, 0, original.Width, original.Height), bgdModel, fgdModel, 1, Emgu.CV.CvEnum.GrabcutInitType.InitWithRectMask);
             CvInvoke.GrabCut(original, mask1, rect, bgdModel, fgdModel, 2, Emgu.CV.CvEnum.GrabcutInitType.Eval);
         }<pre lang="c#">

I am unable to understand How to pass the selected area in this method.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900