global.cpp 2.82 KB
Newer Older
1 2 3
#include <opencv2/opencv.hpp>
#include "global.h"
#include <mutex>
4
#include <QDebug>
5 6 7 8 9 10

using namespace std;
using namespace cv;


namespace Global {
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
ThreadVariables::~ThreadVariables(){
    Global::frame = frame;
    Global::frameHSV = frameHSV;
    Global::correctedFrame = correctedFrame;
    Global::thresholdBall = thresholdBall;
    Global::thresholdAllyF = thresholdAllyF;
    Global::thresholdAllyC = thresholdAllyC;
    Global::thresholdEnemy = thresholdEnemy;
    Global::posRobots = posRobots;
    Global::frenteRobots = frenteRobots;
    Global::contornosRobots = contornosRobots;
    Global::enemies = enemies;
    Global::ballPosition = ballPosition;
}

ThreadVariables::ThreadVariables(){
    posRobots = vector<Point2d>(3);
    frenteRobots = vector<Point2d>(3);
    contornosRobots = vector<vector<Point2d>>(3);
};

int defaultImageHeight;
vector<vector<Point2d>> lastTriangles;
vector<vector<Point2d>> lastAllyFormats;
bool showAllyThreshold = true;
bool showAllyFThreshold = true;
Mutex mtx;
int cameraStatus = 0;
VideoCapture cap;
bool capActive = false;
Mat frame;
Mat correctedFrame;
Mat frameHSV;
Mat thresholdAllyF;
Mat thresholdAllyC;
Mat thresholdBall;
Mat thresholdEnemy;
int frames = 0;
int fps = 0;
bool frameModReady = true;
bool enemyDetectionReady = true;
bool ballDetectionReady = true;
bool allyDetectionReady = true;
bool strategyCompilerReady = true;

int actualTab;

const double proporcao = 7.5;
const int comprimento = 150;
const int altura = 130;
const cv::Point2d marcas[] = {
    cv::Point2d(25, 37.5),
    cv::Point2d(65, 37.5),
    cv::Point2d(105, 37.5),
    cv::Point2d(25, 112.5),
    cv::Point2d(65, 112.5),
    cv::Point2d(105, 112.5)
};
const int alturaGol = 40;
const int alturaAG = 70;
const int larguraAG = 15;

int ballUH = 20;
int ballLH = 9;
int ballUS = 255;
int ballLS = 120;
int ballUV = 255;
int ballLV = 120;
cv::Point2d ballPosition(0, 0);
80

81 82 83 84 85 86 87 88
int enemyUH = 60;
int enemyLH = 25;
int enemyUS = 255;
int enemyLS = 120;
int enemyUV = 255;
int enemyLV = 120;
double distanceTolerance = 15;
vector<cv::Point2d> enemies;
89

90 91 92
vector<Point2d> posRobots(3);
vector<Point2d> frenteRobots(3);
vector<vector<Point2d>> contornosRobots(3);
93

94 95 96 97 98 99
int allyUH = 150;
int allyLH = 100;
int allyUS = 255;
int allyLS = 120;
int allyUV = 255;
int allyLV = 120;
100

101 102 103 104 105 106 107
int allyFUH = 180;
int allyFLH = 146;
int allyFUS = 255;
int allyFLS = 120;
int allyFUV = 255;
int allyFLV = 120;
int DISTANCE = 15;
108

109 110 111 112 113 114 115 116 117 118
std::vector<cv::Point2d> corners(4);
cv::Point2d midLeft;
cv::Point2d midRight;
double rotation = 0;
int confStatus = 0;
bool confConcluded = false;
cv::Mat homography;
std::string calibrationFramesPath = "/home/kramer/frames";
std::vector<std::vector<cv::Point3f>> object_points;
std::vector<std::vector<cv::Point2f>> image_points;
119

120 121 122 123
cv:: Mat intrinsic = cv::Mat(3, 3, CV_32FC1);
cv::Mat distCoeffs;
std::vector<cv::Mat> rvecs;
std::vector<cv::Mat> tvecs;
124
}