aboutsummaryrefslogtreecommitdiff
path: root/samples/common/include/CVUtils/CvVideoFileWriter.hpp
diff options
context:
space:
mode:
authorÉanna Ó Catháin <eanna.ocathain@arm.com>2021-04-07 14:35:25 +0100
committerJim Flynn <jim.flynn@arm.com>2021-05-07 09:11:52 +0000
commitc6ab02a626e15b4a12fc09ecd844eb8b95380c3c (patch)
tree9912ed9cdb89cdb24483b22d6621ae30049ae321 /samples/common/include/CVUtils/CvVideoFileWriter.hpp
parente813d67f86df41a238ff79b5c554ef5027f56576 (diff)
downloadarmnn-c6ab02a626e15b4a12fc09ecd844eb8b95380c3c.tar.gz
MLECO-1252 ASR sample application using the public ArmNN C++ API.
Change-Id: I98cd505b8772a8c8fa88308121bc94135bb45068 Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
Diffstat (limited to 'samples/common/include/CVUtils/CvVideoFileWriter.hpp')
-rw-r--r--samples/common/include/CVUtils/CvVideoFileWriter.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/samples/common/include/CVUtils/CvVideoFileWriter.hpp b/samples/common/include/CVUtils/CvVideoFileWriter.hpp
new file mode 100644
index 0000000000..30348f09cc
--- /dev/null
+++ b/samples/common/include/CVUtils/CvVideoFileWriter.hpp
@@ -0,0 +1,61 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+#include "IFrameOutput.hpp"
+#include <opencv2/opencv.hpp>
+
+namespace common
+{
+
+class CvVideoFileWriter : public IFrameOutput<cv::Mat> {
+public:
+ /**
+ * @brief Default constructor.
+ *
+ * Underlying open cv video writer object will be instantiated.
+ */
+ CvVideoFileWriter() = default;
+
+ ~CvVideoFileWriter() override = default;
+
+ /**
+ * @brief Initialises video file writer.
+ *
+ * Opens opencv writer with given params. FFMPEG backend is used.
+ *
+ * @param outputVideo path to the video file.
+ * @param encoding cv::CAP_PROP_FOURCC code.
+ * @param fps target frame rate.
+ * @param width target frame width.
+ * @param height target frame height.
+ *
+ */
+ void Init(const std::string& outputVideo, int encoding, double fps, int width, int height);
+
+ /**
+ * Writes frame to the file using opencv writer.
+ *
+ * @param frame data to write.
+ */
+ void WriteFrame(std::shared_ptr<cv::Mat>& frame) override;
+
+ /**
+ * Releases opencv writer.
+ */
+ void Close() override;
+
+ /**
+ * Checks if opencv writer was successfully opened.
+ * @return true is underlying writer is ready to be used, false otherwise.
+ */
+ bool IsReady() const override;
+
+private:
+ cv::VideoWriter m_cvWriter{};
+ bool m_ready = false;
+};
+}// namespace common \ No newline at end of file