blob: ab80b95d493a2fcbc37a0ba1c815ae7eca41a0ec [file] [log] [blame]
Éanna Ó Catháin919c14e2020-09-14 17:36:49 +01001//
2// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#include "CvVideoFileWriter.hpp"
7
8namespace od
9{
10
11void 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
20void 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
29bool CvVideoFileWriter::IsReady() const
30{
31 return m_ready;
32}
33
34void CvVideoFileWriter::Close()
35{
36 m_cvWriter.release();
37}
38}// namespace od