From c3c0d2742db73d8a91cdc28218a58e4863086095 Mon Sep 17 00:00:00 2001
From: admin <zzjincn@163.com>
Date: 星期五, 25 四月 2025 15:11:20 +0800
Subject: [PATCH] rtmp推理处理

---
 PreProcessModel.cpp |  330 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 299 insertions(+), 31 deletions(-)

diff --git a/PreProcessModel.cpp b/PreProcessModel.cpp
index 5f9df8f..f634a54 100644
--- a/PreProcessModel.cpp
+++ b/PreProcessModel.cpp
@@ -58,6 +58,40 @@
 	}
 }
 
+int ToWchar(char* &src, wchar_t* &dest, const char *locale = "zh_CN.utf8")
+{
+    if (src == NULL) {
+        dest = NULL;
+        return 0;
+    }
+
+    // 鏍规嵁鐜鍙橀噺璁剧疆locale
+    setlocale(LC_CTYPE, locale);
+
+    // 寰楀埌杞寲涓洪渶瑕佺殑瀹藉瓧绗﹀ぇ灏�
+    int w_size = mbstowcs(NULL, src, 0) + 1;
+
+    // w_size = 0 璇存槑mbstowcs杩斿洖鍊间负-1銆傚嵆鍦ㄨ繍琛岃繃绋嬩腑閬囧埌浜嗛潪娉曞瓧绗�(寰堟湁鍙兘浣縧ocale
+    // 娌℃湁璁剧疆姝g‘)
+    if (w_size == 0) {
+        dest = NULL;
+        return -1;
+    }
+
+    //wcout << "w_size" << w_size << endl;
+    dest = new wchar_t[w_size];
+    if (!dest) {
+        return -1;
+    }
+
+    int ret = mbstowcs(dest, src, strlen(src)+1);
+    if (ret <= 0) {
+        return -1;
+    }
+    return 0;
+}
+
+
 // 鍦ㄥ浘鍍忎笂缁樺埗甯︽湁鑳屾櫙鐨勬枃鏈�
 void drawTextWithBackground(Mat& image, const string& text, int txalign, const Point& orgxy, const Point& orgwh, Scalar bgColor)
 {
@@ -65,9 +99,9 @@
 	{
 		CvxText chinese = CvxText("SimHei.ttf");
 		//璁剧疆浣嶇疆鍜屽瓧浣撳弬鏁�
-		Scalar textColor(0, 0, 0);//鐧借壊鏂囨湰
+		Scalar textColor(255, 255, 255);//鐧借壊鏂囨湰
 		//Scalar bgColor(0, 255, 0);//缁胯壊鑳屾櫙
-		int fontFace = FONT_HERSHEY_SIMPLEX;
+		int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
 		double fontScale = 0.2;
 		int thickness = 1;
 
@@ -75,14 +109,26 @@
 		Size textSize = getTextSize(text, fontFace, fontScale, thickness, 0);
 
 		//璁$畻鏂囨湰鑳屾櫙鐭╁舰妗嗙殑澶у皬
-		Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x, textSize.height + 30);
-
+		//Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x, textSize.height + 30);
+		if (text.length() >= 6)
+		{
+			Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x + textSize.width + 30, textSize.height + 30);
+			//缁樺埗鏂囨湰鑳屾櫙
+			cv::rectangle(image, backgroundRect, bgColor, FILLED);
+		}
+		else
+		{
+			Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x, textSize.height + 30);
+			//缁樺埗鏂囨湰鑳屾櫙
+			cv::rectangle(image, backgroundRect, bgColor, FILLED);
+		}
 		//缁樺埗鏂囨湰鑳屾櫙
-		rectangle(image, backgroundRect, bgColor, FILLED);
+		//rectangle(image, backgroundRect, bgColor, FILLED);
 
 		//CvxText chinese(ttfFont);
 		//璁剧疆瀛椾綋鐨勫ぇ灏� / 绌虹櫧姣斾緥 / 闂撮殧姣旇緝 / 鏃嬭浆瑙掑害
-		Scalar size(30, 0.5, 0, 0);
+		//Scalar size(30, 0.5, 0, 0);
+		Scalar size(25, 0, 0.1, 0);
 		float p = 1.0f; //璁剧疆瀛椾綋鐨勯�忔槑搴�
 		//璁剧疆瀛椾綋
 		chinese.setFont(nullptr, &size, nullptr, &p);
@@ -91,8 +137,8 @@
 		{
 		case 1://鏂囧瓧宸﹀榻�	
 			//缁樺埗鏂囨湰
-			chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5, (orgxy.y - (orgwh.y / 2) - 2)), textColor);
-
+			//chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5, (orgxy.y - (orgwh.y / 2) - 2)), textColor);
+			chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5, orgxy.y - 8), textColor);
 			break;
 		case 2://鏂囧瓧灞呬腑
 			//缁樺埗鏂囨湰
@@ -119,7 +165,84 @@
 	}
 
 }
+// 鍦ㄥ浘鍍忎笂缁樺埗甯︽湁鑳屾櫙鐨勬枃鏈�
+void drawTextWithBackgroundWstr(Mat& image, const string& _text, int txalign, const Point& orgxy, const Point& orgwh, Scalar bgColor)
+{
+	try
+	{
+		
 
+		std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
+    		std::wstring text = converter.from_bytes(_text);
+
+		CvxText chinese = CvxText("SimHei.ttf");
+		//璁剧疆浣嶇疆鍜屽瓧浣撳弬鏁�
+		Scalar textColor(255, 255, 255);//鐧借壊鏂囨湰
+		//Scalar bgColor(0, 255, 0);//缁胯壊鑳屾櫙
+		int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
+		double fontScale = 0.2;
+		int thickness = 1;
+
+		// 鑾峰彇鏂囧瓧闀垮害澶у皬
+		Size textSize = getTextSize(_text, fontFace, fontScale, thickness, 0);
+
+		//璁$畻鏂囨湰鑳屾櫙鐭╁舰妗嗙殑澶у皬
+		//Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x, textSize.height + 30);
+		if (text.length() >= 6)
+		{
+			Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x + textSize.width + 30, textSize.height + 30);
+			//缁樺埗鏂囨湰鑳屾櫙
+			cv::rectangle(image, backgroundRect, bgColor, FILLED);
+		}
+		else
+		{
+			Rect backgroundRect(orgxy.x, orgxy.y - textSize.height - 30, orgwh.x, textSize.height + 30);
+			//缁樺埗鏂囨湰鑳屾櫙
+			cv::rectangle(image, backgroundRect, bgColor, FILLED);
+		}
+		//缁樺埗鏂囨湰鑳屾櫙
+		//rectangle(image, backgroundRect, bgColor, FILLED);
+
+		//CvxText chinese(ttfFont);
+		//璁剧疆瀛椾綋鐨勫ぇ灏� / 绌虹櫧姣斾緥 / 闂撮殧姣旇緝 / 鏃嬭浆瑙掑害
+		//Scalar size(30, 0.5, 0, 0);
+		Scalar size(25, 0, 0.1, 0);
+		float p = 1.0f; //璁剧疆瀛椾綋鐨勯�忔槑搴�
+		//璁剧疆瀛椾綋
+		chinese.setFont(nullptr, &size, nullptr, &p);
+
+		switch (txalign)
+		{
+		case 1://鏂囧瓧宸﹀榻�	
+			//缁樺埗鏂囨湰
+			//chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5, (orgxy.y - (orgwh.y / 2) - 2)), textColor);
+			chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5, orgxy.y - 8), textColor);
+			break;
+		case 2://鏂囧瓧灞呬腑
+			//缁樺埗鏂囨湰
+			chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5 + (orgwh.x - textSize.width) / 2, (orgxy.y - 2)), textColor);
+
+			break;
+		case 3://鏂囧瓧鍙冲榻�
+			//缁樺埗鏂囨湰
+			chinese.putText(image, text.c_str(), cv::Point(orgxy.x + 5 + (orgwh.x - textSize.width), (orgxy.y - 2)), textColor);
+
+			break;
+		default://榛樿涓嶆敮鎸佷腑鏂�
+			//缁樺埗鏂囨湰
+			putText(image, _text.c_str(), cv::Point(orgxy.x + (orgwh.x - textSize.width) / 2, (orgxy.y - (orgwh.y / 2) - 2)), fontFace, 1, textColor, 2);
+			break;
+		}
+	}
+	catch (const std::exception& ex)
+	{
+		std::string errorMessage = "drawTextWithBackground-";
+		errorMessage += ex.what();
+		cout << errorMessage << endl;
+		throw std::runtime_error(errorMessage);
+	}
+
+}
 //鐨甫杩愯鐘舵�佹娴� modelId = 1
 double PreProcessModel::fnBeltMoveRec(Mat& imMat, std::vector<cv::Mat>& imagesBelt, int& beltCount, RUN& rBelt, std::vector<cv::Point> vertices)
 {
@@ -130,7 +253,7 @@
 		//瀹氫箟鎺ュ彈甯�
 		cv::Mat frame = imMat;
 		// 鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡  
-		rectangle(frame, cv::Point(vertices[0].x, vertices[0].y), cv::Point(vertices[1].x, vertices[1].y), cv::Scalar(255, 255, 0), 2);
+		rectangle(frame, cv::Point(vertices[0].x, vertices[0].y), cv::Point(vertices[1].x, vertices[1].y), cv::Scalar(255, 255, 0), 1);
 
 		if (imagesBelt.size() >= 3)//闀垮害澶т簬3鑷姩鍘绘帀澶撮儴甯�
 		{
@@ -281,7 +404,7 @@
 		//std::vector<cv::Point> vertices = stringToPoints(area);
 
 		// 缁樺埗澶氳竟褰�
-		cv::polylines(frame, vertices, true, cv::Scalar(0, 0, 255), 2);
+		cv::polylines(frame, vertices, true, cv::Scalar(0, 0, 255), 1);
 
 		// 瀹氫箟瑕佹祴璇曠殑鐐�
 		cv::Point testPoint;
@@ -322,14 +445,14 @@
 				}
 
 				//鏍囨敞浜哄舰
-				drawTextWithBackground(frame, titleperson, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+				drawTextWithBackgroundWstr(frame, titleperson, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 				//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
 
 				break;
 			//case 1:
 			//	//鏍囨敞甯藉瓙
-			//	drawTextWithBackground(frame, "瀹夊叏甯�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+			//	drawTextWithBackgroundWstr(frame, "瀹夊叏甯�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 			//	//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 			//	rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 
@@ -350,7 +473,7 @@
 				//wearHat++;//鏈僵鎴村畨鍏ㄥ附鐨勪汉鐨勬暟閲�
 
 				//鏍囨敞澶撮儴
-				drawTextWithBackground(frame, "澶�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+				drawTextWithBackgroundWstr(frame, "澶�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 
 				break;
@@ -361,7 +484,152 @@
 		
 		if (workpersons <= 0 && workvertices.size() > 0)
 		{
-			drawTextWithBackground(frame,"绂� 宀�", 2, cv::Point(workvertices[0].x, workvertices[0].y), cv::Point(workvertices[1].x - workvertices[0].x, workvertices[1].y - workvertices[0].y), Scalar(255, 255, 0));
+			drawTextWithBackgroundWstr(frame,"绂� 宀�", 2, cv::Point(workvertices[0].x, workvertices[0].y), cv::Point(workvertices[1].x - workvertices[0].x, workvertices[1].y - workvertices[0].y), Scalar(255, 255, 0));
+
+			// 缁樺埗澶氳竟褰紝宸ヤ綔鍖哄煙
+			cv::polylines(frame, workvertices, true, cv::Scalar(255, 255, 0), 2);
+		}		
+
+		frame.release();
+
+		result.push_back(distance);//鏈変汉杩涘叆鍗遍櫓鍖哄煙
+		result.push_back(wearHat);//鏈甫瀹夊叏甯戒汉鍛樻暟閲�
+		result.push_back(workpersons);//宸ヤ綔鍖哄煙浜哄憳鏁伴噺
+
+		return result;
+	}
+	catch (const std::exception& ex)
+	{
+		std::string errorMessage = "fnImRecProByModelHAT-";
+		errorMessage += ex.what();
+		cout << errorMessage << endl;
+		throw std::runtime_error(errorMessage);
+	}
+}
+vector<double> PreProcessModel::fnImRecProByModelHAT1(Mat& imMat, HAT& hat, std::vector<cv::Point> vertices, std::vector<cv::Point> workvertices,std::vector<std::vector<int>> c_list,std::string lable_title,std::string color_result)
+{
+	try
+	{
+		vector<double> result;
+		string titleperson = "浜� 鍛�";
+
+		double distance = -1;//0:鍗遍櫓鍖哄煙杈圭晫绾夸笂 >1:鍗遍櫓鍖哄煙鍐� <1:鍗遍櫓鍖哄煙澶�
+		double workdistance = -1;//0:宸ヤ綔鍖哄煙杈圭晫绾夸笂 >1:宸ヤ綔鍖哄煙鍐� <1:宸ヤ綔鍖哄煙澶�
+		double workpersons = 0;//宸ヤ綔鍖哄煙浜虹殑鏁伴噺
+		double wearHat = 0;//0:鍏ㄩ儴浣╂埓瀹夊叏甯� 1锛氭湭浣╂埓瀹夊叏甯界殑浜虹殑鏁伴噺
+
+		//瀹氫箟鎺ュ彈甯�
+		cv::Mat frame = imMat;
+
+		//鑾峰彇瑙嗛甯х殑瀹藉害鍜岄珮搴﹀拰甯х巼
+		int frame_width = frame.cols;
+		int frame_height = frame.rows;
+		double frameRate = 25;
+
+		// 鍒涘缓涓�涓┖鐨勮竟鐣屾鍚戦噺
+		std::vector<Box> boxes;
+		// 璋冪敤 detect 鍑芥暟鑾峰彇妫�娴嬪埌鐨勮竟鐣屾
+		hat.detect(frame, boxes);
+
+		//澶氳竟褰㈠尯鍩�
+		//std::vector<cv::Point> vertices = stringToPoints(area);
+		// 缁樺埗澶氳竟褰�
+		cv::polylines(frame, vertices, true, cv::Scalar(0, 0, 255), 1);
+		drawTextWithBackgroundWstr(frame, lable_title, 1, cv::Point(vertices[0].x, vertices[0].y), cv::Point(150, 40), Scalar(c_list[0][0], c_list[0][1], c_list[0][2]));
+
+		// 瀹氫箟瑕佹祴璇曠殑鐐�
+		cv::Point testPoint;
+		cv::Scalar sl;//鏍囨棰滆壊
+
+		// 浣跨敤绱㈠紩閬嶅巻boxes
+		for (int i = 0; i < boxes.size(); i++) {
+			
+			switch (boxes[i].class_id)
+			{
+			case 0:
+				//濡傛灉鏍囨敞浜嗗嵄闄╁尯鍩�
+				if (vertices.size()>0)
+				{
+					distance = cv::pointPolygonTest(vertices, testPoint, false);//鍗遍櫓鍖哄煙鍒ゆ柇
+					if (distance > 0)//鍗遍櫓鍖哄煙鍐呮湁涓汉,鐢荤孩鑹�
+					{
+						if(color_result == "false")
+						{
+							sl = Scalar(255, 0, 0);
+						}
+						else
+						{
+							sl = Scalar(0, 0, 255);
+						}
+						titleperson = "闂� 鍏�";
+					}
+					else
+					{
+						if(color_result == "false")
+						{
+							sl = Scalar(255, 0, 0);
+						}
+						else
+						{
+							sl = Scalar(0, 0, 255);
+						}
+						titleperson = "浜� 鍛�";
+					}
+				}			
+
+				//濡傛灉鏍囨敞浜嗗伐浣滃尯鍩�
+				if (workvertices.size()>0)
+				{
+					workdistance = cv::pointPolygonTest(workvertices, testPoint, false);//鑴卞矖绂诲矖鍒ゆ柇
+
+
+					if (workdistance >= 0)//宸ヤ綔鍖哄煙鍐呮湁涓汉
+					{
+						workpersons++;
+					}
+				}
+
+				//鏍囨敞浜哄舰
+				drawTextWithBackgroundWstr(frame, titleperson, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+				//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
+				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
+
+				break;
+			//case 1:
+			//	//鏍囨敞甯藉瓙
+			//	drawTextWithBackgroundWstr(frame, "瀹夊叏甯�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+			//	//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
+			//	rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
+
+			//	break;
+			case 2:
+
+				//濡傛灉鏍囨敞浜嗗伐浣滃尯鍩�
+				if (workvertices.size() > 0)
+				{
+					workdistance = cv::pointPolygonTest(workvertices, testPoint, false);//鑴卞矖绂诲矖鍒ゆ柇
+
+					if (workdistance >= 0)//宸ヤ綔鍖哄煙鍐呮湁涓汉
+					{
+						workpersons++;
+					}
+				}
+
+				//wearHat++;//鏈僵鎴村畨鍏ㄥ附鐨勪汉鐨勬暟閲�
+
+				//鏍囨敞澶撮儴
+				drawTextWithBackgroundWstr(frame, "澶�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
+
+				break;
+			default:
+				break;
+			}
+		}
+		
+		if (workpersons <= 0 && workvertices.size() > 0)
+		{
+			drawTextWithBackgroundWstr(frame,"绂� 宀�", 2, cv::Point(workvertices[0].x, workvertices[0].y), cv::Point(workvertices[1].x - workvertices[0].x, workvertices[1].y - workvertices[0].y), Scalar(255, 255, 0));
 
 			// 缁樺埗澶氳竟褰紝宸ヤ綔鍖哄煙
 			cv::polylines(frame, workvertices, true, cv::Scalar(255, 255, 0), 2);
@@ -453,7 +721,7 @@
 		frameout.copyTo(roi);
 
 		// 鐓ょ偔鍗犳瘮
-		drawTextWithBackground(frame, std::to_string(result), 0, cv::Point(vertices[0].x, vertices[0].y), cv::Point(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y), Scalar(255, 255, 0));
+		drawTextWithBackgroundWstr(frame, std::to_string(result), 0, cv::Point(vertices[0].x, vertices[0].y), cv::Point(vertices[1].x - vertices[0].x, vertices[1].y - vertices[0].y), Scalar(255, 255, 0));
 
 		// 鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡  
 		//rectangle(frame, cv::Point(vertices[0].x, vertices[0].y), cv::Point(vertices[2].x, vertices[3].y), cv::Scalar(255, 255, 0), 2);
@@ -519,7 +787,7 @@
 				if (cv::pointPolygonTest(vertices, testPoint, false) > 0)//鍖哄煙鍐呮湁涓汉,鐢荤孩鑹�
 				{
 					//鏍囨敞澶у獟鍧�
-					drawTextWithBackground(frame, "澶� 鐓� 鍧�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sPurple);
+					drawTextWithBackgroundWstr(frame, "澶� 鐓� 鍧�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sPurple);
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sPurple, 1);
 				}				
@@ -536,7 +804,7 @@
 				if (cv::pointPolygonTest(vertices, testPoint, false) > 0)//鍖哄煙鍐呮湁涓汉,鐢荤孩鑹�
 				{
 					//鏍囨敞寮傜墿
-					drawTextWithBackground(frame, "寮傜墿", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sRed);
+					drawTextWithBackgroundWstr(frame, "寮傜墿", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sRed);
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sRed, 1);
 				}
@@ -626,7 +894,7 @@
 				if (cv::pointPolygonTest(vertices, testPoint, false) > 0)//杩涘叆鍖哄煙鍚庡啀鐢绘
 				{
 					//鏍囨敞澶х叅鍧�
-					drawTextWithBackground(frame, "澶х叅鍧�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sPurple);
+					drawTextWithBackgroundWstr(frame, "澶х叅鍧�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sPurple);
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sPurple, 1);
 				}
@@ -636,7 +904,7 @@
 			case 1:
 				cv::rectangle(frame, cv::Point(boxes[i].x - boxes[i].width / 2, boxes[i].y - boxes[i].height / 2), cv::Point(boxes[i].x + boxes[i].width / 2, boxes[i].y + boxes[i].height / 2), roller_color2, 3);
 				//鏍囨敞鎵樿緤
-				drawTextWithBackground(frame, "鎵樿緤", 2, cv::Point(boxes[i].x - boxes[i].width / 2, boxes[i].y - boxes[i].height / 2), cv::Point(boxes[i].width, boxes[i].height), sPurple);
+				drawTextWithBackgroundWstr(frame, "鎵樿緤", 2, cv::Point(boxes[i].x - boxes[i].width / 2, boxes[i].y - boxes[i].height / 2), cv::Point(boxes[i].width, boxes[i].height), sPurple);
 				break;
 			case 2:
 			case 3:
@@ -649,7 +917,7 @@
 				if (cv::pointPolygonTest(vertices, testPoint, false) > 0)//鍖哄煙鍐�,鐢荤孩鑹�
 				{
 					//鏍囨敞寮傜墿
-					drawTextWithBackground(frame, "寮傜墿", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sRed);
+					drawTextWithBackgroundWstr(frame, "寮傜墿", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sRed);
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sRed, 1);
 				}
@@ -722,7 +990,7 @@
 				sl = Scalar(0, 0, 255);
 
 				//鏍囨敞浜哄舰
-				drawTextWithBackground(frame, "鎼� 甯� 澶� 浠�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+				drawTextWithBackgroundWstr(frame, "鎼� 甯� 澶� 浠�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 
 				//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
@@ -730,7 +998,7 @@
 				break;
 			//case 1:
 			//	//鏍囨敞甯藉瓙
-			//	drawTextWithBackground(frame, "瀹夊叏甯�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+			//	drawTextWithBackgroundWstr(frame, "瀹夊叏甯�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 			//	//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 			//	rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 
@@ -739,7 +1007,7 @@
 
 			//	wearHat++;//鏈僵鎴村畨鍏ㄥ附鐨勪汉鐨勬暟閲�
 			//	//鏍囨敞澶撮儴
-			//	drawTextWithBackground(frame, "澶�", 3, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+			//	drawTextWithBackgroundWstr(frame, "澶�", 3, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 			//	rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 
 			//	break;
@@ -794,7 +1062,7 @@
 			sl = Scalar(0, 0, 255);
 
 			//鏍囨敞浜哄舰
-			drawTextWithBackground(frame, "鐫� 宀�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+			drawTextWithBackgroundWstr(frame, "鐫� 宀�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 
 			//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 			rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
@@ -872,7 +1140,7 @@
 					checkpersons = 1;
 
 					//鏍囨敞浜哄舰
-					drawTextWithBackground(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+					drawTextWithBackgroundWstr(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
 
@@ -903,7 +1171,7 @@
 					reshat = 1;
 
 					//鏍囨敞甯藉瓙
-					drawTextWithBackground(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+					drawTextWithBackgroundWstr(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 					//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 				}
@@ -912,7 +1180,7 @@
 			//case 2://澶撮儴				
 
 			//	//鏍囨敞澶撮儴
-			//	drawTextWithBackground(frame, "澶�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+			//	drawTextWithBackgroundWstr(frame, "澶�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 			//	rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 
 			//	break;
@@ -924,7 +1192,7 @@
 					respager = 1;
 
 					//鏍囨敞鑷晳鍣�
-					drawTextWithBackground(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+					drawTextWithBackgroundWstr(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 				}
 				
@@ -937,7 +1205,7 @@
 					resshoes = 1;
 
 					//鏍囨敞闉�
-					drawTextWithBackground(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
+					drawTextWithBackgroundWstr(frame, title, 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), cv::Scalar(0, 255, 0));
 					rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), cv::Scalar(0, 255, 0), 1);
 				}
 
@@ -1023,7 +1291,7 @@
 			case 0:
 				fire++;
 				//鏍囨敞鐏�
-				drawTextWithBackground(frame, "鐏�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+				drawTextWithBackgroundWstr(frame, "鐏�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 
 				//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);
@@ -1031,7 +1299,7 @@
 			case 1:
 				smoke++;
 				//鏍囨敞鐑�
-				drawTextWithBackground(frame, "鐑�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
+				drawTextWithBackgroundWstr(frame, "鐑�", 2, cv::Point(boxes[i].x, boxes[i].y), cv::Point(boxes[i].width, boxes[i].height), sl);
 
 				//鍦ㄨ棰戝抚涓婃坊鍔犵煩褰㈡ 
 				rectangle(frame, cv::Point(boxes[i].x, boxes[i].y), cv::Point((boxes[i].x + boxes[i].width), (boxes[i].y + boxes[i].height)), sl, 1);

--
Gitblit v1.8.0