Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't know why do you want to new it?Just declare an automatic object, the resource will be clean up after the videoStream after it leave the scope.If this solution can't work, that means the problem may not on the videoCapture but other codes.

cv::VideoCapture videoStream(2);

if ( !videoStream.isOpened() )
{
    addDebug("Capture failed!");   
    return;
}

videoStream >> incFrame;

if ( !incFrame.empty() )
{
    incFrame.release();
}

ps : If you find out you need to handle the memory manually in c++, maybe you should ask yourself "am I doing something wrong?".In c++, we could deal with memory management and pointer, but we don't "have to" do that.

I don't know why do you want to new it?Just declare an automatic object, the resource will be clean up after the videoStream after it leave the scope.If this solution can't work, that means the problem may not on the videoCapture but other codes.

cv::VideoCapture videoStream(2);

if ( !videoStream.isOpened() )
{
    addDebug("Capture failed!");   
    return;
}

videoStream >> incFrame;

if //you don't need these too, just declare an automatic object like
//cv::Mat incFrame.The resource will be clean up after leaving the scope
/*if ( !incFrame.empty() )
{
    incFrame.release();
}
}*/

ps : If you find out you need to handle the memory manually in c++, maybe you should ask yourself "am I doing something wrong?".In c++, we could deal with memory management and pointer, but we don't "have to" do that.