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

asked 2016-07-22 21:09:46 -0500

ssinfod gravatar image

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:

void VideoWriter::write(const Mat& image)
    if( iwriter )
        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 ?


edit retag flag offensive close merge delete


I believe that if the write fails, it will issue an exception that can be caught.

unxnut gravatar imageunxnut ( 2016-07-23 18:56:29 -0500 )edit

I tried it and there is no exception. Also errno is not set. I think the definition of the function should be changed...

I will write a message on the mailing list..

ssinfod gravatar imagessinfod ( 2016-07-26 09:16:03 -0500 )edit

You are trying to catch cv::Exception. Right?

unxnut gravatar imageunxnut ( 2016-07-27 22:31:34 -0500 )edit