Writting a videocapture driver

asked 2016-12-04 15:23:34 -0600

LBerger gravatar image

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.

edit retag flag offensive close merge delete

Comments

According to this comment, you have additional reference somewhere. Maybe frame.clone().copyTo(...) could help?

mshabunin gravatar imagemshabunin ( 2016-12-05 06:19:11 -0600 )edit

Thanks for you answer. I have tried but it does not solve problem. If I use my logitech webcam I haven't got exception. I think problem is my MyClass ::retrieve method.

I have used a Mat Instead ofUMat and there is no exception

I need to investigate more..

LBerger gravatar imageLBerger ( 2016-12-06 13:42:31 -0600 )edit