次のように私のコードは、私はOpenCVののVideoCaptureクラスの「ラッパー」を作成しようとしているが、私はそれが正常に働いて得ることができない。OpenCVのVideoCaptureラッパークラス
#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
class wrapper
{
private:
cv::VideoCapture cap;
int device_id;
public:
wrapper();
~wrapper();
void setup(int _device_id);
};
// wrapper.cpp
wrapper::wrapper()
{
device_id = 0;
}
wrapper::~wrapper()
{
cap.release();
}
wrapper::setup(int _device_id)
{
device_id = _device_id;
cap = cv::VideoCapture(device_id);
cout << "Checking device" << endl;
if(!cap.isOpened())
{
cout << "Couldn't open device" << endl;
return;
}
else
{
cout << "Device opened " << endl;
}
}
問題がありますデバイスが開かないことを確認します。私はstarter_video.exe(OpenCVの例)で私のデバイスをチェックして、それが開きます。
どのような考えですか?
ところで 'する#include'すべてのものを含んでいることで
: 、ラインを交換してみてください。コアのみをインクルードする場合は、#includeまたは#including highguiは必要ありません。 –