在非托管c ++代码中使用Emgu Image

时间:2012-01-18 12:47:00

标签: c# opencv c++-cli emgucv

我需要为我的C ++代码编写包装器,以便在c#应用程序中使用它。基本上我需要在c ++中从C#中预处理Emgu图像并将其返回。我尝试在un-managed c ++方面这样做:

public ref class ImageProcessor
{
public:
    void process(Image<Bgr, Byte>^ InImage)
    {
            cv::Mat image(InImage->Width,
                          InImage->Height,
                          CV_8UC3,
                          InImage->Ptr.ToPointer());

            cv::imwrite("mask.png", mask); //this line throws exception 

    }
 };

当我从c#调用thiss函数时,抛出异常: System.AccessViolationException未处理   Message =尝试读取或写入受保护的内存。这通常表明其他内存已损坏。

问题是如何正确地将Emgu :: CV :: Image ^从托管代码传递给非托管c ++?

0 个答案:

没有答案