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

📄 draw.h

📁 用于系统跟踪的程序
💻 H
字号:
#pragma warning(disable : 4996)

#include <cv.h>
//绘制十字叉
void DrawCross(IplImage* img ,CvPoint center,int type)
{
	CvPoint pt1,pt2;
	pt1.x=center.x-5;
	pt1.y=center.y;
	pt2.x=center.x+5;
	pt2.y=center.y;
	if(type==0)
	{
		pt1.x=center.x-500;
		pt1.y=center.y;
		pt2.x=center.x+500;
		pt2.y=center.y;
		cvLine(img,pt1,pt2,CV_RGB(0,0,255), 1, 4, 0 );
	}
	if(type==1)cvLine(img,pt1,pt2,CV_RGB(255,0,255), 1, 4, 0 );
 	if(type==2)cvLine(img,pt1,pt2,CV_RGB(255,255,255), 1, 4, 0 );
 	if(type==3)cvLine(img,pt1,pt2,CV_RGB(0,255,0), 1, 4, 0 );

	pt1.x=center.x;
	pt1.y=center.y-5;
	pt2.x=center.x;
	pt2.y=center.y+5;
	if(type==0)
	{
		pt1.x=center.x;
		pt1.y=center.y-500;
		pt2.x=center.x;
		pt2.y=center.y+500;
		cvLine(img,pt1,pt2,CV_RGB(0,00,255), 1, 4, 0 );
	}
	if(type==1)cvLine(img,pt1,pt2,CV_RGB(255,0,255), 1, 4, 0 );
	if(type==2)cvLine(img,pt1,pt2,CV_RGB(255,255,255), 1, 4, 0 );
	if(type==3)cvLine(img,pt1,pt2,CV_RGB(0,255,0), 1, 4, 0 );
}

void DrawCross(IplImage* img ,int x,int y,int type)
{
	CvPoint center;
	center.x=x;
	center.y=y;
	DrawCross(img,center,type);
}


//绘制点和信息

void DrawPoint(IplImage  *img,CvPoint pt,float floatValue)
{
	CvFont font;
	char  info[80];
	 

	int line_type = 8; // change it to 8 to see non-antialiased graphic
	cvInitFont(&font,10,0.4,0.4,0.2,0, line_type );
	 
	//显示每个点的编号
	sprintf((char *)info,"%f", floatValue); 
	//绘制点的位置
	DrawCross(img,pt.x,pt.y,1);
	cvPutText(img,info, pt,&font, CV_RGB(255,0,255));
}
void DrawPoint(IplImage  *img,int x,int y,float floatValue)
{
	CvPoint pt;
	pt.x=x;
	pt.y=y;
	DrawPoint(img,pt,floatValue);
}
void DrawPoint(IplImage  *img,int x,int y,int floatCount,int type)
{

	CvFont font;
	char  info[80];
	CvPoint pt1;

	int line_type = 8; // change it to 8 to see non-antialiased graphic
	cvInitFont(&font,10,0.4,0.4,0.2,0, line_type );
	pt1.x=x;
	pt1.y=y;
	//显示每个点的编号
	sprintf((char *)info,"%d", floatCount); 
	//绘制点的位置
	DrawCross(img,x,y,type);
	cvPutText(img,info, pt1,&font, CV_RGB(0,255,255));
}

//绘制点和信息
void DrawLine(IplImage  *img,CvPoint pt1,CvPoint pt2)
{
	cvLine(img,pt1,pt2,CV_RGB(255,255,0), 1, 4, 0 );
	DrawCross(img,pt1.x,pt1.y,1);
}
void DrawLine(IplImage  *img,float wx,float wy,float x0,float y0)
{
	CvPoint pt1,pt2;

	pt1.x=(int)(1000*wx+x0);
	pt1.y=(int)(1000*wy+y0);
	pt2.x=(int)(-1000*wx+x0);
	pt2.y=(int)(-1000*wy+y0);

	cvLine(img,pt1,pt2,CV_RGB(255,0,0), 1, 4, 0 );

}


//void DrawLine(IplImage  *img,double k, double b,bool isTurnXY)
//{
//	CvPoint pt1,pt2;
//	if(!isTurnXY)
//	{
//		pt1.x=0;
//		pt1.y=(int)(k*pt1.x+b);
//		pt2.x=(int)(img->width);
//		pt2.y=(int)(k*pt2.x+b);
//	}
//	else
//	{
//		pt1.y=0;
//		pt1.x=(int)(k*pt1.y+b);
//		pt2.y=(int)(img->width);
//		pt2.x=(int)(k*pt2.y+b);
//	}
//	cvLine(img,pt1,pt2,CV_RGB(255,0,0), 1, 4, 0 ); 
//}

//绘制一组点
void DrawPoints(IplImage  *img,CvPoint* points,int Count)
{
	int i=0;

	for(i=0;i<Count;i++)
	{
		DrawPoint(img,points[i].x ,points[i].y,i,1);
	}

}

⌨️ 快捷键说明

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