Commit 8bc6a15c LN

皮带线料盘检测优化

1 个父辈 4e503307
...@@ -495,10 +495,11 @@ namespace OnlineStore.AssemblyLine ...@@ -495,10 +495,11 @@ namespace OnlineStore.AssemblyLine
{ {
return; return;
} }
int[] result = ReelCheckUtil.ReelCheck(cameraName); string imgName = "";
int[] result = ReelCheckUtil.ReelCheck(cameraName,out imgName);
if (result != null && result.Length == 2) if (result != null && result.Length == 2)
{ {
MessageBox.Show("相机[" + cameraName + "]检测料盘结果:[" + result[0] + "][" + result[1] + "]",text+"结果",MessageBoxButtons.OK,MessageBoxIcon.Information); MessageBox.Show("相机[" + cameraName + "]检测料盘结果:[" + result[0] + "][" + result[1] + "],图片:"+imgName,text+"结果",MessageBoxButtons.OK,MessageBoxIcon.Information);
} }
else else
{ {
......
...@@ -332,10 +332,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -332,10 +332,11 @@ namespace OnlineStore.DeviceLibrary
{ {
bool exitHasTray = false; bool exitHasTray = false;
bool line3HasTray = false; bool line3HasTray = false;
string imgName = "";
//如果有监控相机 //如果有监控相机
if (!cameraName.Equals("")) if (!cameraName.Equals(""))
{ {
int[] results = ReelCheckUtil.ReelCheck(cameraName); int[] results = ReelCheckUtil.ReelCheck(cameraName,out imgName);
if (results != null && results.Length == 2) if (results != null && results.Length == 2)
{ {
exitHasTray = (results[0] == 1); exitHasTray = (results[0] == 1);
...@@ -367,6 +368,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -367,6 +368,10 @@ namespace OnlineStore.DeviceLibrary
{ {
Line3CanRun = false; Line3CanRun = false;
LogUtil.debug(Name + "出口有料,且" + Line3_TrayCheck + "=LOW,转动一个工位,[" + LineRun_Do + "] [" + ExitLocation_Check + "]"); LogUtil.debug(Name + "出口有料,且" + Line3_TrayCheck + "=LOW,转动一个工位,[" + LineRun_Do + "] [" + ExitLocation_Check + "]");
if (!cameraName.Equals(""))
{
LogUtil.info(Name + "出口有料,长皮带线无料,转动一个工位,"+ exitHasTray + ","+ line3HasTray + ",imgName= "+ imgName + "");
}
StartBrush(); StartBrush();
lineRun.StartLineRun(LineEndProcess); lineRun.StartLineRun(LineEndProcess);
} }
......
...@@ -71,8 +71,9 @@ dMinorStep 步进,默认1.0。 ...@@ -71,8 +71,9 @@ dMinorStep 步进,默认1.0。
///////////////////使用/////////////////// ///////////////////使用///////////////////
public static int[] ReelCheck(string cameraName ) public static int[] ReelCheck(string cameraName ,out string imgName)
{ {
imgName = "";
if (String.IsNullOrEmpty(cameraName)) if (String.IsNullOrEmpty(cameraName))
{ {
return null; return null;
...@@ -91,8 +92,6 @@ dMinorStep 步进,默认1.0。 ...@@ -91,8 +92,6 @@ dMinorStep 步进,默认1.0。
LogUtil.error("ReelCheckUtil :ReelCheck [" + cameraName + "] 获取图片失败 "); LogUtil.error("ReelCheckUtil :ReelCheck [" + cameraName + "] 获取图片失败 ");
return null; return null;
} }
string date = cameraName.Trim().Replace('_', '-') + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + DateTime.Now.Millisecond;
string imageName = date + ".bmp";
//if (SaveImage) //if (SaveImage)
//{ //{
// string path = "D:\\image\\"+ cameraName + "\\SourceImg\\"; // string path = "D:\\image\\"+ cameraName + "\\SourceImg\\";
...@@ -116,10 +115,14 @@ dMinorStep 步进,默认1.0。 ...@@ -116,10 +115,14 @@ dMinorStep 步进,默认1.0。
//添加需要监控的位置信息 //添加需要监控的位置信息
List<EyemRect> tpRois = new List<EyemRect>(); List<EyemRect> tpRois = new List<EyemRect>();
//EyemRect roi1 = new EyemRect();
//roi1.iXs = 533; roi1.iYs = 187; roi1.iWidth = 345; roi1.iHeight = 310;
//EyemRect roi2 = new EyemRect();
//roi2.iXs = 900; roi2.iYs = 137; roi2.iWidth = 240; roi2.iHeight = 197;
EyemRect roi1 = new EyemRect(); EyemRect roi1 = new EyemRect();
roi1.iXs = 533; roi1.iYs = 187; roi1.iWidth = 345; roi1.iHeight = 310; roi1.iXs = 470; roi1.iYs = 143; roi1.iWidth = 411; roi1.iHeight = 387;
EyemRect roi2 = new EyemRect(); EyemRect roi2 = new EyemRect();
roi2.iXs = 900; roi2.iYs = 137; roi2.iWidth = 240; roi2.iHeight = 197; roi2.iXs = 882; roi2.iYs = 84; roi2.iWidth = 317; roi2.iHeight = 251;
tpRois.Add(roi1); tpRois.Add(roi2); tpRois.Add(roi1); tpRois.Add(roi2);
...@@ -134,46 +137,27 @@ dMinorStep 步进,默认1.0。 ...@@ -134,46 +137,27 @@ dMinorStep 步进,默认1.0。
int[] ipResults = new int[tpRois.Count]; int[] ipResults = new int[tpRois.Count];
eyemTrackFeature(image, mask, tpRoi, hGlobal, ipResults.Length, tpHsvModel, ipResults, out EyemImage tpDstImg); eyemTrackFeature(image, mask, tpRoi, hGlobal, ipResults.Length, tpHsvModel, ipResults, out EyemImage tpDstImg);
string resultStr = "";
for (int i = 0; i < ipResults.Length; i++) for (int i = 0; i < ipResults.Length; i++)
{ {
if (ipResults[i] == 1) if (ipResults[i] == 1)
{ {
Console.WriteLine("检测到{0}位置有料盘", i); Console.WriteLine("检测到{0}位置有料盘", i);
} }
resultStr += ipResults[i];
} }
Bitmap dstBitmap = eyemCvtToBitmap(tpDstImg); Bitmap dstBitmap = eyemCvtToBitmap(tpDstImg);
if (dstBitmap != null && SaveImage) if (dstBitmap != null && SaveImage)
{ {
//两个工位只有一个料盘时才保存图片 string date = cameraName.Trim().Replace('_', '-') + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + DateTime.Now.Millisecond;
//bool save = false; string imageName = date + "-" + resultStr + ".bmp";
//if (ipResults != null && ipResults.Length == 2) imgName = imageName;
//{
// if ((ipResults[0] == 0) || (ipResults[0] == 1))
// {
// save = true;
// }
// else if ((ipResults[0] == 1) || (ipResults[0] == 0))
// {
// save = true;
// }
//}
//else
//{
// save = true;
//}
//if (save)
//{
string path = "D:\\image\\" + cameraName + "\\ResOut\\"; string path = "D:\\image\\" + cameraName + "\\ResOut\\";
//if (!Directory.Exists(path))
//{
// Directory.CreateDirectory(path);
//}
if (canSavePic(path)) if (canSavePic(path))
{ {
dstBitmap.Save(path + imageName, ImageFormat.Jpeg); dstBitmap.Save(path + imageName, ImageFormat.Jpeg);
} }
//}
} }
//释放资源 //释放资源
Marshal.FreeHGlobal(hGlobal); Marshal.FreeHGlobal(hGlobal);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!