Commit 8bc6a15c LN

皮带线料盘检测优化

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