如何使用capture-> retrieve()?对非const的引用的初始值必须是左值

时间:2015-07-24 14:13:58

标签: opencv c++-cli lvalue

我试图重构我的项目并摆脱cvQueryFrame和其他"过时的"功能

我是C ++的新手。这就是我想要做的事情:

cv::Mat* frame;
OpenCVEngine* cve;

private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

cve->capture->retrieve(&frame);

// (...) do something with frame
}

我在cve->capture->retrieve(&frame);上有错误:

  

对非const的引用的初始值必须是左值

  

错误C2664:' bool cv :: VideoCapture :: retrieve(cv :: Mat&,int)' :不能   转换参数1来自' cli :: interior_ptr'到' cv :: Mat&'

我的OpenCVEngine类标题:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

class OpenCVEngine
{
public:
    OpenCVEngine();
    ~OpenCVEngine();

    System::Drawing::Bitmap^ MatToBitmap(const cv::Mat& img);

    cv::VideoCapture* capture;

private:

};

我的OpenCVEngine类代码:

#include "OpenCvEngine.h"

using namespace System::Drawing;
using namespace System::Drawing::Imaging;

OpenCVEngine::OpenCVEngine()
{

    capture = &cv::VideoCapture(0);

    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 1920);
    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 1080);


    if (!capture->isOpened())
    {
        // todo: error handling
    }
}

OpenCVEngine::~OpenCVEngine()
{
    capture->release();

}

System::Drawing::Bitmap^ MatToBitmap(const cv::Mat& img)
{
    // (...) not important
}

0 个答案:

没有答案