|
1 |
| -// Copyright (C) 2020 Intel Corporation |
| 1 | +// Copyright (C) 2020-2021 Intel Corporation |
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 | 3 | //
|
4 | 4 |
|
5 | 5 | #include <utils/ocv_common.hpp>
|
6 | 6 | #include "visualizer.hpp"
|
7 | 7 |
|
8 | 8 | // EmotionBarVisualizer
|
9 |
| -EmotionBarVisualizer::EmotionBarVisualizer(std::vector<std::string> const& emotionNames, cv::Size size, cv::Size padding, |
10 |
| - double opacity, double textScale, int textThickness): |
11 |
| - emotionNames(emotionNames), size(size), padding(padding), |
12 |
| - opacity(opacity), textScale(textScale), textThickness(textThickness), |
13 |
| - internalPadding(0) { |
| 9 | +EmotionBarVisualizer::EmotionBarVisualizer(std::vector<std::string> const& emotionNames, |
| 10 | + cv::Size size, |
| 11 | + cv::Size padding, |
| 12 | + double opacity, |
| 13 | + double textScale, |
| 14 | + int textThickness): |
| 15 | + emotionNames(emotionNames), size(size), padding(padding), opacity(opacity), |
| 16 | + textScale(textScale), textThickness(textThickness), internalPadding(0) { |
14 | 17 | auto itMax = std::max_element(emotionNames.begin(), emotionNames.end(), [] (std::string const& lhs, std::string const& rhs) {
|
15 | 18 | return lhs.length() < rhs.length();
|
16 | 19 | });
|
@@ -68,7 +71,7 @@ void PhotoFrameVisualizer::draw(cv::Mat& img, cv::Rect& bb, cv::Scalar color) {
|
68 | 71 |
|
69 | 72 | // HeadPoseVisualizer
|
70 | 73 | HeadPoseVisualizer::HeadPoseVisualizer(float scale, cv::Scalar xAxisColor, cv::Scalar yAxisColor, cv::Scalar zAxisColor, int axisThickness):
|
71 |
| - xAxisColor(xAxisColor), yAxisColor(yAxisColor), zAxisColor(zAxisColor), axisThickness(axisThickness), scale(scale) { |
| 74 | + xAxisColor(xAxisColor), yAxisColor(yAxisColor), zAxisColor(zAxisColor), axisThickness(axisThickness), scale(scale) { |
72 | 75 | }
|
73 | 76 |
|
74 | 77 | void HeadPoseVisualizer::buildCameraMatrix(cv::Mat& cameraMatrix, int cx, int cy, float focalLength) {
|
@@ -151,13 +154,13 @@ void HeadPoseVisualizer::draw(cv::Mat& frame, cv::Point3f cpoint, float yaw, flo
|
151 | 154 | // Visualizer
|
152 | 155 | Visualizer::Visualizer(bool m_ag, bool m_em, bool m_hp, bool m_lm,
|
153 | 156 | int leftPadding, int rightPadding, int topPadding, int bottomPadding):
|
154 |
| - emotionVisualizer(nullptr), photoFrameVisualizer(std::make_shared<PhotoFrameVisualizer>()), |
155 |
| - headPoseVisualizer(std::make_shared<HeadPoseVisualizer>()), |
156 |
| - nxcells(0), nycells(0), xstep(0), ystep(0), leftPadding(leftPadding), |
157 |
| - rightPadding(rightPadding), topPadding(topPadding), |
158 |
| - bottomPadding(bottomPadding), frameCounter(0), |
159 |
| - _isAgeGenderEnabled(m_ag), _isEmotionsEnabled(m_em), |
160 |
| - _isHeadPoseEnabled(m_hp), _isLandmarksEnabled(m_lm) {} |
| 157 | + emotionVisualizer(nullptr), photoFrameVisualizer(std::make_shared<PhotoFrameVisualizer>()), |
| 158 | + headPoseVisualizer(std::make_shared<HeadPoseVisualizer>()), |
| 159 | + nxcells(0), nycells(0), xstep(0), ystep(0), leftPadding(leftPadding), |
| 160 | + rightPadding(rightPadding), topPadding(topPadding), |
| 161 | + bottomPadding(bottomPadding), frameCounter(0), |
| 162 | + _isAgeGenderEnabled(m_ag), _isEmotionsEnabled(m_em), |
| 163 | + _isHeadPoseEnabled(m_hp), _isLandmarksEnabled(m_lm) {} |
161 | 164 |
|
162 | 165 | void Visualizer::enableEmotionBar(const cv::Size inImgSize, std::vector<std::string> const& emotionNames) {
|
163 | 166 | if (inImgSize != imgSize) {
|
@@ -186,10 +189,11 @@ void Visualizer::enableEmotionBar(const cv::Size inImgSize, std::vector<std::str
|
186 | 189 | }
|
187 | 190 |
|
188 | 191 | void Visualizer::drawFace(cv::Mat& img, Face::Ptr f, bool drawEmotionBar) {
|
189 |
| - auto genderColor = (_isAgeGenderEnabled) ? |
190 |
| - ((f->isMale()) ? cv::Scalar(255, 0, 0) : |
191 |
| - cv::Scalar(147, 20, 255)) : |
192 |
| - cv::Scalar(100, 100, 100); |
| 192 | + auto genderColor = (_isAgeGenderEnabled) |
| 193 | + ? ((f->isMale()) |
| 194 | + ? cv::Scalar(255, 0, 0) |
| 195 | + : cv::Scalar(147, 20, 255)) |
| 196 | + : cv::Scalar(100, 100, 100); |
193 | 197 |
|
194 | 198 | std::ostringstream out;
|
195 | 199 | if (_isAgeGenderEnabled) {
|
|
0 commit comments