Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::Mat is already a refcounted smart pointer, if you pass around pointers to that, you defeat its purpose.

please do NOT use any raw pointers or new here, and pass objects by reference:

Mat get_capture_frame_cv(cv::VideoCapture &cpp_ca)
{
    cv::Mat mat; // NO new !
    if (cpp_cap.isOpened())
    {
         cpp_cap >> mat;
    }
    else cerr << " cv::VideoCapture isn't open \n";
    if (mat.empty()) {
          cerr << " Video-stream stopped! \n";
    }
    return mat;
}

VideoCapture cap(0); // 1st webcam
Mat img = get_capture_frame_cv(cap);