blob: b76630049a1d9f5d10b4c6fcf44206a830c36f42 [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
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +01008namespace common
Éanna Ó Catháin919c14e2020-09-14 17:36:49 +01009{
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}
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010038}// namespace common