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

📄 visionview.h

📁 FIRA 3对3 机器人足球PC端控制程序。
💻 H
字号:
// VisionView.h : interface of the CVisionView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_VISIONVIEW_H__40926F6D_B1C4_11D1_B9ED_0000E818599F__INCLUDED_)
#define AFX_VISIONVIEW_H__40926F6D_B1C4_11D1_B9ED_0000E818599F__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define	PARTIAL_MAX_NUM_LABEL		200	/* max. numbering of labels */
#define	PARTIAL_MAXNUMLABEL_1		199
#define	PARTIAL_MAX_NUM_ESET		150	/* max. number of equivalent sets */
#define	PARTIAL_MAXNUMESET_1		149

#define	MAX_NUM_LABEL		700	/* max. numbering of labels */
#define	MAXNUMLABEL_1		699
#define	MAX_NUM_ESET		300	/* max. number of equivalent sets */
#define	MAXNUMESET_1		299
#define	MAX_NUM_ELABEL		300	/* max. number of labels in each equivalent set */
#define	MAXNUMELABEL_1		299
#define	MAX_PIX_SIZE		400
#define	MAXPIXSIZE_1		399

// Choi.W.H  2000.02.18 
//#define	NUM_COLORS			4
#define	NUM_COLORS			6

#define BALL_COLOR			0
#define TEAM_COLOR			1
#define ID1_COLOR			2
/////////////////////////////////////////////////
// Choi.W.H  2000.02.21
#define ID2_COLOR			3
#define ID3_COLOR			4
#define OPPONENT_COLOR		5

//#define OPPONENT_COLOR		3
// Choi.W.H  2000.02.21
////////////////////////////////////////////////

#define	NONE_COLOR			-1
  
#define	IMAGE_SIZE_X		640
#define	IMAGE_SIZE_Y		480


#define HOME1		0	// Be sure that HOME1=0, HOME2=1, ... , HGOALIE=4.
#define HOME2		1
#define HGOALIE		2
#define BALL		3
#define OPPONENT1	4
#define OPPONENT2	5
#define OPPONENT3	6
#define OPPONENT_C  4

//#define HOME3		2	
//#define HOME4		3
//#define OPPONENT4	7
//#define OPPONENT5	8

#define OPP1	0
#define OPP2	1
#define OPP3	2
//#define OPP4	3
//#define OPP5	4


class CVisionDoc;
class CVisionView : public CFormView
{
protected: // create from serialization only
	CVisionView();
	DECLARE_DYNCREATE(CVisionView)

public:
	//{{AFX_DATA(CVisionView)
	enum { IDD = IDD_VISION_FORM };
	BOOL	m_bFlagFindBall;
	BOOL	m_bFlagFindHgoalie;
	BOOL	m_bFlagFindHome1;
	BOOL	m_bFlagFindHome2;
	BOOL	m_bFlagFindHome3;
	BOOL	m_bFlagFindHome4;
	BOOL	m_bPort1;
	int		m_nGame;
	int		m_nSetting;
	BOOL	m_bFlagDraw;
	CString	m_sInfo;
	BOOL	m_bEnableInitPos;
	int		m_nLeftHome;
	BOOL	m_bFlagFindOpponent1;
	BOOL	m_bFlagFindOpponent2;
	BOOL	m_bFlagFindOpponent3;
	BOOL	m_bFlagFindOpponent4;
	BOOL	m_bFlagFindOpponent5;
	//}}AFX_DATA

// Attributes
	

private:
	CVisionDoc* GetDocument();
	CRect	MMRect;					// CRect variable
	CRect	rcClient;				// RECT variable
	CRect	SelectedRectInZoom, rectBoundary;
	BOOL	bSetColor, bBeginZoom, bEndZoom, bSetRobotSize;
	BYTE	ZoomBuffer[17000];	  //64*64*4 = 16384	
	BYTE	ImageBuffer[1230000]; //640*480*4 = 1228800
	BYTE	*ptrBuffer;
	short	BallColor[6], TeamColor[6], IdColor[3][6], OpponentColor[6];
	short	Rmin, Rmax, Gmin, Gmax, Bmin, Bmax;
	long	ZoomLeft, ZoomTop, DispSizeX, DispSizeY;
	long	NumberOfDigitizer;	// Number of digitizers available on the system
	long	TransparentColor;		// Keying color
	short	SizeXofRobot, SizeYofRobot;
	BOOL	bFlagIsOurHomeLeft;
	unsigned long	iteration;
	MIL_ID	MilOverlayImage;		// Overlay image buffer identifier 
	MIL_ID	MilDisplayId;				// Display identifier.
	MIL_ID	MilDigitizerId;
	MIL_ID	MilImageBufferId;
	long	index_lut;
	BOOL	bPlay, bFlagEven;
	BOOL	bFlagSendCommand;
	BOOL	nInitPosBall;

	/*********** VRAM Access *****************/
	RECT	clientRect;		//position of client area on screen
	char*	PointPhys;
	/*********** VRAM Access *****************/

unsigned long  start_t, end_t;
BOOL	       start_t_flag, end_t_flag;
unsigned long	           delay_time;
double	       past_position;


	/*************** variable declarations for vision routine ****************/
	short	label[IMAGE_SIZE_Y][IMAGE_SIZE_X];
	short	ES[6][MAX_NUM_ESET][MAX_NUM_ELABEL], whichES[6][MAX_NUM_LABEL];
	short	i, j, index, indexES1, indexES2, indexes_whichcolor, numberoflabel_whichcolor;
	short	UpperLabel, LeftLabel, tmpLabel, sizeES1, sizeES2, SumOfSize;
	short	whichColor, WhereAppended, /*whichcomponent,*/ whichComponent[NUM_COLORS][MAX_NUM_ESET];
	short	ColorOfUpperLabel, ColorOfLeftLabel, ColorOfLabel[IMAGE_SIZE_Y][IMAGE_SIZE_X];
	long	R, G, B;
	// Big Team Color
	short	WhichComponentOfBigTeamColor[MAX_NUM_ESET];
	short	WhichComponentOfSmallIDColor[3][MAX_NUM_ESET];
	short	NumberOfBigTeamColors;
	BOOL	ValidFlagOfComponentOfBigTeamColor[MAX_NUM_ESET];
	// Small ID Color
	short	CenterXOfComponentOfSmallIDColor[3][MAX_NUM_ESET], CenterYOfComponentOfSmallIDColor[3][MAX_NUM_ESET];
	short	NumberOfSmallIDColors[3];

	short	NoError;
	short	NumberOfLabel[NUM_COLORS], indexES[NUM_COLORS];
	short	NumberOfComponent[NUM_COLORS], CenterXOfComponent[NUM_COLORS][MAX_NUM_ESET], CenterYOfComponent[NUM_COLORS][MAX_NUM_ESET];
	long	SumOfX[NUM_COLORS][MAX_NUM_ESET], SumOfY[NUM_COLORS][MAX_NUM_ESET];
	short	Component[NUM_COLORS][MAX_NUM_ESET][MAX_PIX_SIZE][2];
	short	PixelSizeOfComponent[NUM_COLORS][MAX_NUM_ESET];
	
	short	LowerBoundOfBallSize, UpperBoundOfBallSize;
	short	LowerBoundOfBigTeamSize, UpperBoundOfBigTeamSize;
	short	LowerBoundOfSmallIDSize, UpperBoundOfSmallIDSize;
	short	LowerBoundOfOpponentSize, UpperBoundOfOpponentSize;
	short	DistanceBetweenBigTeamAndSmallID;
	
	short	iPositionOfBall[2], iPositionOfHomeRobot[5][2], iAngleOfHomeRobot[5], iPositionOfOpponent[5][2];
	BOOL	bFlagFindBall, bFlagFindHomeRobot[5], bFlagFindOpponent[5];
	BOOL	bFlagBallFound, bFlagHomeRobotFound[5], bFlagOpponentFound[5];
	long	index_vram;


	/*************** variable declarations for vision routine ****************/

		
private:
	void	Zoom(CPoint point);
	void	SetColorUpdate();
	void	MinMaxOfRGB(CPoint point);
	void	InitSetColorDlg();
	void	UpdateLUTcolor(short *ptr, const int color); 
	void	UpdateLUTAllColor(); 
	void	FindObjects();
	void	DetermineOffsetXY(short rx, short ry, short size, long *offx, long *offy);


	
	/************ VRAM Access ******************/
	void	GetWndPos();
	void	InitVramAccess();
	/************ VRAM Access ******************/
	

	/*************** variable declarations for vision routine ****************/
	void DetermineComponentsOfBigTeamColor();
	// Choi.W.H  2000.02.18
	//void DetermineComponentsOfSmallIDColor();
	void DetermineComponentsOfSmallIDColor(short whichRobot);
	
	void FindBall(short OffX, short OffY);
	void FindOpponent(short whichRobot, short OffX, short OffY);
	void FindHomeRobot(short whichRobot, short OffX, short OffY);
/////////////////////////////////////////////////
// Choi.W.H  2000.02.21	
	long MinDistanceFromBigTeamColor(short sX, short sY, short* spBigteam_nearst);
	
	void LabelingWholeImage(short object);
	//void LabelingWholeImage(long ImageSizeX, long ImageSizeY);
// Choi.W.H  2000.02.21
// //////////////////////////////////////////////
	void LabelingPartialImage(long OffsetX, long OffsetY, long ImageSizeX, long ImageSizeY, short object);
	/*************** variable declarations for vision routine ****************/

			
// Operations
public:
	void	RemoveFromDisplay();
	
// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CVisionView)
	public:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void OnInitialUpdate();
	virtual BOOL DestroyWindow();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
public:
	BOOL m_nStopflag;
	virtual ~CVisionView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CVisionView)
	afx_msg void OnSetColor();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnSetBoundary();
	afx_msg void OnLoadConfiguration();
	afx_msg void OnSaveConfiguration();
	afx_msg void OnChangeColor();
	afx_msg void OnSetPixelSize();
	afx_msg void OnSetRobotSize();
	afx_msg void OnFlagFindBall();
	afx_msg void OnFlagFindHgoalie();
	afx_msg void OnFlagFindHome1();
	afx_msg void OnFlagFindHome2();
	afx_msg void OnFlagFindHome3();
	afx_msg void OnFlagFindHome4();
	afx_msg void OnCom1();
	afx_msg void OnCom2();
	afx_msg void OnLeftHome();
	afx_msg void OnRightHome();
	afx_msg void OnKickOff();
	afx_msg void OnPenalityKick();
	afx_msg void OnFreeKick();
	afx_msg void OnFreeBall();
	afx_msg void OnGoalieKick();
	afx_msg void OnDefense();
	afx_msg void OnReady();
	afx_msg void OnStopGame();
	afx_msg void OnFlagDraw();
	afx_msg void OnStartGame();
	afx_msg void OnLoadVxd();
	afx_msg void OnContinuousGrab();
	afx_msg void OnPosBallRadio();
	afx_msg void OnPosHgoalieRadio();
	afx_msg void OnPosHome1Radio();
	afx_msg void OnPosHome2Radio();
	afx_msg void OnPosHome3Radio();
	afx_msg void OnPosHome4Radio();
	afx_msg void OnEnableInitPosCheck();
	afx_msg void OnFlagFindOpponent1();
	afx_msg void OnFlagFindOpponent2();
	afx_msg void OnFlagFindOpponent3();
	afx_msg void OnFlagFindOpponent4();
	afx_msg void OnFlagFindOpponent5();
	afx_msg void OnPosOppo1Radio();
	afx_msg void OnPosOppo2Radio();
	afx_msg void OnPosOppo3Radio();
	afx_msg void OnPosOppo4Radio();
	afx_msg void OnPosOppo5Radio();
	afx_msg void OnRobotStop();
	afx_msg void OnFreeBall2();
	afx_msg void OnAutoSetting();
	afx_msg void OnSelectSituation();
	afx_msg void OnWholeFind();
	afx_msg void OnColortunning();
	afx_msg void OnTestOnMnu();
	afx_msg void OnTestOffMnu();
	afx_msg void OnKickOff2();
	afx_msg void OnPenalityKick2();
	afx_msg void OnFreeKick2();
	afx_msg void OnGoalieKick2();
	afx_msg void OnFreeBall22();
	afx_msg void OnFreeBall21();
	afx_msg void OnFreeBall23();
	afx_msg void OnFreeBall24();
	afx_msg void OnDefense2();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in VisionView.cpp
inline CVisionDoc* CVisionView::GetDocument()
   { return (CVisionDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_VISIONVIEW_H__40926F6D_B1C4_11D1_B9ED_0000E818599F__INCLUDED_)

⌨️ 快捷键说明

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