From a68073a77792dc96cecbfb79693d531bc51ebbac Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 08 八月 2025 18:01:35 +0800
Subject: [PATCH] 1. 修复保存图片分配率问题 2. 修复获取相机配置的问题 3. 添加侧面检的视觉模块

---
 EdgeInspector_App/InterfaceManager.cpp |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/EdgeInspector_App/InterfaceManager.cpp b/EdgeInspector_App/InterfaceManager.cpp
index e06011b..92fd985 100644
--- a/EdgeInspector_App/InterfaceManager.cpp
+++ b/EdgeInspector_App/InterfaceManager.cpp
@@ -1,4 +1,4 @@
-#include "StdAfx.h"
+锘�#include "StdAfx.h"
 #include "InterfaceManager.h"
 #include "MulticamControl.h"
 #include "RadientControl.h"
@@ -150,7 +150,7 @@
 	return 0;
 }
 
-// End Signal阑 PLC俊辑 肋 给罐酒辑 Retry 持菌澜
+// End Signal闃� PLC淇婅緫 鑲� 缁欑綈閰掕緫 Retry 鎸佽弻婢�
 void CInterfaceManager::PLCSignalRetry(SEND_MESSAGE_SECTION emSection,InspectToControlSignal emSendSignal,enInterface_Send_Control emControlSignal)
 {
 	if(m_HardwareRecipe.m_nPLCSignalRetry <= 0)
@@ -505,7 +505,7 @@
 	m_PostProcess.SetView((void*) m_pView);
 	m_PostProcess.RunPostProcessing();
 
-	// 馆靛矫 Scan End 脚龋 焊郴扁 傈俊 秦拎具茄促... Scan End 脚龋 焊尘锭 Loading捞 肯丰 救登搁 救焊郴瘤霸 阜囚乐澜..
+	// 棣嗛潧鐭� Scan End 鑴氶緥 鐒婇兇鎵� 鍌堜繆 绉︽嫀鍏疯寗淇�... Scan End 鑴氶緥 鐒婂皹閿� Loading鎹� 鑲赴 鏁戠櫥鎼� 鏁戠剨閮寸槫闇� 闃滃洑涔愭緶..
 	m_bGlassLoadingEnd = FALSE;
 	m_bPLCGlassLoading = FALSE;
 
@@ -1213,7 +1213,7 @@
 	if(!m_strReserveRecipe.IsEmpty())
 	{
 		g_pLog->DisplayMessage(_T("Apply reserve Recipe Loading - [%s]"), m_strReserveRecipe);		
-		if (LoadGlassRecipe(m_strReserveRecipe,TRUE))	// 鞍篮 Recipe扼档 利侩 抗距登绢 乐栏搁 促矫 肺爹茄促.
+		if (LoadGlassRecipe(m_strReserveRecipe,TRUE))	// 闉嶇 Recipe鎵兼。 鍒╀京 鎶楄窛鐧荤虎 涔愭爮鎼� 淇冪煫 鑲虹埞鑼勪績.
 		{					
 			g_pLog->DisplayMessage(_T("Apply reserve Recipe Loading - [%s] : Success"), m_strReserveRecipe);
 		}
@@ -1227,7 +1227,7 @@
 		return FALSE;
 	}	
 
-	if (strRcp.CompareNoCase(m_GlassRecipe.GetRecipeName()) != 0)	// strRecipeName 官差搁 肺爹茄促.
+	if (strRcp.CompareNoCase(m_GlassRecipe.GetRecipeName()) != 0)	// strRecipeName 瀹樺樊鎼� 鑲虹埞鑼勪績.
 	{			
 		if (LoadGlassRecipe(strRcp,TRUE) == FALSE)			
 		{
@@ -1393,7 +1393,7 @@
 	BlVision_GetVisionRecipe()->setRecipeType(EI_VISION_RECIPE);
 	BlVision_GetVisionRecipe()->init();
 
-	for (int i = 0; i < nCount; i++) {        //设置分辨率
+	for (int i = 0; i < nCount; i++) {        //璁剧疆鍒嗚鲸鐜�
 		DimensionDir eDir = (DimensionDir)(i);
 		CBlSideData *pSide = BlVision_GetVisionRecipe()->getSideData(eDir);
 
@@ -1443,7 +1443,7 @@
 	g_pLog->DisplayMessage( _T("CreateCamera Start!"));	
 
 	//////////////////////////////////////////////////////////////////////////
-	// Camera Handle 积己.
+	// Camera Handle 绉繁.
 	int			iCam;		
 	BOOL		bRet = TRUE;
 
@@ -1540,7 +1540,7 @@
 		int nErrorCode;		
 		int nBoardId = iCam;
 
-		// B5 4龋扁 悸泼
+		// B5 4榫嬫墎 鎮告臣
 		g_pBase->m_strSBKLine = m_HardwareRecipe.GetLineID();
 		g_pBase->m_strSBKLine.Append(_T("#"));
 
@@ -1825,7 +1825,13 @@
 	strSavePath += _T(".jpg");
 
 	Lock();
-	FIBITMAP* bitmap = FreeImage_Allocate(IMAGE_WIDTH, nLineCnt, 8);
+	FIBITMAP* bitmap = nullptr;
+	int nImageWidth = IMAGE_WIDTH;
+	if (iSide > DIMENSION_D_DN) {
+		nImageWidth = IMAGE_WIDTH / 2;
+	}
+	bitmap = FreeImage_Allocate(nImageWidth, nLineCnt, 8);
+
 	if (bitmap == NULL) {
 		Unlock();
 		return FALSE;
@@ -1844,7 +1850,7 @@
 		return FALSE;
 	}
 
-	CopyMemory(pBitBuffer, lpImg, IMAGE_WIDTH * nLineCnt);
+	CopyMemory(pBitBuffer, lpImg, nImageWidth * nLineCnt);
 
 	USES_CONVERSION;
 	char str_filename[1024];
@@ -1855,6 +1861,8 @@
 	FreeImage_Unload(bitmap);
 
 	Unlock();
+
+	return TRUE;
 }
 
 BOOL CInterfaceManager::SaveFullImageModern(CString strPath,LPBYTE lpOrigin,int nImgWidth,int nImgHeight,int iSide,int nStartY,int nQuality /*= 80*/)
@@ -1909,15 +1917,15 @@
 	cvReleaseImageHeader(&pImg);
 #else
 	Lock();
-	// 原始图像数据转 cv::Mat
+	// 鍘熷鍥惧儚鏁版嵁杞� cv::Mat
 	cv::Mat origin(nImgHeight, nImgWidth, CV_8UC1, lpOrigin + (nImgWidth * nStartY));
 
-	// 缩放图像
+	// 缂╂斁鍥惧儚
 	cv::Size szNew(static_cast<int>(nImgWidth * dRatio), static_cast<int>(nImgHeight * dRatio));
 	cv::Mat resized;
 	cv::resize(origin, resized, szNew, 0, 0, cv::INTER_LINEAR);
 
-	// 设置 JPEG 压缩参数
+	// 璁剧疆 JPEG 鍘嬬缉鍙傛暟
 	std::vector<int> params = {
 		cv::IMWRITE_JPEG_QUALITY,
 		nQuality
@@ -2029,7 +2037,7 @@
 		strPath.Append(_T("_NG"));
 	}
 #else
-	// 加载灰度图像
+	// 鍔犺浇鐏板害鍥惧儚
 	std::string strFilename = CT2A(strPath);
 	cv::Mat img = cv::imread(strFilename, cv::IMREAD_GRAYSCALE);
 
@@ -2057,7 +2065,7 @@
 			nHeight = img.rows;
 		}
 		else {
-			// 按比例缩放
+			// 鎸夋瘮渚嬬缉鏀�
 			const double dRatio = 1.0 - static_cast<double>(IMAGE_COMPRESSRATIO) / 100.0;
 			int newWidth = static_cast<int>(img.cols / dRatio);
 			int newHeight = static_cast<int>(img.rows / dRatio);

--
Gitblit v1.9.3