⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edgerecognition.h

📁 该文件是包含了机器人足球比赛中的整个系统的代码
💻 H
字号:
// File: EdgeRecognition.h
// Date: 18/02/03

#ifndef _EdgeRecognition_h_DEFINED
#define _EdgeRecognition_h_DEFINED

#include "../Common/VisionObject.h"
#include "../Common/VisionLine.h"
#include "../Common/Common.h"
#include "VisionData.h"

#define MAX_POINTS 20 // From objrecog_new (J code)
#define BORDER_WIDTH 20
#define MAXIMUM_SEPARATION 10 // Defines the maximum distance from the edge of the field where the first green pixel will no longer be replaced by the last white pixel found
#define MINIMUM_WIDTH  20
#define WALL_SEARCH_REGION 8 // Maximum distance we will search for a white pixel when trying to determine whether we are next to a wall
#define DOG_NECK_HEIGHT 13 // CS - Height of the dogs neck above the ground - only valid when the dog is standing
#define FIND_POINTS_MAXY_CHANGE 25
#define POINT_FIND_INC 4 // Distance between the lines we are searching on the field
#define GWG_Y_INC 2
#define MAX_SORTED_LINES 10
#define MAX_SIDELINE_POINTS (DOUBLE_IMAGE_WIDTH/POINT_FIND_INC) // Defines the maximum number of side lines points that we can find
#define MAX_FIELDLINE_POINTS (3 * DOUBLE_IMAGE_WIDTH/POINT_FIND_INC) // Defines the maximum number of field lines points that we can find
#define MAX_CENTRE_CIRCLE_POINTS DOUBLE_IMAGE_WIDTH
#define CENTRE_CORNER_ERROR_MAX 100

#define CORNER_MAX_RESIDUAL 100 // Not yet determined
#define CENTRE_POINT_MAX_RESIDUAL 1 
#define CENTRE_LINE_CORNER_MAX_RESIDUAL 5 
#define LINE_MAX_RESIDUAL 2 

#define HORIZON_ADJUSTMENT 20
#define MAX_FIELD_DISTANCE 400
#define SEARCH_DISTANCE 3

class EdgeRecognition {

public:
  EdgeRecognition(); // Class constructor
  void FindVanishingPoint(VisionData*);

private:
  VisionData* visionData;
  
  int centreCircleNum;
  int numFieldLineDetPoints; //  Stores the number of points found so far
  int numSideLineDetPoints; //  Stores the number of points found so far
  int numSortedLinesLeft;
  int numSortedLinesRight;
  int numSortedLinesSide;
  
  point sideLineDetPoints[MAX_SIDELINE_POINTS]; // Stores the points which have been found so far
  point fieldLineDetPoints[MAX_FIELDLINE_POINTS]; // Stores the points which have been found so far
  sortedLine sortedLinesLeft[MAX_SORTED_LINES];
  sortedLine sortedLinesRight[MAX_SORTED_LINES];
  sortedLine sortedLinesSide[MAX_SORTED_LINES];
  point centreCircle[MAX_CENTRE_CIRCLE_POINTS];

  bool PointBelowHorizon(int,int);
  void BoundaryDetection();
  void FindGoalCorner(double,double);
  void FindSideLineCorner();
  void EdgeDetection();
  void FindPoint(int);
  void CalcVanishingPoint();
  
  int FindBorderLine(line*);
  int FindCornerPoint(sortedLine,int,bool);
  int FitXLine(line*, point*, int,int,int);
  int FitYLine(line*, point*, int,int,int);
  int FitXLine(line*, point*, int,int,int, int, int, int, int);
  int FitYLine(line*, point*, int,int,int, int, int, int, int);
  int LeastSquaredFit(line*, int, int, int, int, int);
  double CalculateResidual(line, point*, int, int);
  
  void FindCornerData();
  void FindSideLinePoints(int, int, int, int);
  void FindSideLinePoints(VisionObject, int, int);
  void FindSideLinePoints(int, int, VisionObject);
  void FindSideLinePoints(VisionObject,VisionObject);
  void LocateFirstGreenBelow(int currX, int currY, int* greenPositionAbove, int* whitePosition, int* greenPositionBelow);
  void LocateFirstWhite(int currX, int currY, int* greenPositionAbove, int* whitePosition, int* greenPositionBelow, int* greenPositionUnknown);
  void AssociateData(int i, point* lineDetPoints, int numLineDetPoints, sortedLine* sortedLines, int* numSortedLines);
  double DataAssociationLeft(point* lineDetPoints, int numLineDetPoints, sortedLine* sortedLines, int* numSortedLines);
  double DataAssociationRight(point* lineDetPoints, int numLineDetPoints, sortedLine* sortedLines, int* numSortedLines);
  int MergeLines(sortedLine* sortedLines, int numSortedLines);

  void FindCentreCircle();
  void FindCentreLineCorner(double,double);
  void VerticalAndSideLineAngle();
  void FindPointGivenCenter(line*, int startXValue, double startDistance, int endXValue, double endDistance, const VisionLine::LineType type);
  void LocateFirstWhite(unsigned char* pPointer, int searchYDown, int* greenPositionAbove, int* whitePosition);
  void FindNextGreen(unsigned char* pPointer, int searchYDown, int* greenPositionBelow, int* whitePosition);
  void FindNextColour(unsigned char* pPointer, int searchYDown, int* greenPositionBelow, int* whitePosition);

  // Sanity Factor System
  void PointConfidence(VisionObject* visObject);
  void LineConfidence(VisionLine* visLine);
  int LocateStartPoint(sortedLine lineInstance);
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -