aboutsummaryrefslogtreecommitdiff
path: root/samples/ObjectDetection/include/ImageUtils.hpp
diff options
context:
space:
mode:
authorÉanna Ó Catháin <eanna.ocathain@arm.com>2020-09-14 17:36:49 +0100
committerJim Flynn <jim.flynn@arm.com>2020-09-14 18:40:01 +0000
commit919c14ef132986aa1514b2070ce6d19b5579a6ab (patch)
tree5c281e02a083768f65871cb861ab9b32ac7d8767 /samples/ObjectDetection/include/ImageUtils.hpp
parent589e3e81a86c83456580e112978bf7a0ed5f43ac (diff)
downloadarmnn-919c14ef132986aa1514b2070ce6d19b5579a6ab.tar.gz
MLECO-929 Add Object Detection sample application using the public ArmNN C++ API
Change-Id: I14aa1b4b726212cffbefd6687203f93f936fa872 Signed-off-by: Éanna Ó Catháin <eanna.ocathain@arm.com>
Diffstat (limited to 'samples/ObjectDetection/include/ImageUtils.hpp')
-rw-r--r--samples/ObjectDetection/include/ImageUtils.hpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/samples/ObjectDetection/include/ImageUtils.hpp b/samples/ObjectDetection/include/ImageUtils.hpp
new file mode 100644
index 0000000000..07e2b839f9
--- /dev/null
+++ b/samples/ObjectDetection/include/ImageUtils.hpp
@@ -0,0 +1,58 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#pragma once
+
+#include "DetectedObject.hpp"
+#include "Types.hpp"
+
+#include <opencv2/opencv.hpp>
+
+#include <vector>
+
+const cv::InterpolationFlags DefaultResizeFlag = cv::INTER_NEAREST;
+
+/**
+* @brief Function to process the decoded results from the inference, and overlay the detail onto the provided frame
+* @param[in] decodedResults the decoded results from the inference output.
+* @param[in] inputFrame the frame to overlay the inference output details onto.
+* @param[in] labels the label set associated with the trained model used.
+*/
+void AddInferenceOutputToFrame(od::DetectedObjects& decodedResults,
+ cv::Mat& inputFrame,
+ std::vector<std::tuple<std::string, od::BBoxColor>>& labels);
+
+/**
+* @brief Function to resize a frame while keeping aspect ratio.
+*
+* @param[in] frame the frame we want to resize from.
+* @param[out] dest the frame we want to resize into.
+* @param[in] aspectRatio aspect ratio to use when resizing.
+*/
+void ResizeFrame(const cv::Mat& frame, cv::Mat& dest, const od::Size& aspectRatio);
+
+/**
+* @brief Function to pad a frame.
+* @param[in] src the frame we want to pad.
+* @param[out] dest the frame we want to store the result.
+* @param[in] bottom padding to use on bottom of the frame.
+* @param[in] right padding to use on the right of the frame.
+*/
+void PadFrame(const cv::Mat& src, cv::Mat& dest, int bottom, int right);
+
+/**
+ * Resize frame to the destination size and pad if necessary to preserve initial frame aspect ratio.
+ *
+ * @param frame input frame to resize
+ * @param dest output frame to place resized and padded result
+ * @param cache operation requires intermediate data container.
+ * @param destSize size of the destination frame
+ */
+void ResizeWithPad(const cv::Mat& frame, cv::Mat& dest, cv::Mat& cache, const od::Size& destSize);
+
+/**
+* @brief Function to retrieve the cv::scalar color from a RGB tuple.
+* @param[in] color the tuple form of the RGB color
+*/
+static cv::Scalar GetScalarColorCode(std::tuple<int, int, int> color); \ No newline at end of file