diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-03-26 12:54:09 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-03-26 12:54:09 +0200 |
| commit | 7dbd32ddcf6611dec88ef56336b364110b019571 (patch) | |
| tree | 9cb2ed657787d907b6bbd7695aafa244bba886ee /Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp | |
| parent | 0aaf60dbc0322abc6707b5cf057d797fc26a1734 (diff) | |
| download | Tango-7dbd32ddcf6611dec88ef56336b364110b019571.tar.gz Tango-7dbd32ddcf6611dec88ef56336b364110b019571.zip | |
A lot of work !!!!
Diffstat (limited to 'Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp')
| -rw-r--r-- | Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp b/Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp new file mode 100644 index 000000000..6e49c315c --- /dev/null +++ b/Software/Visual_Studio/TCC/Tango.TCC.OpenCV/Utils.cpp @@ -0,0 +1,41 @@ +#include "Utils.h" + + + +Utils::Utils() +{ +} + + +Utils::~Utils() +{ +} + +Rect Utils::cropRect(Rect rect, Size size) +{ + Point center = (rect.br() + rect.tl())*0.5; + Rect cropped(center.x - size.width / 2, center.y - size.height / 2, size.width, size.height); + return cropped; +} + +Scalar Utils::getRectMeanColor(Mat image, Rect rect) +{ + Point pts[1][4]; + pts[0][0] = Point(rect.x, rect.y); + pts[0][1] = Point(rect.x + rect.width, rect.y); + pts[0][2] = Point(rect.x + rect.width, rect.y + rect.height); + pts[0][3] = Point(rect.x, rect.y + rect.height); + + const Point* points[1] = { pts[0] }; + int npoints = 4; + + // Create the mask with the polygon + Mat1b mask(image.rows, image.cols, uchar(0)); + + fillPoly(mask, points, &npoints, 1, Scalar(255)); + + // Compute the mean with the computed mask + Scalar average = mean(image, mask); + + return average; +}
\ No newline at end of file |
