Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 3.1 VideoWriter::write(const Mat&) does not return its status.

Hello, I found it strange that the "VideoWriter::write(const Mat&)" function does not return its status (true/false).

I think that function should return an int to inform about the result of the call. (true (success) / false (fail))

The function declaration could be changed to: "virtual int write (const Mat &image)" instead of "virtual void write (const Mat &image)"

It would be easy to return the status because the source code inside write is using "cvWriteFrame(writer, &_img);" which returns an integer.

See definition and source here:

http://docs.opencv.org/master/dd/d9e/classcv_1_1VideoWriter.html#gsc.tab=0

https://github.com/opencv/opencv/blob/169b5e9fdeb74daa671a747c724e3424e15c0c2a/modules/videoio/src/cap.cpp

void VideoWriter::write(const Mat& image)
{
    if( iwriter )
        iwriter->write(image);
    else
    {
        IplImage _img = image;
        cvWriteFrame(writer, &_img);
    }
}

Otherwise, how can we know the status of the write call ?
(For example: it could fail because of the drive is full or there is a problem with the encoder or the storage device has been removed)

If my comment is relevant, where should I request that change ?

Thanks