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

📄 visiondata.h

📁 该文件是包含了机器人足球比赛中的整个系统的代码
💻 H
字号:
#ifndef _VisionData_h_DEFINED
#define _VisionData_h_DEFINED

#include "../Common/Common.h"


#define MAX_STORED_LINE_POINTS (3*DOUBLE_IMAGE_WIDTH)

// Use FOVx isntead !!
//#define CAMERA_ANGLE DEG_TO_RAD(58.0) // Maximum range of vision for the camera

// Infrared Parameters
#define INFRA_MIN_DIST 10 // This factor affects the minimum size that the object must be in the vision frame before an attempt at infrared is used
#define INFRA_MIN_X 60-INFRA_MIN_DIST // Defines the limits of the infrared sensor area 75
#define INFRA_MAX_X 90+INFRA_MIN_DIST // Defines the limits of the infrared sensor area 79
#define INFRA_MIN_Y 30-INFRA_MIN_DIST // Defines the limits of the infrared sensor area 62
#define INFRA_MAX_Y 60+INFRA_MIN_DIST // Defines the limits of the infrared sensor area 70
#define INFRA_AREA (INFRA_MAX_X - INFRA_MIN_X) * (INFRA_MAX_Y - INFRA_MIN_Y)
#define INFRA_CENTRE_X (INFRA_MAX_X - INFRA_MIN_X)/2 + INFRA_MIN_X
#define INFRA_CENTRE_Y (INFRA_MAX_Y - INFRA_MIN_Y)/2 + INFRA_MIN_Y


// A blob structure effectivly stores a set of coordinators which maps out the corners of the object
struct Blob {
  short minX, maxX, minY, maxY;
  short minXy, maxXy, minYx, maxYx; // so we can get the exact coords of the N,E,S,W points.
  short minXRotated, maxXRotated, minYRotated, maxYRotated; // Stores the rotated version of the blob
  short area;
  struct Blob* nextBlob;
  struct Blob* prevBlob;
  bool subsumed;
};

// The run struct defines a row of the image that has the same colour
struct Run {
  short line, startPoint, endPoint;
  short blobNumber;
  unsigned char colour; // NOTE: Changed from byte
};

// Defines the stucture for a point
struct point {
  int x;
  int y;
};

// Defines the limits of a line with in the lineDetPoints array
struct lineLimit {
  int startPoint;
  int endPoint;
};

// Defines the structure for a line
struct line {
  bool exists;
  double m;
  double b;
};

// Defines the structure for a sorted line
struct sortedLine {
  point points[MAX_STORED_LINE_POINTS];
  int numPoints;
  bool merged;
  bool subsumed;
};

struct Circle {
  double centreX, centreY;
  double radius, sd;
  bool isDefined;
};

#define DOWNCHECK -15

enum Colour {
  c_UNKNOWN = 0,
  c_FIELD_GREEN = 1,
  c_WHITE = 2,
  c_BALL_ORANGE = 3,
  c_ROBOT_RED = 4,
  c_ROBOT_BLUE = 5,
  c_BEACON_GREEN = 6,
  c_BEACON_BLUE = 7,
  c_BEACON_PINK = 8,
  c_BEACON_YELLOW = 9
};


enum {
  LEFTRIGHT = 0,
  RIGHTLEFT = 1,
  TOPBOTTOM = 2,
  BOTTOMTOP = 3,
};

#define NUMCOLOURS 10
#define MAXRUNSPERLINE DOUBLE_IMAGE_WIDTH/2 // A run must be at least 2 pixels long therefore the maximum num of runs is half the image width
#define MAXBLOBS MAXRUNSPERLINE*DOUBLE_IMAGE_HEIGHT
#define INC_X 5 // From objrecog_new (J code)
#define INC_Y 2 // From objrecog_new (J code)

class VisionData {
  public:
    VisionData();

    int* numRuns_;
    int* numBlobs_;
    Run** runs_;
    Blob** blobs_;

    void* ball_; // pointer to the best ball we have

    uchar* classified_;
    uchar* classifiedTight_;
    uchar* unclassified_;

#ifdef WIN32
    uchar* overlay;
#endif

    long infraRed_;
    double bodyTilt_;
    double bodyRoll_;
    double headPan_;
    double cosHeadPan_, sinHeadPan_;

    double headTiltBig_, headTiltSmall_, headTiltCombined_;
    double cosHeadTiltBig_, sinHeadTiltBig_;
    double cosHeadTiltSmall_, sinHeadTiltSmall_;
    double cosHeadTiltCombined_, sinHeadTiltCombined_;

    double headRoll_;
    double cosHeadRoll_, sinHeadRoll_;

    double effHeadTilt_; // Effective head tilt
    double cosEffHeadTilt_, sinEffHeadTilt_;
    double effHeadRoll_; // Effective head roll
    double cosEffHeadRoll_, sinEffHeadRoll_;

    double realElevation_;

    double accX; // Accelerometer values for the three sensors 
    double accY;
    double accZ;

    line leftBorderLine; // Stores the left border line
    line middleBorderLine; // Stores the middle border line
    line rightBorderLine; // Stores the right border line
    line horizonLine; // Stores the parameters of the horizon line
    line verticalLine; // Stores the line perpendicular to the horizon line
    line borderLine; 

    void DrawOverlayLine(int startX, int startY, double angle, int length, int colour);
    void DrawOverlayLine(int startX, int startY, double xInc, double yInc, int length, int colour);

    bool CheckForColour(Blob* b, int startX, int startY, int maxDistance, int colour, bool left);
    bool CheckForColourAngle(Blob* b, int startX, int startY, int maxDistance, int colour, double angle);
    bool CheckForMultipleColourAngle(Blob* currentBlob, int startX, int startY, int distance, int colour, int numRequiredPixels, double angle);
    bool CheckForColourLeft(Blob* b, int startX, int startY, int maxDistance, int colour);
    bool CheckForColourRight(Blob* b, int startX, int startY, int maxDistance, int colour);

    void UpdateLookupTrigonometry(int, double, double, double, double, double, double);
    void GenerateHorizon();
    double GetDistance(int x, int y, int x2, int y2);
    double CalculateHeading(int);
    double CalculateHeading(int cx, int cy, double sinEffRoll, double cosEffRoll);
    double CalculateElevation(int);
    double CalculateElevation(int cx, int cy, double sinEffRoll, double cosEffRoll);
    void TransformPosition(double*,double*,double*);
    void TransformPositionObject(void* vo_);
    void TransformPositionLine(void* vl_);
    void DeleteBlob(Blob* deleteBlob);
    double GetDistanceToPoint(double cx, double cy, double heightOfNeck);
    double GetDistanceToPointUnreliable(double cx, double cy, double heightOfNeck);
    double GetInfraredDistance(Blob*,Colour);
  
    // Config file variables
    bool doEdgeDetection;
    bool findSideLineCorner;
    bool findCentreLineCorner;
    bool findGoalCorner;
    bool findCentreCircle;
    bool findSideLineAngle;
    bool useSanityFactors;
    bool useWhiteBelowBeaconCheck;
    double maxHeight;

    // Sanity Factor System
    double NonLinearScaling(double value, double min, double max);
};

#endif

⌨️ 快捷键说明

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