Ask Your Question

Revision history [back]

Writting a videocapture driver

Hi,

I need to write my own class videocapture (Windows 10 VC 2015 and opencv 3.1-dev). I write somethin like this :

class MyClass : public VideoCapture {
....

Now I want to write retrieve method I wrote :

bool MyClass ::retrieve(OutputArray image, int flag ) 
 { 
     image.create(288, 384, CV_16UC1);
     if (!image.isContinuous())
     {
         return false;
     }
     char c = 1;
     irFile.Write(&c, 1);
     int nb=irFile.Read(image.getMat().ptr(0), 384 * 288 * 2);
     return nb== 384 * 288 * 2;
 }

I have sometime after 5s or 1 min an exception when I run my program. This error occur when I want to copy grabbed frame in a UMat (UMATFRAME) frame.copyTo(UMATFRAME);

wxOpenCVMain.exe!cv::error(const cv::Exception & exc) Ligne 662 C++
wxOpenCVMain.exe!cv::error(int _code, const cv::String & _err, const char * _func, const char * _file, int _line) Ligne 666 C++
wxOpenCVMain.exe!cv::ocl::OpenCLAllocator::deallocate(cv::UMatData * u) Ligne 4528  C++
wxOpenCVMain.exe!cv::UMat::deallocate() Ligne 410   C++
wxOpenCVMain.exe!cv::UMat::release() Ligne 3493 C++
wxOpenCVMain.exe!cv::UMat::~UMat() Ligne 402    C++
[Code externe]  
wxOpenCVMain.exe!cv::error(const cv::Exception & exc) Ligne 662 C++
wxOpenCVMain.exe!cv::error(int _code, const cv::String & _err, const char * _func, const char * _file, int _line) Ligne 666 C++
wxOpenCVMain.exe!cv::ocl::OpenCLAllocator::upload(cv::UMatData * u, const void * srcptr, int dims, const unsigned __int64 * sz, const unsigned __int64 * dstofs, const unsigned __int64 * dststep, const unsigned __int64 * srcstep) Ligne 5036 C++
wxOpenCVMain.exe!cv::Mat::copyTo(const cv::_OutputArray & _dst) Ligne 280   C++

Idea to solve this problem are welcome.