Commit b2fb4069 LN

点料算法更新

1 个父辈 6e29a642
......@@ -75,29 +75,18 @@
</summary>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetLocalCount(System.String,System.Double,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<member name="M:Asa.CarerayImage.GetLocalCount(System.String,System.Double,System.Int32,System.String@,Asa.API.EyemImage@)">
<summary>
本地文件器件点料
本地文件普通器件点料
</summary>
<param name="path"></param>
<param name="dOffset"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="count"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetLocalCountHuge(System.String,System.Double,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<summary>
本地文件大器件点料
</summary>
<param name="path"></param>
<param name="dOffset"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.CarerayImage.GetLocalCountIrregular(System.String,System.Double,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<member name="M:Asa.CarerayImage.GetLocalCountIrregular(System.String,System.Double,System.Int32,System.Int32,System.String@,Asa.API.EyemImage@)">
<summary>
本地文件异性器件点料
</summary>
......@@ -105,7 +94,7 @@
<param name="dOffset"></param>
<param name="type"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="count"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
......@@ -124,23 +113,9 @@
</summary>
<param name="ipImage"></param>
</member>
<member name="M:Asa.API.eyemCountObject(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<summary>
小盘点料
</summary>
<param name="tpSrcImg"></param>
<param name="fileName"></param>
<param name="dOffset"></param>
<param name="iMinArea"></param>
<param name="iMaxArea"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.API.eyemCountObject4Huge(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<member name="M:Asa.API.eyemCountObject(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.IntPtr@,Asa.API.EyemImage@)">
<summary>
大盘点料
普通器件
</summary>
<param name="tpSrcImg"></param>
<param name="fileName"></param>
......@@ -148,13 +123,13 @@
<param name="iMinArea"></param>
<param name="iMaxArea"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="pNumObj"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
<member name="M:Asa.API.eyemCountObjectIrregularParts(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.Int32@,Asa.API.EyemImage@)">
<member name="M:Asa.API.eyemCountObjectIrregularParts(Asa.API.EyemImage,System.String,System.Double,System.Int32,System.Int32,System.Int32,System.IntPtr@,Asa.API.EyemImage@)">
<summary>
器件
器件
</summary>
<param name="tpSrcImg"></param>
<param name="fileName"></param>
......@@ -162,7 +137,7 @@
<param name="iType"></param>
<param name="iMaxArea"></param>
<param name="iWinSize"></param>
<param name="iObjCount"></param>
<param name="pNumObj"></param>
<param name="tpDstImg"></param>
<returns></returns>
</member>
......
......@@ -142,7 +142,7 @@ namespace OnlineStore.AutoCountClient
list.Add(obj.ToCSVStr());
}
File.WriteAllLines(filePath, list.ToArray<string>(), Encoding.GetEncoding("gbk"));
File.WriteAllLines(filePath, list.ToArray<string>(), Encoding.UTF8);
MessageBox.Show("成功导出程序到文件:" + "\r\n" + filePath);
}
}
......
......@@ -282,7 +282,7 @@ namespace OnlineStore.AutoCountClient
txtFengzhuang.Text = "";
txtPartNum.Text = "";
cmbSuanfa.SelectedIndex = 5;
lblTuijian.Text = "";
txtPartNum.Enabled = true;
groupInfo.Text = "新增元器件";
}
......
using Acc.ImageBox;
using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -20,9 +21,8 @@ namespace OnlineStore.AutoCountClient
public FrmLearning()
{
InitializeComponent();
}
private ImageBox currShowBox = null;
private int CurrType = -1;
}
private int CurrType = -2;
private string CurrFullFileName = "";
private string CurrPN = "";
......@@ -84,8 +84,7 @@ namespace OnlineStore.AutoCountClient
if (currIndex >= ImageList.Count)
{
btnNext.Enabled = false;
MessageBox.Show("已经是最后一张图片");
MessageBox.Show("已经是最后一张图片");
return;
}
string fullFName = ImageList[currIndex];
......@@ -117,7 +116,7 @@ namespace OnlineStore.AutoCountClient
}
else
{
ShowType(-1);
ShowType(-1);
}
imgCurrImg.HorizontalScroll.Value = 173;
......@@ -126,6 +125,24 @@ namespace OnlineStore.AutoCountClient
{
btnNext.Enabled = false;
}
if (LoadCSVLibrary.CSVBomManager.allComMap.ContainsKey(CurrPN))
{
ComponetInfo com = CSVBomManager.allComMap[CurrPN];
lblDes.Text = "描述:" + com.Describe;
lblFeng.Text = "封装:" + com.Encapsulations;
lblPN.Text = "元器件编号:" + com.PartNum;
lblProName.Text = "产品:" + com.ProductName;
}
else
{
lblPN.Text = "元器件编号:" + CurrPN;
lblDes.Text = "--";
lblFeng.Text = "--";
lblProName.Text = "--";
}
timer1.Start();
}
......@@ -138,10 +155,12 @@ namespace OnlineStore.AutoCountClient
CurrType = type;
int index = 0;
btnTest.Text = "请选择算法";
bool findsuanfa = false;
foreach (Button btn in SelBtnList)
{
if (index.Equals(type))
{
findsuanfa = true;
btn.Text = gouStr + btn.Tag;
btnTest.Text = btn.Tag + "-点料测试";
btn.BackColor = Color.LightGreen;
......@@ -153,12 +172,9 @@ namespace OnlineStore.AutoCountClient
}
index++;
}
bool isShowBtn = (type >= 0&&type<5);
btnTest.Enabled = isShowBtn;
btnNext.Enabled = isShowBtn;
btnEnd.Enabled = true ;
btnTest.Enabled = findsuanfa;
btnNext.Enabled = findsuanfa;
}
private void btnTest_Click(object sender, EventArgs e)
......@@ -248,7 +264,7 @@ namespace OnlineStore.AutoCountClient
private void btnNext_Click(object sender, EventArgs e)
{
btnNext.Enabled = false;
//btnNext.Enabled = false;
this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
try
{
......@@ -258,7 +274,7 @@ namespace OnlineStore.AutoCountClient
{
LogUtil.error("下一张 报错:" + ex.ToString());
}
btnNext.Enabled = true;
//btnNext.Enabled = true;
this.Cursor = System.Windows.Forms.Cursors.Default;
}
......
type,sign,value,threshold,windowSize
type,sign,value,threshold,windowSize
6H10B,1,5,0,0
7H5S1,0,0,0,0
6H106,1,0,0,0
......
......@@ -559,29 +559,50 @@ namespace OnlineStore.DeviceLibrary
}
public int GetCountResult(string fileP, CountParam param,out Asa.API.EyemImage tpDstImg)
public int GetCountResult(string fileP, CountParam param, out Asa.API.EyemImage tpDstImg)
{
// 器件类型
//"小器件" GetLocalCount
//"粘连不严重" GetLocalCountIrregular type = 0
//"大器件" GetLocalCountIrregular type = 1
//"长条型器件" GetLocalCountIrregular type = 2
//"E形状" GetLocalCountIrregular type = 3
//返回的数量是string类型,count = "4000,3000,3500,2000"
int count = 0;
int result = 0;
int type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize;
if (param.Sign.Equals(0))
{
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out count, out tpDstImg);
LogUtil.info("GetCountResult "+ type + " 调用 GetLocalCount 【" + fileP+"】【"+threshold+"】【"+windowsize+"】,返回【"+result+"】,结果【"+count+"】");
}
else if (param.Sign.Equals(1))
tpDstImg = new API.EyemImage();
try
{
result = carerayImage.GetLocalCountHuge(fileP, threshold, windowsize, out count, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + count + "】");
string countStr = "";
int result = 0;
int type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize;
if (param.Sign.Equals(0))
{
result = carerayImage.GetLocalCount(fileP, threshold, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
//else if (param.Sign.Equals(1))
//{
// result = carerayImage.GetLocalCountHuge(fileP, threshold, windowsize, out countStr, out tpDstImg);
// LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
//}
else
{
int t = param.Sign - 1;
result = carerayImage.GetLocalCountIrregular(fileP, threshold, t, windowsize, out countStr, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】[" + t + "]【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
}
string[] array = countStr.Split(',');
if (array.Length > 0)
{
count= Convert.ToInt32(array[0]);
}
}
else
catch (Exception ex)
{
int t = param.Sign - 2;
WorkLog("点料:开始调用 carerayImage.GetLocalCountIrregular ");
result = carerayImage.GetLocalCountIrregular(fileP, threshold, t, windowsize, out count, out tpDstImg);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】["+t+"]【" + windowsize + "】,返回【" + result + "】,结果【" + count + "】");
LogUtil.error("GetCountResult 出错: " + ex.ToString());
}
return count;
}
......
......@@ -121,6 +121,8 @@ namespace OnlineStore.DeviceLibrary
File.WriteAllLines(ConfigFilePath, lineList);
LogUtil.info("SaveMapToFile 【" + ConfigFilePath + "】");
CSVBomManager.BackFile(ConfigFilePath, lineList.ToArray());
}
catch (Exception ex)
{
......
......@@ -114,7 +114,7 @@ namespace OnlineStore.LoadCSVLibrary
}
File.WriteAllLines(filePath, lines, Encoding.GetEncoding("gbk"));
}
catch (Exception ex)
{
......@@ -162,7 +162,7 @@ namespace OnlineStore.LoadCSVLibrary
if (!titleIndex.ContainsKey(str))
{
LogUtil.error("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("未找到必须列:" + str + ",加载数据失败!");
throw new CVSFieldNotMatchingExection("【"+ lineValue + "】未找到必须列:【" + str + "】,加载数据失败!");
}
}
}
......
......@@ -56,9 +56,15 @@ namespace OnlineStore.LoadCSVLibrary
}
public static string getFilePath()
{
{
string ComPath_Config = ConfigAppSettings.GetValue(Setting_Init.ComPath_Config);
if (String.IsNullOrEmpty(ComPath_Config))
{
ComPath_Config = @"\XRAY\pnDetailedList.csv";
ConfigAppSettings.SaveValue(Setting_Init.ComPath_Config, ComPath_Config);
}
string appPath = Application.StartupPath;
string fileName = appPath + ConfigAppSettings.GetValue(Setting_Init.ComPath_Config);
string fileName = appPath + ComPath_Config;
return fileName;
}
/// <summary>
......@@ -245,6 +251,8 @@ namespace OnlineStore.LoadCSVLibrary
}
bool result = WriteCSVFile(filePath, lines);
LogUtil.info("保存物料库列表到文件 SaveToFile :" + result);
BackFile(filePath, lines);
return true;
}
catch (Exception ex)
......@@ -264,6 +272,56 @@ namespace OnlineStore.LoadCSVLibrary
return false;
}
public static void BackFile(string filePath, string[] lines)
{
//备份保存
//try
//{
// FileInfo file = new FileInfo(filePath);
// string date = DateTime.Now.ToString("yyyy-MM-dd");
// string targetBackPath = @"C:\configBack\" + date + @"\";
// if (!Directory.Exists(targetBackPath))
// {
// Directory.CreateDirectory(targetBackPath);
// }
// string fileName = file.Name;
// string backFile = targetBackPath + fileName;
// if (File.Exists(backFile))
// {
// File.Delete(backFile);
// }
// File.WriteAllLines(backFile, lines, Encoding.GetEncoding("gbk"));
//}
//catch (Exception e)
//{
// LogUtil.error("备份["+ filePath + "]到C:configBack出错:" + e.ToString());
//}
//备份保存
try
{
FileInfo file = new FileInfo(filePath);
string date = DateTime.Now.ToString("yyyy-MM-dd");
string targetBackPath = @"D:\configBack\" + date + @"\";
if (!Directory.Exists(targetBackPath))
{
Directory.CreateDirectory(targetBackPath);
}
string fileName = file.Name;
string backFile = targetBackPath + fileName;
if (File.Exists(backFile))
{
File.Delete(backFile);
}
File.WriteAllLines(backFile, lines, Encoding.UTF8);
}
catch (Exception e)
{
LogUtil.error("备份[" + filePath + "]到D:configBack出错:" + e.ToString());
}
}
public static ComponetInfo GetCom(string partNum)
{
if (allComMap.ContainsKey(partNum))
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!