From 1b351233b73aaba0b458e01ae6b4bf8994e402a1 Mon Sep 17 00:00:00 2001 From: "simon.fanetti" <simon.fanetti@etu.hesge.ch> Date: Wed, 15 Jul 2020 17:15:59 +0200 Subject: [PATCH] cleaning --- inc/sandboxSetup.h | 3 -- src/lib/sandboxSetup.cpp | 74 +--------------------------------------- 2 files changed, 1 insertion(+), 76 deletions(-) diff --git a/inc/sandboxSetup.h b/inc/sandboxSetup.h index 967a75c..94cbf17 100644 --- a/inc/sandboxSetup.h +++ b/inc/sandboxSetup.h @@ -14,8 +14,6 @@ class SandboxSetup{ Camera *camera; Beamer *beamer; - std::vector<std::vector<cv::Point2i>> getTriangles(std::vector<cv::Point2i> rectPoints); - std::vector<cv::Point2i> getCentroids(std::vector<std::vector<cv::Point2i>> triangles); double toDegrees(double radians); public: @@ -37,7 +35,6 @@ class SandboxSetup{ int loadCroppingMask(); // edit variables of config => not persistant - cv::Point2i getCenterOfQuadrilateral(std::vector<cv::Point> rectPoints); void setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Point center); void setupCroppingMask(std::vector<cv::Point> rectPoints); }; diff --git a/src/lib/sandboxSetup.cpp b/src/lib/sandboxSetup.cpp index 6c0ef6a..13d0205 100644 --- a/src/lib/sandboxSetup.cpp +++ b/src/lib/sandboxSetup.cpp @@ -62,37 +62,6 @@ int SandboxSetup::loadFrameProcessProfil(){ return loadFrameProcessProfilFrom(defaultConfigFilePath); } -/* - Get the centroid of a quadrilateral - source : http://jwilson.coe.uga.edu/EMT668/EMT668.Folders.F97/Patterson/EMT%20669/centroid%20of%20quad/Centroid.html -*/ -cv::Point2i SandboxSetup::getCenterOfQuadrilateral(std::vector<cv::Point> rectPoints){ - - std::vector<std::vector<cv::Point2i>> triangles = getTriangles(rectPoints); - std::vector<cv::Point2i> centroids = getCentroids(triangles); - - /* - Pa = P1 + mua (P2 - P1) - Pb = P3 + mub (P4 - P3) - */ - cv::Point3d pa; - cv::Point3d pb; - double mua; - double mub; - beamer->LineLineIntersect( cv::Point3d(centroids.at(0).x, centroids.at(0).y, 0), - cv::Point3d(centroids.at(2).x, centroids.at(2).y, 0), - cv::Point3d(centroids.at(1).x, centroids.at(1).y, 0), - cv::Point3d(centroids.at(3).x, centroids.at(3).y, 0), - &pa, &pb, &mua, &mub ); - - // pa and pb should be the same - cv::Point2i center; - center.x = (pa.x + pb.x) / 2; - center.y = (pa.y + pb.y) / 2; - - return center; -} - /* Assuming points positions are : * pts[0] : top left @@ -107,7 +76,7 @@ void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Poin // Set adjusting matrix for the projection int widthTop = rectPoints[3].x - rectPoints[0].x; double angle = atan((double)(rectPoints[3].y - rectPoints[0].y) / widthTop); - cv::Mat_<float> matRotation = cv::getRotationMatrix2D(center, toDegrees(angle), 1); // adjustingMatrix + cv::Mat_<float> matRotation = cv::getRotationMatrix2D(center, toDegrees(angle), 1); projection->setAdjustingMatrix(matRotation); } @@ -138,47 +107,6 @@ void SandboxSetup::setupCroppingMask(std::vector<cv::Point2i> rectPoints){ // -/* - Get the 4 triangles in the quadrilateral -*/ -std::vector<std::vector<cv::Point2i>> SandboxSetup::getTriangles(std::vector<cv::Point2i> rectPoints){ - - std::vector<std::vector<cv::Point2i>> triangles; - std::vector<cv::Point2i> A, B, C, D; - std::vector<cv::Point2i> lst[4] = {A,B,C,D}; - - // 4 triangles in the quadrilateral - for (int i=0; i<4; i++){ - // corners in the triangle - for(int j=0; j<3; j++){ - lst[i].push_back(rectPoints.at( (i+j)%rectPoints.size() )); - } - triangles.push_back(lst[i]); - } - - return triangles; -} - -/* - Get the centroid of each of the 4 triangles - source : https://www.khanacademy.org/math/geometry-home/triangle-properties/medians-centroids/v/triangle-medians-and-centroids -*/ -std::vector<cv::Point2i> SandboxSetup::getCentroids(std::vector<std::vector<cv::Point2i>> triangles){ - - std::vector<cv::Point2i> centroids; - - // the centroid is the average of the 3 coordinates - for(int i=0; i<(int)triangles.size(); i++){ - std::vector<cv::Point2i> tr = triangles.at(i); - cv::Point2i center; - center.x = (tr.at(0).x + tr.at(1).x + tr.at(2).x) / 3; - center.y = (tr.at(0).y + tr.at(1).y + tr.at(2).y) / 3; - centroids.push_back(center); - } - - return centroids; -} - double SandboxSetup::toDegrees(double radians){ return radians * (180.0 / M_PI); } -- GitLab