c++opencvmatwriteriplimage

What is the equivalent function for " cvWriteFrame " to use Mat - image type?


What is the equivalent function for " cvWriteFrame " to use Mat - image type ?

In IplImage it can be done using like below:

CvVideoWriter *writer;
IplImage* frame = " IMAGE ";   

cvWriteFrame(writer, frame);

How to write video for Mat Files.


Solution

  • Opencv doc

    C++: VideoWriter& VideoWriter::operator<<(const Mat& image)
    C++: void VideoWriter::write(const Mat& image)
    Python: cv2.VideoWriter.write(image) → None
    C: int cvWriteFrame(CvVideoWriter* writer, const IplImage* image)
    Python: cv.WriteFrame(writer, image) → int
    

    So i guess something like

    cv::Mat image;
    ....
    cv::VideoWriter writer;
    writer.open(...);
    if (writer.isOpened())
      writer << image;