blob: 9bae5687559304c80b0c96b720b667a276784176 [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#pragma once
6
7#include "DetectedObject.hpp"
8#include "Types.hpp"
9
10#include <opencv2/opencv.hpp>
11
12#include <vector>
13
14const cv::InterpolationFlags DefaultResizeFlag = cv::INTER_NEAREST;
15
16/**
17* @brief Function to process the decoded results from the inference, and overlay the detail onto the provided frame
18* @param[in] decodedResults the decoded results from the inference output.
19* @param[in] inputFrame the frame to overlay the inference output details onto.
20* @param[in] labels the label set associated with the trained model used.
21*/
22void AddInferenceOutputToFrame(od::DetectedObjects& decodedResults,
23 cv::Mat& inputFrame,
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010024 std::vector<std::tuple<std::string, common::BBoxColor>>& labels);
Éanna Ó Catháin919c14e2020-09-14 17:36:49 +010025
26/**
27* @brief Function to resize a frame while keeping aspect ratio.
28*
29* @param[in] frame the frame we want to resize from.
30* @param[out] dest the frame we want to resize into.
31* @param[in] aspectRatio aspect ratio to use when resizing.
32*/
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010033void ResizeFrame(const cv::Mat& frame, cv::Mat& dest, const common::Size& aspectRatio);
Éanna Ó Catháin919c14e2020-09-14 17:36:49 +010034
35/**
36* @brief Function to pad a frame.
37* @param[in] src the frame we want to pad.
38* @param[out] dest the frame we want to store the result.
39* @param[in] bottom padding to use on bottom of the frame.
40* @param[in] right padding to use on the right of the frame.
41*/
42void PadFrame(const cv::Mat& src, cv::Mat& dest, int bottom, int right);
43
44/**
45 * Resize frame to the destination size and pad if necessary to preserve initial frame aspect ratio.
46 *
47 * @param frame input frame to resize
48 * @param dest output frame to place resized and padded result
49 * @param cache operation requires intermediate data container.
50 * @param destSize size of the destination frame
51 */
Éanna Ó Catháinc6ab02a2021-04-07 14:35:25 +010052void ResizeWithPad(const cv::Mat& frame, cv::Mat& dest, cv::Mat& cache, const common::Size& destSize);
Éanna Ó Catháin919c14e2020-09-14 17:36:49 +010053
54/**
55* @brief Function to retrieve the cv::scalar color from a RGB tuple.
56* @param[in] color the tuple form of the RGB color
57*/
58static cv::Scalar GetScalarColorCode(std::tuple<int, int, int> color);