Commit bd392c11 张东亮

存储机构-料格水平检测逻辑添加,未启用。关闭到中间待机点拍照动作

1 个父辈 adbbc66c
文件属性发生变化
文件属性发生变化
文件属性发生变化
......@@ -506,6 +506,37 @@ namespace OnlineStore.DeviceLibrary
/// 存储机构自动对位:到下一个抽屉(反向)
/// </summary>
SA_10_Neg_NextDrawer,
#region 存储机构-料格水平检测
/// <summary>
/// 料格水平检测:预检查,检查是否是首尾列(目前忽略)
/// </summary>
SCH_00_PreCheck,
/// <summary>
/// 料格水平检测:回退一段距离
/// </summary>
SCH_01_BackDistance,
/// <summary>
/// 料格水平检测:取像
/// </summary>
SCH_02_AcqImage,
/// <summary>
/// 料格水平检测:检查X轴位置
/// </summary>
SCH_03_CheckXCoord,
/// <summary>
/// 料格水平检测:调整X轴位置
/// </summary>
SCH_04_AdjXPos,
/// <summary>
/// 料格水平检测:X轴到位,确认Y轴是否超过限制
/// </summary>
SCH_05_CheckYDiff,
/// <summary>
/// 料格水平检测:检查结束
/// </summary>
SCH_06_Finish,
#endregion
#endregion
#region 存储机构库位调试 500开始
......
using CodeLibrary;
using eyemLib_Sharp;
using HuichuanLibrary;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
......@@ -178,13 +179,13 @@ namespace OnlineStore.DeviceLibrary
{
if (Math.Abs(GetDrawerX() - eyemOcsFXYR.fX) < GetError_X())
{
LogInfo($"视觉对位 {MoveInfo.SLog}:Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)},在误差范围内" +
LogInfo($" {MoveInfo.SLog}:Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)},在误差范围内" +
$"[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
AutoFindPosSaveImage($"OK_Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)}");
return true;
}
AutoFindPosSaveImage($"NG_Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)}");
LogInfo($"视觉对位 {MoveInfo.SLog}:Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)}," +
LogInfo($" {MoveInfo.SLog}:Mark点X轴坐标{eyemOcsFXYR.fX},模板Mark点X轴坐标{GetDrawerX()},X轴偏差{(GetDrawerX() - eyemOcsFXYR.fX)}," +
$"行走机构相对移动{(GetDrawerX() - eyemOcsFXYR.fX) * autoFindPos.XCoeffOfCoorToPulse}[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
MoveAxis.AbsMove(MoveInfo, Convert.ToInt32(MoveAxis.GetAclPosition() + (GetDrawerX() - eyemOcsFXYR.fX) * autoFindPos.XCoeffOfCoorToPulse), Config.MoveAxis_FindPosSpeed / 10);
return false;
......@@ -195,6 +196,7 @@ namespace OnlineStore.DeviceLibrary
{
LogInfo($"视觉对位 {MoveInfo.SLog}:Mark点Y轴坐标{eyemOcsFXYR.fY},模板Mark点Y轴坐标{GetDrawerY()},Y轴偏差{(GetDrawerY() - eyemOcsFXYR.fY)},在误差范围内" +
$"[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
autoFindPos.MarkYCoor = eyemOcsFXYR.fY;
AutoFindPosSaveImage($"OK_Mark点Y轴坐标{eyemOcsFXYR.fY},模板Mark点Y轴坐标{GetDrawerY()},Y轴偏差{(GetDrawerY() - eyemOcsFXYR.fY)}");
return true;
}
......@@ -256,7 +258,7 @@ namespace OnlineStore.DeviceLibrary
string nameStr = DeviceID.ToString();
positionConfigFile = positionConfigFile.Replace(".csv", "_" + nameStr + ".csv");
}
bool result = CSVPositionReader<BoxPosition>.SavePostion(positionConfigFile, ktkPosition,false);
bool result = CSVPositionReader<BoxPosition>.SavePostion(positionConfigFile, ktkPosition, false);
if (!result)
{
SetWarnMsg("库位【" + item + "】保存失败!");
......@@ -279,7 +281,7 @@ namespace OnlineStore.DeviceLibrary
}
return false;
}
Bitmap bitmap=null;
Bitmap bitmap = null;
public void FindPosEnd()
{
MoveInfo.EndMove();
......@@ -293,6 +295,38 @@ namespace OnlineStore.DeviceLibrary
if (autoFindPos.FailedDrawers.Count > 0)
autoFindPos.FailedDrawers.Clear();
}
/// <summary>
/// 当前是否是第一或者最后一列
/// </summary>
/// <returns>true:是最后一列</returns>
public bool IsFirstOrLastColum()
{
if (autoFindPos.CurColumn.Equals(1) || autoFindPos.CurColumn.Equals(Config.Drawer_Columns))
return true;
return false;
}
/// <summary>
/// 回退一段距离
/// </summary>
private void BackDistance()
{
autoFindPos.Startposition_MoveAxis = MoveAxis.GetAclPosition() + (-autoFindPos.CurColumn + autoFindPos.PreColumn) * autoFindPos.Row_Spacing / 2;
int moveAxis;
if (autoFindPos.Startposition_MoveAxis >= Config.MoveAxis_PosLimit)
{
moveAxis = Config.MoveAxis_PosLimit;
}
else if (autoFindPos.Startposition_MoveAxis <= Config.MoveAxis_NegLimit)
{
moveAxis = Config.MoveAxis_NegLimit;
}
else
moveAxis = autoFindPos.Startposition_MoveAxis;
LogUtil.info($"料格水平检查 运行到抽屉 行走机构回退{autoFindPos.Startposition_MoveAxis}");
MoveAxis.AbsMove(MoveInfo, moveAxis, Config.MoveAxis_FindPosSpeed);
}
EyemOcsFXYR ocsFXYR;
public void AutoFindPosProcess()
{
......@@ -345,6 +379,7 @@ namespace OnlineStore.DeviceLibrary
case StepEnum.SA_03_Pos_GetMark:
if (CheckMarkXPoint(ocsFXYR) && CheckMarkYPoint(ocsFXYR))
{
autoFindPos.IsPositiveDir = true;
MoveInfo.NextMoveStep(StepEnum.SA_05_Pos_NextDrawer);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//存储抽屉位置信息
......@@ -426,6 +461,7 @@ namespace OnlineStore.DeviceLibrary
case StepEnum.SA_08_Neg_GetMark:
if (CheckMarkXPoint(ocsFXYR) && CheckMarkYPoint(ocsFXYR))
{
autoFindPos.IsPositiveDir = false;
MoveInfo.NextMoveStep(StepEnum.SA_10_Neg_NextDrawer);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
//存储抽屉位置信息
......@@ -469,12 +505,94 @@ namespace OnlineStore.DeviceLibrary
}
}
break;
//料格水平检查
case StepEnum.SCH_00_PreCheck:
if (IsFirstOrLastColum())
{
MoveInfo.NextMoveStep(StepEnum.SCH_06_Finish);
LogInfo($"料格水平检查 {MoveInfo.SLog}:当前为第{autoFindPos.CurColumn}列,忽略");
}
else
{
MoveInfo.NextMoveStep(StepEnum.SCH_01_BackDistance);
LogInfo($"料格水平检查 {MoveInfo.SLog}:当前为第{autoFindPos.CurRow}行,第{autoFindPos.CurColumn}列,开始回退");
BackDistance();
}
break;
case StepEnum.SCH_01_BackDistance:
MoveInfo.NextMoveStep(StepEnum.SCH_02_AcqImage);
bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
LogInfo($"料格水平检查 {MoveInfo.SLog}:取图,行={autoFindPos.CurRow},列={autoFindPos.CurColumn}[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
break;
case StepEnum.SCH_02_AcqImage:
int res2 = AutoFindPos.GetMarkInfo(bitmap, $"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0, 4)}", $"row{autoFindPos.CurRow}_col{autoFindPos.CurColumn}", out ocsFXYR, SelectColor.Green);
if (res2 == 0)
{
MoveInfo.NextMoveStep(StepEnum.SCH_03_CheckXCoord);
LogInfo($"料格水平检查 {MoveInfo.SLog}:获取Mark成功[ret={res2}],行={autoFindPos.CurRow},列={autoFindPos.CurColumn}[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
}
else
{
MoveInfo.NextMoveStep(StepEnum.SCH_06_Finish);
SetWarnMsg($"料格水平检查异常[code={res2}],未找到Mark点。对位失败的行={autoFindPos.CurRow}[{MoveAxis.GetAclPosition()}],列={autoFindPos.CurColumn}[{UpdownAxis.GetAclPosition()}]");
autoFindPos.FailedDrawers.Add($"{autoFindPos.CurRow},{autoFindPos.CurColumn}");
}
break;
case StepEnum.SCH_03_CheckXCoord:
if (CheckMarkXPoint(ocsFXYR))
{
MoveInfo.NextMoveStep(StepEnum.SCH_05_CheckYDiff);
}
else
{
MoveInfo.NextMoveStep(StepEnum.SCH_04_AdjXPos);
}
break;
case StepEnum.SCH_04_AdjXPos:
MoveInfo.NextMoveStep(StepEnum.SCH_01_BackDistance);
LogInfo($"料格水平检查 {MoveInfo.SLog}:当前为第{autoFindPos.CurRow}行,第{autoFindPos.CurColumn}列,准备重新取图");
break;
case StepEnum.SCH_05_CheckYDiff:
MoveInfo.NextMoveStep(StepEnum.SCH_06_Finish);
if (Math.Abs(GetDrawerY() - ocsFXYR.fY) < GetError_Y())
{
LogInfo($"料格水平检查 {MoveInfo.SLog}:第{autoFindPos.CurRow}行,第{autoFindPos.CurColumn}列OK");
}
else
{
SetWarnMsg($"料格水平检查 {MoveInfo.SLog}:第{autoFindPos.CurRow}行,第{autoFindPos.CurColumn}列NG:模板Mark点Y坐标={GetDrawerY()}," +
$"检测到的Mark点坐标={ocsFXYR.fY},相差{Math.Abs(GetDrawerY() - ocsFXYR.fY)}像素");
autoFindPos.FailedDrawers.Add($"{autoFindPos.CurRow},{autoFindPos.CurColumn}");
}
break;
case StepEnum.SCH_06_Finish:
if (autoFindPos.IsPositiveDir)
{
MoveInfo.NextMoveStep(StepEnum.SA_05_Pos_NextDrawer);
}
else
{
MoveInfo.NextMoveStep(StepEnum.SA_10_Neg_NextDrawer);
}
LogInfo($"料格水平检查 {MoveInfo.SLog}:检查结束,进行下一个抽屉");
break;
}
}
}
public class AutoFindPos
{
/// <summary>
/// 运行方向是否是正向
/// </summary>
public bool IsPositiveDir { get; set; } = true;
public int Startposition_MoveAxis { get; set; }
public int Startposition_UpDownAxis { get; set; }
public int Startposition_PullUpdpwnAxis { get; set; }
......@@ -528,6 +646,10 @@ namespace OnlineStore.DeviceLibrary
public int UpdownAxis_Diff_Upper_Low { get; set; }
public int RowsInDraw { get; set; }
public int ColumnsInDraw { get; set; }
/// <summary>
/// 红色Mark点的Y坐标
/// </summary>
public float MarkYCoor { get; set; }
public List<string> FailedDrawers { get; set; }
BoxEquip_Config boxEquip_Config;
public AutoFindPos(BoxEquip_Config boxEquip_Config)
......@@ -558,13 +680,30 @@ namespace OnlineStore.DeviceLibrary
/// <param name="bitmap">输入图片</param>
/// <param name="markCoor">mark点坐标信息</param>
/// <returns>0 正常 -4未定位到 </returns>
public static int GetMarkInfo(Bitmap bitmap, string subpath, string filename, out EyemOcsFXYR markCoor, out Bitmap resBitmap)
public static int GetMarkInfo(Bitmap bitmap, string subpath, string filename, out EyemOcsFXYR markCoor, out Bitmap resBitmap, SelectColor color = SelectColor.Red)
{
int flag;
markCoor = new EyemOcsFXYR();
EyemImage tpDstImg;
EyemImage image = eyemCvtToEyemImage(bitmap);
flag = eyemMarkerTracing(image, 120, ref markCoor, out tpDstImg);
EyemHSVModel tpHsvModel = new EyemHSVModel();
switch (color)
{
case SelectColor.Red:
tpHsvModel.dpRangeL = new double[] { 0, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 10, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 156, 43, 46 }; tpHsvModel.dpRangeUExt = new double[] { 180, 255, 255 };
break;
case SelectColor.Blue:
tpHsvModel.dpRangeL = new double[] { 100, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 124, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
case SelectColor.Green:
tpHsvModel.dpRangeL = new double[] { 35, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 77, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
}
flag = eyemMarkerTracing(image, tpHsvModel, ref markCoor, out tpDstImg);
string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ImagePath) + subpath + "\\" + DateTime.Now.ToString("yyyyMMdd");
string path1 = path + "\\" + "Src\\";
string path2 = path + "\\" + "ResOut\\";
......@@ -584,7 +723,52 @@ namespace OnlineStore.DeviceLibrary
eyemImageFree(ref tpDstImg);
return flag;
}
public static int GetMarkInfo(Bitmap bitmap, string subpath, string filename, out EyemOcsFXYR markCoor)
public static int GetMarkInfo(EyemImage image, string subpath, string filename, out EyemOcsFXYR markCoor, out Bitmap resBitmap, SelectColor color = SelectColor.Red)
{
int flag;
markCoor = new EyemOcsFXYR();
EyemImage tpDstImg;
EyemHSVModel tpHsvModel = new EyemHSVModel();
switch (color)
{
case SelectColor.Red:
tpHsvModel.dpRangeL = new double[] { 0, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 10, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 156, 43, 46 }; tpHsvModel.dpRangeUExt = new double[] { 180, 255, 255 };
break;
case SelectColor.Blue:
tpHsvModel.dpRangeL = new double[] { 100, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 124, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
case SelectColor.Green:
tpHsvModel.dpRangeL = new double[] { 35, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 77, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
}
flag = eyemMarkerTracing(image, tpHsvModel, ref markCoor, out tpDstImg);
string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ImagePath) + subpath + "\\" + DateTime.Now.ToString("yyyyMMdd");
string path1 = path + "\\" + "Src\\";
string path2 = path + "\\" + "ResOut\\";
string time = DateTime.Now.ToString("HHmmss");
if (!System.IO.Directory.Exists(path1))
Directory.CreateDirectory(path1);
if (!System.IO.Directory.Exists(path2))
Directory.CreateDirectory(path2);
Bitmap bitmap = eyemCvtToBitmap(image);
bitmap.Save(path1 + filename + $"_{flag}_{time}" + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
resBitmap = eyemCvtToBitmap(tpDstImg);
if (resBitmap != null)
{
resBitmap.Save(string.Format("{0}{1}_{2}_{3}_{4}_{5}_{6}.bmp", path2, filename, flag, time, markCoor.fX, markCoor.fY, markCoor.fR));
}
Marshal.FreeHGlobal(image.vpImage);
eyemImageFree(ref tpDstImg);
return flag;
}
public static int GetMarkInfo(Bitmap bitmap, string subpath, string filename, out EyemOcsFXYR markCoor, SelectColor color = SelectColor.Red)
{
int flag;
markCoor = new EyemOcsFXYR();
......@@ -592,7 +776,24 @@ namespace OnlineStore.DeviceLibrary
return -1;
EyemImage tpDstImg;
EyemImage image = eyemCvtToEyemImage(bitmap);
flag = eyemMarkerTracing(image, 120, ref markCoor, out tpDstImg);
EyemHSVModel tpHsvModel = new EyemHSVModel();
switch (color)
{
case SelectColor.Red:
tpHsvModel.dpRangeL = new double[] { 0, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 10, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 156, 43, 46 }; tpHsvModel.dpRangeUExt = new double[] { 180, 255, 255 };
break;
case SelectColor.Blue:
tpHsvModel.dpRangeL = new double[] { 100, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 124, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
case SelectColor.Green:
tpHsvModel.dpRangeL = new double[] { 35, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 77, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 0, 0, 0 }; tpHsvModel.dpRangeUExt = new double[] { 0, 0, 0 };
break;
}
flag = eyemMarkerTracing(image, tpHsvModel, ref markCoor, out tpDstImg);
string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ImagePath) + subpath + "\\" + DateTime.Now.ToString("yyyyMMdd");
string path1 = path + "\\" + "Src\\";
string path2 = path + "\\" + "ResOut\\";
......
......@@ -312,18 +312,20 @@ namespace OnlineStore.DeviceLibrary
PullAxis_UpdownToHighP3();
break;
case StepEnum.SI_16_LiftTray:
MoveInfo.NextMoveStep(StepEnum.SI_17_PushTray);
LogInfo($"入库 {MoveInfo.SLog}:推到抽屉待机点采集图片,料斗拉取进出轴到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P1();
//MoveInfo.NextMoveStep(StepEnum.SI_17_PushTray);
// LogInfo($"入库 {MoveInfo.SLog}:推到抽屉待机点采集图片,料斗拉取进出轴到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
//PullAxis_Inout_To_P1();
//MoveInfo.NextMoveStep(StepEnum.SI_18_PutTrayMiddle);
//LogInfo($"入库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
//PullAxis_Inout_To_P2_P4();
MoveInfo.NextMoveStep(StepEnum.SI_18_PutTrayMiddle);
LogInfo($"入库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P2_P4();
MiddleAxis_To_P2();
break;
case StepEnum.SI_17_PushTray:
MoveInfo.NextMoveStep(StepEnum.SI_18_PutTrayMiddle);
LogInfo($"入库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2/P4[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
LogInfo($"入库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2/P4,移栽旋转轴到水平点[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P2_P4();
MiddleAxis_To_P2();
SaveSpecifiedImage();
//Bitmap bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId));
//bool rtn = MatchAndSaveImg(bitmap, $"{DateTime.Now.ToString("HHmmss")}");
......
......@@ -108,17 +108,17 @@ namespace OnlineStore.DeviceLibrary
PullAxis_UpdownToHighP3();
break;
case StepEnum.SO_10_LiftTray:
MoveInfo.NextMoveStep(StepEnum.SO_11_PushTray);
LogInfo($"出库 {MoveInfo.SLog}:到进出轴待机点拍照,料斗拉取进出轴到料屉待机点P1,移栽旋转轴到取放料水平点P2,移栽X到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P1();
MiddleAxis_To_P2();
XAxis_To_P1();
//MoveInfo.NextMoveStep(StepEnum.SO_12_PutTrayMiddle);
//LogInfo($"出库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2/P4,移栽旋转轴到取放料水平点P2,移栽X到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
//PullAxis_Inout_To_P2_P4();
//MoveInfo.NextMoveStep(StepEnum.SO_11_PushTray);
//LogInfo($"出库 {MoveInfo.SLog}:到进出轴待机点拍照,料斗拉取进出轴到料屉待机点P1,移栽旋转轴到取放料水平点P2,移栽X到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
//PullAxis_Inout_To_P1();
//MiddleAxis_To_P2();
//XAxis_To_P1();
MoveInfo.NextMoveStep(StepEnum.SO_12_PutTrayMiddle);
LogInfo($"出库 {MoveInfo.SLog}:推到抽屉提取点,料斗拉取进出轴到料屉提取点P2/P4,移栽旋转轴到取放料水平点P2,移栽X到P1[{MoveInfo.MoveParam.PosInfo.GetPosSide()}面]");
PullAxis_Inout_To_P2_P4();
MiddleAxis_To_P2();
XAxis_To_P1();
break;
case StepEnum.SO_11_PushTray:
MoveInfo.NextMoveStep(StepEnum.SO_12_PutTrayMiddle);
......
......@@ -9,6 +9,15 @@ using System.Drawing.Imaging;
namespace eyemLib_Sharp
{
/// <summary>
/// mark点的颜色
/// </summary>
public enum SelectColor
{
Red,
Green,
Blue
}
public unsafe class EyemLibDemo
{
#region 枚举
......@@ -589,12 +598,30 @@ namespace eyemLib_Sharp
public IntPtr hType; // 码类型
public IntPtr hText; // 码内容
}
[StructLayout(LayoutKind.Sequential)]
public struct EyemHSVModel
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public double[] dpRangeL, dpRangeU; // 提取下限,提取上限[H S V]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
public double[] dpRangeLExt, dpRangeUExt; // 额外提取下限,额外提取上限(针对处于跨模型颜色的补充,比如红色)[H S V]
}
#endregion
#region 项目
//圆形mark点定位
/// <summary>
/// 圆形Mark点定位
/// </summary>
/// <param name="tpImage">图像</param>
/// <param name="tpHSVModel">HSV阈值范围</param>
/// <param name="tpCircle">结果</param>
/// <param name="tpDstImg">结果图</param>
/// <param name="bHighAccuracy">是否使用高精度</param>
/// <returns>0=FUNC_OK</returns>
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
public static extern int eyemMarkerTracing(EyemImage tpImage, double dThreshold, ref EyemOcsFXYR tpCircle,out EyemImage tpDstImg, bool bHighAccuracy = true);
// public static extern int eyemMarkerTracing(EyemImage tpImage, double dThreshold, ref EyemOcsFXYR tpCircle,out EyemImage tpDstImg, bool bHighAccuracy = true);
public static extern int eyemMarkerTracing(EyemImage tpImage, EyemHSVModel tpHSVModel, ref EyemOcsFXYR tpCircle, out EyemImage tpDstImg, bool bHighAccuracy = true);
#endregion
#region 通用
......@@ -604,7 +631,7 @@ namespace eyemLib_Sharp
private static extern byte* memcpy(byte* dst, byte* src, int count);
//读取图像,支持彩色与多深度
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemImageRead(string filename, int iFalgs, out EyemImage tpImage);
public static extern int eyemImageRead(string filename, int iFalgs, out EyemImage tpImage);
//释放图像资源
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
public static extern void eyemImageFree(ref EyemImage tpImage);
......@@ -626,7 +653,11 @@ namespace eyemLib_Sharp
}
EyemOcsFXYR tpCircle = new EyemOcsFXYR();
flag = eyemMarkerTracing(image, 120, ref tpCircle, out tpDstImg);
////红色分割
EyemHSVModel tpHsvModel = new EyemHSVModel();
tpHsvModel.dpRangeL = new double[] { 0, 43, 46 }; tpHsvModel.dpRangeU = new double[] { 10, 255, 255 };
tpHsvModel.dpRangeLExt = new double[] { 156, 43, 46 }; tpHsvModel.dpRangeUExt = new double[] { 180, 255, 255 };
flag = eyemMarkerTracing(image, tpHsvModel, ref tpCircle, out tpDstImg);
//0 正常 -4未定位到
Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
......
......@@ -369,54 +369,54 @@
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(114, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
//
// 启动AToolStripMenuItem
//
this.启动AToolStripMenuItem.Name = "启动AToolStripMenuItem";
this.启动AToolStripMenuItem.Size = new System.Drawing.Size(117, 26);
this.启动AToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.启动AToolStripMenuItem.Text = "启动 ";
this.启动AToolStripMenuItem.Click += new System.EventHandler(this.启动所有料仓AToolStripMenuItem_Click);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(114, 6);
this.toolStripSeparator4.Size = new System.Drawing.Size(177, 6);
//
// 复位RToolStripMenuItem
//
this.复位RToolStripMenuItem.Name = "复位RToolStripMenuItem";
this.复位RToolStripMenuItem.Size = new System.Drawing.Size(117, 26);
this.复位RToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.复位RToolStripMenuItem.Text = "复位";
this.复位RToolStripMenuItem.Click += new System.EventHandler(this.复位RToolStripMenuItem_Click);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(114, 6);
this.toolStripSeparator3.Size = new System.Drawing.Size(177, 6);
//
// 停止TToolStripMenuItem
//
this.停止TToolStripMenuItem.Name = "停止TToolStripMenuItem";
this.停止TToolStripMenuItem.Size = new System.Drawing.Size(117, 26);
this.停止TToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.停止TToolStripMenuItem.Text = "停止";
this.停止TToolStripMenuItem.Click += new System.EventHandler(this.停止所有料仓TToolStripMenuItem_Click);
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(114, 6);
this.toolStripSeparator5.Size = new System.Drawing.Size(177, 6);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(114, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator2.Visible = false;
//
// 退出ToolStripMenuItem
//
this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(117, 26);
this.退出ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.退出ToolStripMenuItem.Text = "退出";
this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click_1);
//
......@@ -436,36 +436,36 @@
// toolStripSeparator6
//
this.toolStripSeparator6.Name = "toolStripSeparator6";
this.toolStripSeparator6.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator6.Size = new System.Drawing.Size(177, 6);
this.toolStripSeparator6.Visible = false;
//
// 二维码学习ToolStripMenuItem
//
this.二维码学习ToolStripMenuItem.Name = "二维码学习ToolStripMenuItem";
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.二维码学习ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.二维码学习ToolStripMenuItem.Text = "二维码学习";
this.二维码学习ToolStripMenuItem.Click += new System.EventHandler(this.二维码学习ToolStripMenuItem_Click);
//
// toolStripSeparator7
//
this.toolStripSeparator7.Name = "toolStripSeparator7";
this.toolStripSeparator7.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator7.Size = new System.Drawing.Size(177, 6);
//
// 托盘初始化ToolStripMenuItem
//
this.托盘初始化ToolStripMenuItem.Name = "托盘初始化ToolStripMenuItem";
this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(176, 26);
this.托盘初始化ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.托盘初始化ToolStripMenuItem.Text = "托盘编码";
//
// toolStripSeparator16
//
this.toolStripSeparator16.Name = "toolStripSeparator16";
this.toolStripSeparator16.Size = new System.Drawing.Size(173, 6);
this.toolStripSeparator16.Size = new System.Drawing.Size(177, 6);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(176, 26);
this.toolStripMenuItem3.Size = new System.Drawing.Size(180, 26);
this.toolStripMenuItem3.Text = "脆盘料号配置";
this.toolStripMenuItem3.Click += new System.EventHandler(this.toolStripMenuItem3_Click);
//
......@@ -484,31 +484,31 @@
// 清空日志ToolStripMenuItem
//
this.清空日志ToolStripMenuItem.Name = "清空日志ToolStripMenuItem";
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.清空日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.清空日志ToolStripMenuItem.Text = "清空日志";
this.清空日志ToolStripMenuItem.Click += new System.EventHandler(this.清空日志ToolStripMenuItem_Click);
//
// toolStripSeparator10
//
this.toolStripSeparator10.Name = "toolStripSeparator10";
this.toolStripSeparator10.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator10.Size = new System.Drawing.Size(177, 6);
//
// 复制日志ToolStripMenuItem
//
this.复制日志ToolStripMenuItem.Name = "复制日志ToolStripMenuItem";
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.复制日志ToolStripMenuItem.Text = "复制日志";
this.复制日志ToolStripMenuItem.Click += new System.EventHandler(this.复制日志ToolStripMenuItem_Click);
//
// toolStripSeparator11
//
this.toolStripSeparator11.Name = "toolStripSeparator11";
this.toolStripSeparator11.Size = new System.Drawing.Size(141, 6);
this.toolStripSeparator11.Size = new System.Drawing.Size(177, 6);
//
// 版本号ToolStripMenuItem
//
this.版本号ToolStripMenuItem.Name = "版本号ToolStripMenuItem";
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(144, 26);
this.版本号ToolStripMenuItem.Size = new System.Drawing.Size(180, 26);
this.版本号ToolStripMenuItem.Text = "关于软件";
this.版本号ToolStripMenuItem.Click += new System.EventHandler(this.版本号ToolStripMenuItem_Click);
//
......
......@@ -773,5 +773,6 @@ namespace OnlineStore.XLRStore
}
LogUtil.info(Name + " 点击:" + 启用门禁ToolStripMenuItem.Text);
}
}
}
......@@ -65,6 +65,7 @@
this.txtDrawerColumns = new System.Windows.Forms.TextBox();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.cmbColor = new System.Windows.Forms.ComboBox();
this.btnPullUpdwnToPos1 = new System.Windows.Forms.Button();
this.btnMoveAxisToPos1 = new System.Windows.Forms.Button();
this.btnUndwnToPos1 = new System.Windows.Forms.Button();
......@@ -112,6 +113,7 @@
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.btnOpenImg = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
......@@ -494,6 +496,8 @@
//
// groupBox6
//
this.groupBox6.Controls.Add(this.btnOpenImg);
this.groupBox6.Controls.Add(this.cmbColor);
this.groupBox6.Controls.Add(this.btnPullUpdwnToPos1);
this.groupBox6.Controls.Add(this.btnMoveAxisToPos1);
this.groupBox6.Controls.Add(this.btnUndwnToPos1);
......@@ -514,6 +518,22 @@
this.groupBox6.TabStop = false;
this.groupBox6.Text = "groupBox6";
//
// cmbColor
//
this.cmbColor.AutoCompleteCustomSource.AddRange(new string[] {
"Red",
"Blue",
"Green"});
this.cmbColor.FormattingEnabled = true;
this.cmbColor.Items.AddRange(new object[] {
"Red",
"Green",
"Blue"});
this.cmbColor.Location = new System.Drawing.Point(288, 171);
this.cmbColor.Name = "cmbColor";
this.cmbColor.Size = new System.Drawing.Size(79, 25);
this.cmbColor.TabIndex = 18;
//
// btnPullUpdwnToPos1
//
this.btnPullUpdwnToPos1.Location = new System.Drawing.Point(156, 213);
......@@ -575,7 +595,7 @@
//
this.btnAcquireImage1.Location = new System.Drawing.Point(273, 22);
this.btnAcquireImage1.Name = "btnAcquireImage1";
this.btnAcquireImage1.Size = new System.Drawing.Size(86, 123);
this.btnAcquireImage1.Size = new System.Drawing.Size(86, 57);
this.btnAcquireImage1.TabIndex = 12;
this.btnAcquireImage1.Text = "取像";
this.btnAcquireImage1.UseVisualStyleBackColor = true;
......@@ -985,6 +1005,16 @@
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// btnOpenImg
//
this.btnOpenImg.Location = new System.Drawing.Point(273, 88);
this.btnOpenImg.Name = "btnOpenImg";
this.btnOpenImg.Size = new System.Drawing.Size(86, 57);
this.btnOpenImg.TabIndex = 19;
this.btnOpenImg.Text = "打开";
this.btnOpenImg.UseVisualStyleBackColor = true;
this.btnOpenImg.Click += new System.EventHandler(this.btnOpenImg_Click);
//
// FrmAutoFindPos
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
......@@ -1106,5 +1136,7 @@
private System.Windows.Forms.Label lblResult;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.CheckBox chkCloseOutStoreCheck;
private System.Windows.Forms.ComboBox cmbColor;
private System.Windows.Forms.Button btnOpenImg;
}
}
\ No newline at end of file
......@@ -11,6 +11,8 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using eyemLib_Sharp;
using static CodeLibrary.EyemDecode;
namespace OnlineStore.XLRStore
{
......@@ -23,6 +25,7 @@ namespace OnlineStore.XLRStore
boxEquip = StoreManager.XLRStore.boxEquip;
chkBoxCloseCam.Checked = bool.Parse(Common.ConfigAppSettings.GetValue(Setting_Init.CloseCamDetect));
SetState(false);
cmbColor.SelectedIndex = 0;
}
BoxEquip boxEquip;
string posSide = "AA";
......@@ -143,7 +146,7 @@ namespace OnlineStore.XLRStore
private void button10_Click(object sender, EventArgs e)
{
boxEquip.autoFindPos.SetParam(int.Parse(txtCurRow.Text), int.Parse(txtCurCol.Text), int.Parse(txtStartRow.Text),int.Parse(txtStartCol.Text),float.Parse(txtCoffX.Text), float.Parse(txtCoofY.Text));
boxEquip.autoFindPos.SetParam(int.Parse(txtCurRow.Text), int.Parse(txtCurCol.Text), int.Parse(txtStartRow.Text), int.Parse(txtStartCol.Text), float.Parse(txtCoffX.Text), float.Parse(txtCoofY.Text));
StringBuilder head2 = new StringBuilder(boxEquip.CID + posSide + txtStartRow.Text.PadLeft(2, '0') + txtStartCol.Text.PadLeft(2, '0'));
head2.Append("0101");
LineMoveP lineMoveP = new LineMoveP();
......@@ -215,9 +218,10 @@ namespace OnlineStore.XLRStore
bitmap = boxEquip.AcqImage("box_B");
}
pictureBox1.Image = null;
if (bitmap != null)
{
int res = AutoFindPos.GetMarkInfo(bitmap, boxEquip.CID + posSide + "_Manual", string.Format("{0}", DateTime.Now.ToString("yyyyMMddhhmmss")), out eyemOcsFXYR, out Bitmap bitmap1);
int res = AutoFindPos.GetMarkInfo(bitmap, boxEquip.CID + posSide + "_Manual", string.Format("{0}", DateTime.Now.ToString("yyyyMMddhhmmss")), out eyemOcsFXYR, out Bitmap bitmap1, (SelectColor)cmbColor.SelectedIndex);
if (bitmap1 != null)
pictureBox1.Image = bitmap1;
else
......@@ -404,7 +408,7 @@ namespace OnlineStore.XLRStore
private void button4_Click(object sender, EventArgs e)
{
if(posSide.Equals("AA"))
if (posSide.Equals("AA"))
{
boxEquip.PullAxis_Inout.AbsMove(null, boxEquip.Config.PullAxis_Inout_CamA, boxEquip.Config.PullAxis_Inout_P1_Speed);
}
......@@ -445,5 +449,35 @@ namespace OnlineStore.XLRStore
{
boxEquip.CloseOutStoreCheck = chkCloseOutStoreCheck.Checked;
}
private void btnOpenImg_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
op.Filter = "Image|*.bmp";
if (op.ShowDialog() == DialogResult.OK)
{
EyemLibDemo.eyemImageRead(op.FileName, -1,out EyemLibDemo.EyemImage img);
eyemLib_Sharp.EyemLibDemo.EyemOcsFXYR eyemOcsFXYR;
int res = AutoFindPos.GetMarkInfo(img, boxEquip.CID + posSide + "_Manual", string.Format("{0}", DateTime.Now.ToString("yyyyMMddhhmmss")), out eyemOcsFXYR, out Bitmap bitmap1, (SelectColor)cmbColor.SelectedIndex);
if (bitmap1 != null)
pictureBox1.Image = bitmap1;
else
pictureBox1.Image = Image.FromFile(op.FileName);
if (res == 0)
{
txtMark_X.Text = eyemOcsFXYR.fX.ToString("f2");
txtMark_Y.Text = eyemOcsFXYR.fY.ToString("f2");
lblResult.Text = "获取mark点信息成功";
lblResult.BackColor = Color.Green;
}
else
{
lblResult.Text = "获取mark点信息失败,异常码:" + res;
lblResult.BackColor = Color.Red;
}
}
}
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!