Skip to content

Commit

Permalink
constants.h minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
albertopasqualetto committed Jul 21, 2024
1 parent b63b75a commit 9dcacff
Show file tree
Hide file tree
Showing 13 changed files with 1,435 additions and 1,435 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_library(TableOrientation include/tableOrientation.h src/tableOrientation.cpp
add_library(Transformation include/transformation.h src/transformation.cpp)
add_library(Tracking include/tracking.h src/tracking.cpp)
add_library(Metrics include/metrics.h src/metrics.cpp)
add_library(Utils include/category.h include/minimap.h include/util.h src/util_first.cpp src/util_second.cpp img/minimap.h)
add_library(Utils include/category.h include/constants.h include/util.h src/util_first.cpp src/util_second.cpp include/minimap.h)

target_link_libraries(Ball
${OpenCV_LIBS}
Expand Down
1,386 changes: 0 additions & 1,386 deletions img/minimap.h

This file was deleted.

45 changes: 45 additions & 0 deletions include/constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//Author: Michela Schibuola

#ifndef CONSTANTS_H
#define CONSTANTS_H

#include <string>
#include <opencv2/opencv.hpp>

//path of the minimap
// const std::string MINIMAP_PATH = "../img/minimap.png";

//corners of the table in the minimap
const cv::Point2f TOP_LEFT_MAP_CORNER = cv::Point2f(65, 63);
const cv::Point2f TOP_RIGHT_MAP_CORNER = cv::Point2f(901, 63);
const cv::Point2f BOTTOM_RIGHT_MAP_CORNER = cv::Point2f(901, 496);
const cv::Point2f BOTTOM_LEFT_MAP_CORNER = cv::Point2f(65, 496);
const cv::Vec<cv::Point2f, 4> MAP_CORNERS = {TOP_LEFT_MAP_CORNER, TOP_RIGHT_MAP_CORNER, BOTTOM_RIGHT_MAP_CORNER, BOTTOM_LEFT_MAP_CORNER};

//information about the minimap image
const int MINIMAP_IMG_WIDTH = 967;
const int MINIMAP_IMG_HEIGHT = 560;

//radius of the balls on the minimap
const double MAP_BALL_RADIUS = 12.6;

//colors for the balls in the minimap
const cv::Vec3b BACKGROUND_BGR_COLOR = cv::Vec3b(0, 0, 0); // black
const cv::Vec3b WHITE_BGR_COLOR = cv::Vec3b(255, 255, 255); // white
const cv::Vec3b BLACK_BGR_COLOR = cv::Vec3b(100, 100, 100); // gray
const cv::Vec3b SOLID_BGR_COLOR = cv::Vec3b(0, 0, 255); // red
const cv::Vec3b STRIPED_BGR_COLOR = cv::Vec3b(255, 0, 0); // blue
const cv::Vec3b PLAYING_FIELD_BGR_COLOR = cv::Vec3b(0, 255, 0); // green


//some real table dimensions (approximates)
const float POCKET_DIAMETER_CM = 15;
const float TABLE_LONGEST_EDGE_CM = 250;
const float BALL_RADIUS_CM = 2.86;
const float TABLE_DIAMETER_CM = 215;

// S>70, V>100 to be a color and not black or white
const int S_CHANNEL_COLOR_THRESHOLD = 70;
const int V_CHANNEL_COLOR_THRESHOLD = 100;

#endif //CONSTANTS_H
1,419 changes: 1,380 additions & 39 deletions include/minimap.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ball.h"
#include "detection.h"
#include "util.h"
#include "minimap.h"
#include "constants.h"

using namespace cv;
using namespace std;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <filesystem>
#include <chrono>

#include "../img/minimap.h"
#include "minimap.h"
#include "ball.h"
#include "table.h"
#include "detection.h"
Expand Down
2 changes: 1 addition & 1 deletion src/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "category.h"
#include "table.h"
#include "ball.h"
#include "minimap.h"
#include "constants.h"
#include <stdexcept>
#include <filesystem>
#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion src/segmentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "segmentation.h"
#include "ball.h"
#include "table.h"
#include "minimap.h"
#include "constants.h"
#include "util.h"

using namespace cv;
Expand Down
2 changes: 1 addition & 1 deletion src/showSegmentationColored.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <opencv2/highgui.hpp>
#include "ball.h"
#include "table.h"
#include "minimap.h"
#include "constants.h"
#include "metrics.h"
#include <iostream>
#include <fstream>
Expand Down
2 changes: 1 addition & 1 deletion src/tableOrientation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <opencv2/opencv.hpp>
#include "tableOrientation.h"
#include "minimap.h"
#include "constants.h"
#include "util.h"

#include "detection.h"
Expand Down
2 changes: 1 addition & 1 deletion src/transformation.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Author: Michela Schibuola

#include "transformation.h"
#include "minimap.h"
#include "constants.h"
#include "tableOrientation.h"
#include "util.h"

Expand Down
2 changes: 1 addition & 1 deletion src/util_first.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdexcept>
#include <opencv2/opencv.hpp>
#include "util.h"
#include "minimap.h"
#include "constants.h"
#include "ball.h"
#include "table.h"

Expand Down
2 changes: 1 addition & 1 deletion src/util_second.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <opencv2/opencv.hpp>
#include "util.h"
#include "minimap.h"
#include "constants.h"

using namespace std;
using namespace cv;
Expand Down

0 comments on commit 9dcacff

Please sign in to comment.