RLL Computer Vision Code: code/armour_detector.h 源文件

RLL Computer Vision

RLL Computer Vision Code  1.0
江苏科技大学HLL战队机器视觉代码
armour_detector.h
浏览该文件的文档.
1 /*****************************************************************************
2 * HLL Computer Vision Code *
3 * Copyright (C) 2017 HLL [email protected]. *
4 * *
5 * This file is part of HCVC. *
6 * *
7 * @file armour_detector.h *
8 * @brief Detect the armour zone *
9 * Details. *
10 * *
11 * @author HLL *
12 * @email [email protected] *
13 * @version 1.0.0.0 *
14 * @date 2017.11.10 *
15 * *
16 *----------------------------------------------------------------------------*
17 * Remark : Description *
18 *----------------------------------------------------------------------------*
19 * Change History : *
20 * <Date> | <Version> | <Author> | <Description> *
21 *----------------------------------------------------------------------------*
22 * 2017/11/10 | 1.0.0.0 | Zhu Min | Create file *
23 *----------------------------------------------------------------------------*
24 * *
25 *****************************************************************************/
26 
27 #ifndef ARMOUR_DETECTOR_H
28 #define ARMOUR_DETECTOR_H
29 
30 #include "image_preprocessor.h"
31 
32 namespace HCVC {
35 
41 {
42 public:
48 
57  bool detect(const Mat& srcImage);
58 
64  Rect2d getBestArmourBlock() const;
65 
73  void drawBlocks(Mat srcImage, const vector<RotatedRect>& minRotatedRects, const Scalar& color) const;
74 
76  struct Params
77  {
78  float angleRange;
79  float minArea;
83  float maxWidthRat;
84  float maxHeightRat;
85  float maxAngleDiff;
88  }params;
89 
90 private:
96  {
98  RotatedRect block;
100  double grade;
101 
103  OptimalArmourBlock(const RotatedRect& _block, const double& _grade):
104  block(_block), grade(_grade)
105  {}
106 
108  bool operator < (const OptimalArmourBlock& other) const
109  {
110  return grade < other.grade;
111  }
112  };
113 
114  //! 按顺序存储最优的装甲板区域
115  vector<OptimalArmourBlock> optimalArmourBlocks;
116 
122  vector<vector<Point> > searchBlocks(Mat srcImage);
123 
132  void fillLampBlock(Mat& srcImage, vector<vector<Point> >& blocks, int row, int col);
133 
139  vector<RotatedRect> calcBlocksInfo(const vector<vector<Point> >& blocks);
140 
146  vector<RotatedRect> extracArmourBlocks(const vector<RotatedRect>& minRotatedRects);
147 
155  void markArmourBlocks(const Mat& srcImage, const Mat& dstImage, const vector<RotatedRect>& armourBlocks);
156 
162  void cutEdgeOfRect(Point2f* points);
163 };
165 }
166 #endif // ARMOUR_DETECTOR_H
double grade
对该装甲板区域的评分
装甲板检测模块
装甲板判定参数
bool detect(const Mat &srcImage)
检测图像中是否存在装甲板区域
vector< vector< Point > > searchBlocks(Mat srcImage)
搜寻图中所有独立的团块
OptimalArmourBlock(const RotatedRect &_block, const double &_grade)
初始化参数
HLL Computer Vision Code namepace.
void cutEdgeOfRect(Point2f *points)
减去旋转矩形的边角,使旋转矩形的左右两条边与竖直方向平行,成为平行四边形
void markArmourBlocks(const Mat &srcImage, const Mat &dstImage, const vector< RotatedRect > &armourBlocks)
对最后提取出的灯柱区域评分,选出最优区域
最佳装甲板区域结构体
struct HCVC::ArmourDetector::Params params
void drawBlocks(Mat srcImage, const vector< RotatedRect > &minRotatedRects, const Scalar &color) const
在原图像上画出旋转矩形,便于调试
vector< RotatedRect > calcBlocksInfo(const vector< vector< Point > > &blocks)
计算每一个团块的信息,并进行初步的筛选即去除掉一些不符合条件的团块
void fillLampBlock(Mat &srcImage, vector< vector< Point > > &blocks, int row, int col)
用广度优先搜索填充每一个连通块
ArmourDetector()
加载装甲板区域判定参数
RotatedRect block
包围装甲板区域的选装矩形
图像预处理模块
Rect2d getBestArmourBlock() const
获取上一次图像中检测出的最佳装甲板区域
vector< OptimalArmourBlock > optimalArmourBlocks
vector< RotatedRect > extracArmourBlocks(const vector< RotatedRect > &minRotatedRects)
进一步筛选,匹配团块即灯柱对,提取出最优目标
制作者   doxygen 1.8.13