Éanna Ó Catháin | 919c14e | 2020-09-14 17:36:49 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "CvVideoFileWriter.hpp" |
| 7 | |
Éanna Ó Catháin | c6ab02a | 2021-04-07 14:35:25 +0100 | [diff] [blame] | 8 | namespace common |
Éanna Ó Catháin | 919c14e | 2020-09-14 17:36:49 +0100 | [diff] [blame] | 9 | { |
| 10 | |
| 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 | |
| 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 | |
| 29 | bool CvVideoFileWriter::IsReady() const |
| 30 | { |
| 31 | return m_ready; |
| 32 | } |
| 33 | |
| 34 | void CvVideoFileWriter::Close() |
| 35 | { |
| 36 | m_cvWriter.release(); |
| 37 | } |
Éanna Ó Catháin | c6ab02a | 2021-04-07 14:35:25 +0100 | [diff] [blame] | 38 | }// namespace common |