Search code examples
c#formswinformsopencvemgucv

Emgu: The name CV_RBG2GRAY does not exist in the current context


I'm writing a Form in c# using Emgu, but, when trying to use the function CvtColor, I get the error "CV_RBG2GRAY" does not exist in the current context. I've looked everywhere, but I couldn't find any other occurences of this problem.
The problem occurs in this line:

private void startToolStripMenuItem_Click(object sender, EventArgs e)
{
  CvInvoke.CvtColor(Processo.InImage, Processo.BWImage, CV_Rgb2Gray);
}

Could Someone please help me?


Solution

  • That constant is in Emgu.CV.CvEnum.ColorConversion namespace. Try this:

    private void startToolStripMenuItem_Click(object sender, EventArgs e)
    {
      CvInvoke.CvtColor(Processo.InImage, Processo.BWImage, Emgu.CV.CvEnum.ColorConversion.Rgb2Gray);
    }