1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "CvVideoFileWriter.hpp"
7
8 namespace common
9 {
10
Init(const std::string & outputVideo,int encoding,double fps,int width,int height)11 void CvVideoFileWriter::Init(const std::string& outputVideo, int encoding, double fps, int width, int height)
12 {
13 m_ready = m_cvWriter.open(outputVideo, cv::CAP_FFMPEG,
14 encoding,
15 fps,
16 cv::Size(width, height), true);
17 }
18
19
WriteFrame(std::shared_ptr<cv::Mat> & frame)20 void CvVideoFileWriter::WriteFrame(std::shared_ptr<cv::Mat>& frame)
21 {
22 if(m_cvWriter.isOpened())
23 {
24 cv::cvtColor(*frame, *frame, cv::COLOR_RGB2BGR);
25 m_cvWriter.write(*frame);
26 }
27 }
28
IsReady() const29 bool CvVideoFileWriter::IsReady() const
30 {
31 return m_ready;
32 }
33
Close()34 void CvVideoFileWriter::Close()
35 {
36 m_cvWriter.release();
37 }
38 }// namespace common
39