rmcv  v0.1.0
A library for RoboMaster computer vision based on OpenCV.
core.h
1 //
2 // Created by yaione on 2/26/2022.
3 //
4 
5 #ifndef RMCV_CORE_H
6 #define RMCV_CORE_H
7 
8 #include "utils.h"
9 
10 namespace rm {
11  enum CampType {
12  CAMP_RED = 0, CAMP_BLUE = 1, CAMP_GUIDELIGHT = 2, CAMP_NEUTRAL = -1
13  };
14 
15  enum AimMode {
16  AIM_COMBAT = 0, AIM_BUFF = 1, AIM_SNIPE = 2
17  };
18 
19  typedef std::vector<cv::Point> Contour;
20 
21  class LightBlob {
22  public:
23  float angle = 0;
24  rm::CampType camp = rm::CAMP_NEUTRAL;
25  cv::Point2f center;
26  cv::Point2f vertices[4];
27  cv::Size2f size;
28 
29  LightBlob() = default;
30 
31  explicit LightBlob(cv::RotatedRect box, rm::CampType camp = rm::CAMP_NEUTRAL);
32  };
33 
34  class Armour {
35  public:
36  float rank = 0;
37  rm::CampType camp = rm::CAMP_NEUTRAL;
38  cv::Point2f icon[4];
39  cv::Point2f vertices[4];
40 
41  Armour() = default;
42 
43  explicit Armour(std::vector<rm::LightBlob> lightBlobs, float rank = 0, rm::CampType camp = rm::CAMP_NEUTRAL);
44  };
45 
46  class Package {
47  public:
48  rm::CampType camp = rm::CAMP_NEUTRAL;
49  rm::AimMode mode = rm::AIM_COMBAT;
50  unsigned char speed = 0;
51  float pitch = 0;
52  cv::Mat frame;
53  cv::Mat binary;
54  std::vector<rm::Armour> armours;
55 
56  Package(rm::CampType camp, rm::AimMode mode, unsigned char speed, float pitch, const cv::Mat &inputFrame,
57  const cv::Mat &inputBinary);
58 
59  explicit Package(const std::shared_ptr<rm::Package> &input);
60  };
61 
62 }
63 
64 #endif //RMCV_CORE_H
rm::LightBlob::center
cv::Point2f center
Camp this light blob belongs to.
Definition: core.h:25
rm::LightBlob::vertices
cv::Point2f vertices[4]
Mass center of the light blob.
Definition: core.h:26
rm::LightBlob::LightBlob
LightBlob()=default
Width and height of the light blob.
rm::Package::speed
unsigned char speed
Aim mode.
Definition: core.h:50
rm::Package::frame
cv::Mat frame
Pitch angle.
Definition: core.h:52
rm::LightBlob
Definition: core.h:21
rm::LightBlob::camp
rm::CampType camp
Rotation angle of the light blob (vertical when the angle is 90)
Definition: core.h:24
rm::Armour
Definition: core.h:34
rm::Package::mode
rm::AimMode mode
Self camp.
Definition: core.h:49
rm::Armour::icon
cv::Point2f icon[4]
Camp this armour belongs to.
Definition: core.h:38
rm::Package
Definition: core.h:46
rm::LightBlob::size
cv::Size2f size
Four vertices around the light blob.
Definition: core.h:27
rm
Main modules.
Definition: daheng.h:17
rm::Package::pitch
float pitch
Bullet speed.
Definition: core.h:51
rm::Armour::Armour
Armour()=default
Vertices of armour (square with light blob as side length for better PNP result)
rm::Armour::camp
rm::CampType camp
A value help in sorting multiple armours.
Definition: core.h:37
rm::Armour::vertices
cv::Point2f vertices[4]
Vertices of icon area.
Definition: core.h:39