cv::VideoCapture with no url or camera index

Hey there,

I have some cameras libraries in my project done by me that return a data buffer that afterward is transformed into a cv::Mat object.

Can I use a cv::VideoCapture ptr object to pass the cv::Mat object without having to pass any camera index?

Right now I am testing with cv::imshow that the grabbed image from the buffer works but in the main application my custom frame to show the image.
Below my testing code

while (cv::waitKey(1) != 27) {
    cv::Mat image(m_cr_camera->getHeight(),
                  m_cr_camera->getWidth(), CV_16UC1, m_cr_camera->getBuffer());
    cv::namedWindow(camera_name_window, cv::WINDOW_AUTOSIZE);
    cv::imshow(camera_name_window, image);
  }

What I would like to do is something like:

cv::VideoCapture *capture = new VideoCapture();
(*capture) >> m_camera->getImage();

Then the capture is passed into my custom frame to reproduce the image.
Thank you in advance.

i dont think, what you want is possible (unless you implement another “backend” in the videoio src).
but at least you could write some “mock” capture class:

class MyCapture {
    WhatEver *m_cr_camera;
public:
     MyCapture() {
         // init m_cr_camera
     }
     MyCapture& operator >> (Mat& image) {
         image = Mat(m_cr_camera->getHeight(),
                     m_cr_camera->getWidth(), 
                     CV_16UC1, 
                     m_cr_camera->getBuffer()); //.clone(); // (maybe)
         return *this;
     }
};

however, you’d have to lookup, ,how data ownership is handled here, if you have to lock the camera, etc.

I confirm that you can’t. What I am doing instead is passing by reference my grabbed image after some image processing into the image frame I have using threads.