/* * Copyright (C) 2018 dimercur * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __IMG_H__ #define __IMG_H__ #include #include #include #include #include #include #ifdef __WITH_ARUCO__ #include #include //#include #include #endif // __WITH_ARUCO__ #define ARENA_NOT_DETECTED -1 using namespace std; typedef cv::Mat ImageMat; typedef vector Jpg; typedef struct { cv::Point2f center; cv::Point2f direction; float angle; int robotId; } Position; class Arena { public: Arena() {} cv::Rect arena; bool IsEmpty(); }; class Img { public: ImageMat img; Img(ImageMat imgMatrice); string ToString(); Img* Copy(); Jpg ToJpg(); Arena SearchArena(); int DrawRobot(Position robot); int DrawAllRobots(std::list robots); int DrawArena(Arena arenaToDraw); std::list SearchRobot(Arena arena); #ifdef __WITH_ARUCO__ list SearchAruco(Arena arena); cv::Ptr dictionary; #endif // __WITH_ARUCO__ private: #ifdef __WITH_ARUCO__ cv::Point2f FindArucoCenter(std::vector aruco); cv::Point2f FindArucoDirection(std::vector aruco); #endif // __WITH_ARUCO__ float CalculAngle(Position robots); float CalculAngle2(cv::Point2f pt1, cv::Point2f pt2); float EuclideanDistance(cv::Point2f p, cv::Point2f q); ImageMat CropArena(Arena arena); }; #endif //__IMG_H__