Opencv 根据视频馈送中检测到的颜色输出字符串

Opencv 根据视频馈送中检测到的颜色输出字符串,opencv,c++-cli,emgucv,Opencv,C++ Cli,Emgucv,所以我要做的是根据我在视频提要中看到的颜色输出一个特定的字符串。现在,我所做的是设置提要的阈值,使高于某个亮度的所有内容都显示为红色。现在,我想有一些东西,如果提要中有任何红色,那么我会在显示提要的用户界面上的文本框中输出一个1。如果没有红色,则向文本框输出0。我用EGGU CV管理的VC++与VS2010,有人能帮我吗?多谢各位 这是我到目前为止没有正常工作的代码,它给了我一个编译器错误 cvConvertScaleAbs(frameFromCamera->Ptr.ToPointer()

所以我要做的是根据我在视频提要中看到的颜色输出一个特定的字符串。现在,我所做的是设置提要的阈值,使高于某个亮度的所有内容都显示为红色。现在,我想有一些东西,如果提要中有任何红色,那么我会在显示提要的用户界面上的文本框中输出一个1。如果没有红色,则向文本框输出0。我用EGGU CV管理的VC++与VS2010,有人能帮我吗?多谢各位

这是我到目前为止没有正常工作的代码,它给了我一个编译器错误

cvConvertScaleAbs(frameFromCamera->Ptr.ToPointer(),frameDisplay->Ptr.ToPointer(),double(1)/16,0);
    cvCvtColor(frameDisplay->Ptr.ToPointer(),frameColorDisplay->Ptr.ToPointer(),CV_GRAY2BGR);
    cvThreshold(frameDisplay->Ptr.ToPointer(),maskSaturated->Ptr.ToPointer(),200,255,CV_THRESH_BINARY);
    cvNot(maskSaturated->Ptr.ToPointer(),mask1->Ptr.ToPointer());
    cv::Scalar red(0,0,255);
    cvSet(frameColorDisplay->Ptr.ToPointer(),red,maskSaturated->Ptr.ToPointer());

    highColor = gcnew Emgu::CV::Image<Bgr,UInt16>(0, 0, 255);
    lowColor = gcnew Emgu::CV::Image<Bgr,UInt16>(0, 0, 200);

    if(maskSaturated->InRange(lowColor, highColor) == 255){
        tbMorse->Text ="1";
    }
    else{
        tbMorse->Text = "0";
    }
    imageMain->Image=frameColorDisplay;
我在头文件中初始化了highColor和lowColor

Emgu::CV::Image<Bgr,UInt16> ^lowColor;
    Emgu::CV::Image<Bgr,UInt16> ^highColor;
它给我的错误是

 BAOTFISInterface.cpp(1010): error C2664: 'Emgu::CV::Image<TColor,TDepth>::Image(int,int,Emgu::CV::Structure::Bgr)' : cannot convert parameter 3 from 'int' to 'Emgu::CV::Structure::Bgr'
      with
      [
          TColor=Emgu::CV::Structure::Bgr,
          TDepth=unsigned short
      ]
      No user-defined-conversion operator available that can perform this conversion,         or the operator cannot be called
 BAOTFISInterface.cpp(1011): error C2664: 'Emgu::CV::Image<TColor,TDepth>::Image(int,int,Emgu::CV::Structure::Bgr)' : cannot convert parameter 3 from 'int' to 'Emgu::CV::Structure::Bgr'
      with
      [
          TColor=Emgu::CV::Structure::Bgr,
          TDepth=unsigned short
      ]
      No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
 BAOTFISInterface.cpp(1013): error C2664: 'Emgu::CV::Image<TColor,TDepth> ^Emgu::CV::Image<TColor,TDepth>::InRange(Emgu::CV::Image<TColor,TDepth> ^,Emgu::CV::Image<TColor,TDepth> ^)' : cannot convert parameter 1 from 'Emgu::CV::Image<TColor,TDepth> ^' to 'Emgu::CV::Image<TColor,TDepth> ^'
      with
      [
          TColor=Emgu::CV::Structure::Gray,
          TDepth=unsigned char
      ]
      and
      [
          TColor=Emgu::CV::Structure::Bgr,
          TDepth=unsigned short
      ]
      and
      [
          TColor=Emgu::CV::Structure::Gray,
          TDepth=unsigned char
      ]
      No user-defined-conversion operator available, or
      Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

问题是你不使用C++,你使用的是C++,CLI,这是一种非常相似的语言,但是是一种独立的语言。例如,它是一种托管语言,有一种特殊类型的指针被垃圾收集。那些是使用^而不是普通C++的。C++/CLI的托管指针与普通非托管指针不兼容,这就是您的错误所在。函数需要一个托管指针,而你给了它一个非托管指针。哦,这有点让人困惑。那么我该如何修复它呢?如何将其转换为托管指针?我必须将其声明为托管指针吗?谢谢你的及时回复@Joachimpileborg如果您使用的是Emgu CV所使用的托管库,那么您需要使用C++/CLI的托管功能。所以,是的,您应该使用托管指针,像SomeType^var=gcnewsometype一样分配;很抱歉,这是一个混乱的局面,我不知道如何将代码放入注释中:您不知道。将代码放入注释中,我的意思是:更新您的问题,或者发布新问题。