Commit c3fa2e42 张东亮

存储机构-保存源图片和异常图片

1 个父辈 80e8f55d
此文件类型无法预览
...@@ -143,7 +143,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -143,7 +143,7 @@ namespace OnlineStore.DeviceLibrary
} }
private void AutoFindPosSaveImage(string imgInfo) private void AutoFindPosSaveImage(string imgInfo)
{ {
SaveImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId),$"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0,4)}",$"{DateTime.Now.ToString("yyyyMMddhhmmss")}_{autoFindPos.CurRow}_{autoFindPos.CurColumn}_{imgInfo}"); //SaveImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId), $"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0, 4)}", $"{DateTime.Now.ToString("yyyyMMddhhmmss")}_{autoFindPos.CurRow}_{autoFindPos.CurColumn}_{imgInfo}");
} }
public void StartFindPos(InOutParam param) public void StartFindPos(InOutParam param)
{ {
...@@ -243,7 +243,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -243,7 +243,7 @@ namespace OnlineStore.DeviceLibrary
//取图 //取图
//Bitmap bitmap = null; //Bitmap bitmap = null;
Bitmap bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId)); Bitmap bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId));
int res = AutoFindPos.GetMarkInfo(bitmap, out ocsFXYR); int res = AutoFindPos.GetMarkInfo(bitmap, $"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0, 4)}",$"row{autoFindPos.CurRow}_col{autoFindPos.CurColumn}", out ocsFXYR);
if (res == 0) if (res == 0)
{ {
MoveInfo.NextMoveStep(StepEnum.SA_03_Pos_AcqImg); MoveInfo.NextMoveStep(StepEnum.SA_03_Pos_AcqImg);
...@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -318,7 +318,7 @@ namespace OnlineStore.DeviceLibrary
//取图 //取图
//Bitmap bitmap1 = null; //Bitmap bitmap1 = null;
Bitmap bitmap1 = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId)); Bitmap bitmap1 = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId));
int res1 = AutoFindPos.GetMarkInfo(bitmap1, out ocsFXYR); int res1 = AutoFindPos.GetMarkInfo(bitmap1, $"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0, 4)}", $"row{autoFindPos.CurRow}_col{autoFindPos.CurColumn}", out ocsFXYR);
if (res1 == 0) if (res1 == 0)
{ {
MoveInfo.NextMoveStep(StepEnum.SA_08_Neg_AcqImg); MoveInfo.NextMoveStep(StepEnum.SA_08_Neg_AcqImg);
...@@ -471,13 +471,52 @@ namespace OnlineStore.DeviceLibrary ...@@ -471,13 +471,52 @@ namespace OnlineStore.DeviceLibrary
/// <param name="bitmap">输入图片</param> /// <param name="bitmap">输入图片</param>
/// <param name="markCoor">mark点坐标信息</param> /// <param name="markCoor">mark点坐标信息</param>
/// <returns>0 正常 -4未定位到 </returns> /// <returns>0 正常 -4未定位到 </returns>
public static int GetMarkInfo(Bitmap bitmap, out EyemOcsFXYR markCoor) public static int GetMarkInfo(Bitmap bitmap,string subpath,string filename, out EyemOcsFXYR markCoor,out Bitmap resBitmap)
{ {
int flag; int flag;
markCoor = new EyemOcsFXYR(); markCoor = new EyemOcsFXYR();
EyemImage tpDstImg;
EyemImage image = eyemCvtToEyemImage(bitmap); EyemImage image = eyemCvtToEyemImage(bitmap);
flag = eyemMarkerTracing(image, 120, ref markCoor); flag = eyemMarkerTracing(image, 120, 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\\";
if (!System.IO.Directory.Exists(path1))
Directory.CreateDirectory(path1);
if (!System.IO.Directory.Exists(path2))
Directory.CreateDirectory(path2);
bitmap.Save(path1+filename+".bmp",System.Drawing.Imaging.ImageFormat.Bmp);
resBitmap = eyemCvtToBitmap(tpDstImg);
if (resBitmap != null)
{
resBitmap.Save(string.Format("{0}{1}_{2}_{3}_{4}.bmp",path2,filename, 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)
{
int flag;
markCoor = new EyemOcsFXYR();
EyemImage tpDstImg;
EyemImage image = eyemCvtToEyemImage(bitmap);
flag = eyemMarkerTracing(image, 120, 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\\";
if (!System.IO.Directory.Exists(path1))
Directory.CreateDirectory(path1);
if (!System.IO.Directory.Exists(path2))
Directory.CreateDirectory(path2);
bitmap.Save(path1 + filename + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
Bitmap resBitmap = eyemCvtToBitmap(tpDstImg);
if (resBitmap != null)
{
resBitmap.Save(string.Format("{0}{1}_{2}_{3}_{4}.bmp", path2, filename, markCoor.fX, markCoor.fY, markCoor.fR));
}
Marshal.FreeHGlobal(image.vpImage); Marshal.FreeHGlobal(image.vpImage);
eyemImageFree(ref tpDstImg);
return flag; return flag;
} }
} }
......
...@@ -76,18 +76,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -76,18 +76,15 @@ namespace OnlineStore.DeviceLibrary
{ {
return camera.GetImage(camName); return camera.GetImage(camName);
} }
public void SaveImage(string camName, string subpath, string filename,Bitmap bitmap=null) public void SaveImage(string camName, string subpath, string filename)
{ {
string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ImagePath) + subpath; string path = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.ImagePath) + subpath;
if (AutoSaveImage) if (AutoSaveImage)
{ {
if (!System.IO.Directory.Exists(path)) if (!System.IO.Directory.Exists(path))
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
//if (bitmap != null)
// bitmap.Save(path + "\\" + filename + ".bmp");
camera.SaveImage(camName, path, filename, System.Drawing.Imaging.ImageFormat.Bmp); camera.SaveImage(camName, path, filename, System.Drawing.Imaging.ImageFormat.Bmp);
} }
//camera.SaveImage(camName, path, filename, System.Drawing.Imaging.ImageFormat.Bmp);
} }
} }
public class CameraArgs : EventArgs public class CameraArgs : EventArgs
......
...@@ -537,7 +537,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -537,7 +537,7 @@ namespace OnlineStore.DeviceLibrary
return true; return true;
} }
Bitmap bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId)); Bitmap bitmap = AcqImage(CamPosSide(MoveInfo.MoveParam.PosInfo.PosId));
int res = AutoFindPos.GetMarkInfo(bitmap, out ocsFXYR); int res = AutoFindPos.GetMarkInfo(bitmap, $"{MoveInfo.MoveParam.PosInfo.PosId.Substring(0, 4)}", $"row{autoFindPos.CurRow}_col{autoFindPos.CurColumn}", out ocsFXYR);
if (res == 0) if (res == 0)
{ {
LogInfo($"存储机构-相机检查库位 {MoveInfo.SLog}:取图[{MoveInfo.MoveParam.PosInfo.PosId}]"); LogInfo($"存储机构-相机检查库位 {MoveInfo.SLog}:取图[{MoveInfo.MoveParam.PosInfo.PosId}]");
......
...@@ -594,7 +594,7 @@ namespace eyemLib_Sharp ...@@ -594,7 +594,7 @@ namespace eyemLib_Sharp
#region 项目 #region 项目
//圆形mark点定位 //圆形mark点定位
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
public static extern int eyemMarkerTracing(EyemImage tpImage, double dThreshold, ref EyemOcsFXYR tpCircle, bool bHighAccuracy = false); public static extern int eyemMarkerTracing(EyemImage tpImage, double dThreshold, ref EyemOcsFXYR tpCircle,out EyemImage tpDstImg, bool bHighAccuracy = false);
#endregion #endregion
#region 通用 #region 通用
...@@ -607,7 +607,7 @@ namespace eyemLib_Sharp ...@@ -607,7 +607,7 @@ namespace eyemLib_Sharp
private static extern int eyemImageRead(string filename, int iFalgs, out EyemImage tpImage); private static extern int eyemImageRead(string filename, int iFalgs, out EyemImage tpImage);
//释放图像资源 //释放图像资源
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)] [DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern void eyemImageFree(ref EyemImage tpImage); public static extern void eyemImageFree(ref EyemImage tpImage);
#endregion #endregion
...@@ -626,7 +626,7 @@ namespace eyemLib_Sharp ...@@ -626,7 +626,7 @@ namespace eyemLib_Sharp
} }
EyemOcsFXYR tpCircle = new EyemOcsFXYR(); EyemOcsFXYR tpCircle = new EyemOcsFXYR();
flag = eyemMarkerTracing(image, 130, ref tpCircle); flag = eyemMarkerTracing(image, 120, ref tpCircle, out tpDstImg);
//0 正常 -4未定位到 //0 正常 -4未定位到
Bitmap bitmap = eyemCvtToBitmap(tpDstImg); Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
......
...@@ -234,7 +234,7 @@ namespace OnlineStore.XLRStore ...@@ -234,7 +234,7 @@ namespace OnlineStore.XLRStore
button11.Enabled = true; button11.Enabled = true;
timer1.Enabled = true; timer1.Enabled = true;
timer1.Start(); timer1.Start();
StringBuilder head2 = new StringBuilder(boxEquip.CID + posSide + textBox6.Text.PadLeft(2, '0') + textBox5.Text.PadLeft(2, '0')+"0101"); StringBuilder head2 = new StringBuilder(boxEquip.CID + posSide + textBox6.Text.PadLeft(2, '0') + textBox5.Text.PadLeft(2, '0') + "0101");
boxEquip.autoFindPosMode = true; boxEquip.autoFindPosMode = true;
boxEquip.StartFindPos(new InOutParam(new InOutPosInfo("AutoFindPos", head2.ToString()))); boxEquip.StartFindPos(new InOutParam(new InOutPosInfo("AutoFindPos", head2.ToString())));
...@@ -242,7 +242,7 @@ namespace OnlineStore.XLRStore ...@@ -242,7 +242,7 @@ namespace OnlineStore.XLRStore
private void button10_Click(object sender, EventArgs e) private void button10_Click(object sender, EventArgs e)
{ {
boxEquip.autoFindPos.SetParam(int.Parse(textBox6.Text), int.Parse(textBox5.Text),float.Parse(textBox8.Text),float.Parse(textBox7.Text)); boxEquip.autoFindPos.SetParam(int.Parse(textBox6.Text), int.Parse(textBox5.Text), float.Parse(textBox8.Text), float.Parse(textBox7.Text));
StringBuilder head2 = new StringBuilder(boxEquip.CID + posSide + textBox6.Text.PadLeft(2, '0') + textBox5.Text.PadLeft(2, '0')); StringBuilder head2 = new StringBuilder(boxEquip.CID + posSide + textBox6.Text.PadLeft(2, '0') + textBox5.Text.PadLeft(2, '0'));
head2.Append("0101"); head2.Append("0101");
LineMoveP lineMoveP = new LineMoveP(); LineMoveP lineMoveP = new LineMoveP();
...@@ -268,7 +268,7 @@ namespace OnlineStore.XLRStore ...@@ -268,7 +268,7 @@ namespace OnlineStore.XLRStore
private void button11_Click(object sender, EventArgs e) private void button11_Click(object sender, EventArgs e)
{ {
if(button11.Text.Equals("暂停")) if (button11.Text.Equals("暂停"))
{ {
boxEquip.autoFindPosMode = false; boxEquip.autoFindPosMode = false;
button11.Text = "继续"; button11.Text = "继续";
...@@ -297,8 +297,9 @@ namespace OnlineStore.XLRStore ...@@ -297,8 +297,9 @@ namespace OnlineStore.XLRStore
private void button13_Click(object sender, EventArgs e) private void button13_Click(object sender, EventArgs e)
{ {
Bitmap bitmap = null; Bitmap bitmap = null;
bool rtn = false ; bool rtn = false;
if(posSide.Equals("AA")) eyemLib_Sharp.EyemLibDemo.EyemOcsFXYR eyemOcsFXYR;
if (posSide.Equals("AA"))
{ {
bitmap = boxEquip.AcqImage("box_A"); bitmap = boxEquip.AcqImage("box_A");
} }
...@@ -307,18 +308,13 @@ namespace OnlineStore.XLRStore ...@@ -307,18 +308,13 @@ namespace OnlineStore.XLRStore
bitmap = boxEquip.AcqImage("box_B"); bitmap = boxEquip.AcqImage("box_B");
} }
pictureBox1.Image = null; pictureBox1.Image = null;
if (bitmap!=null) if (bitmap != null)
{
pictureBox1.Image = bitmap;
int res = AutoFindPos.GetMarkInfo(bitmap, out eyemLib_Sharp.EyemLibDemo.EyemOcsFXYR eyemOcsFXYR);
if (posSide.Equals("AA"))
{ {
boxEquip.SaveImage("box_A", boxEquip.CID + posSide + "_Manual", string.Format("{0}_{1}_{2}", DateTime.Now.ToString("yyyyMMddhhmmss"), eyemOcsFXYR.fX.ToString("f2"), eyemOcsFXYR.fY.ToString("f2"))); int res = AutoFindPos.GetMarkInfo(bitmap, boxEquip.CID + posSide + "_Manual", string.Format("{0}", DateTime.Now.ToString("yyyyMMddhhmmss")), out eyemOcsFXYR, out Bitmap bitmap1);
} if (bitmap1 != null)
pictureBox1.Image = bitmap1;
else else
{ pictureBox1.Image = bitmap;
boxEquip.SaveImage("box_B", boxEquip.CID + posSide + "_Manual", string.Format("{0}_{1}_{2}", DateTime.Now.ToString("yyyyMMddhhmmss"), eyemOcsFXYR.fX.ToString("f2"), eyemOcsFXYR.fY.ToString("f2")));
}
if (res == 0) if (res == 0)
{ {
txtMark_X.Text = eyemOcsFXYR.fX.ToString("f2"); txtMark_X.Text = eyemOcsFXYR.fX.ToString("f2");
...@@ -342,9 +338,9 @@ namespace OnlineStore.XLRStore ...@@ -342,9 +338,9 @@ namespace OnlineStore.XLRStore
private void button14_Click(object sender, EventArgs e) private void button14_Click(object sender, EventArgs e)
{ {
boxEquip.Config.Drawer_X = float.Parse(txtMark_X.Text); boxEquip.Config.Drawer_X = float.Parse(txtMark_X.Text);
boxEquip.Config.Drawer_Y=float.Parse(txtMark_Y.Text); boxEquip.Config.Drawer_Y = float.Parse(txtMark_Y.Text);
boxEquip.Config.Drawer_X_Error=float.Parse(txtMark_X_err.Text); boxEquip.Config.Drawer_X_Error = float.Parse(txtMark_X_err.Text);
boxEquip.Config.Drawer_Y_Error=float.Parse(txtMark_Y_err.Text); boxEquip.Config.Drawer_Y_Error = float.Parse(txtMark_Y_err.Text);
StoreManager.SaveBoxConfig(boxEquip.Config); StoreManager.SaveBoxConfig(boxEquip.Config);
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!