首页 > 代码库 > opencv在图片上添加文字

opencv在图片上添加文字

/******************************************
	func:cvText
	desc:put text on an image

	@param img The image pointer which we want to put text on
	@param text the text pointer
	@param x the x coordinate
	@param y the y coordinate

	@return null
******************************************/

void cvText(IplImage* img, const char* text, int x, int y)
{
	CvFont font;
	double hscale = 2;
	double vscale = 2;
	int linewidth = 3;
	cvInitFont(&font,CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,hscale,vscale,0,linewidth);
	CvScalar textColor =cvScalar(0,255,255);
	CvPoint textPos =cvPoint(x, y);
	cvPutText(img, text, textPos, &font,textColor);
}