Commit 93e26866 张东亮

重新获取条码时添加提示信息:清除模板

1 个父辈 a291af67
...@@ -16,6 +16,6 @@ namespace Model ...@@ -16,6 +16,6 @@ namespace Model
public const string MATERIAL_TEMPLATE_DEL = "MaterialTemplateDel"; public const string MATERIAL_TEMPLATE_DEL = "MaterialTemplateDel";
public const string MATERIAL_TEMPLATE_RENAME = "MaterialTemplateRename"; public const string MATERIAL_TEMPLATE_RENAME = "MaterialTemplateRename";
public const string SAVE_SUCCEED = "SaveSucceed"; public const string SAVE_SUCCEED = "SaveSucceed";
public const string REMIND_CLEARTEMPLATE = "RemindClearTemplate";
} }
} }
此文件类型无法预览
...@@ -18,7 +18,7 @@ namespace SmartScan ...@@ -18,7 +18,7 @@ namespace SmartScan
public UsrMaterialTemplate() public UsrMaterialTemplate()
{ {
InitializeComponent(); InitializeComponent();
BtnOcrCode.Enabled = Config.Func_EnabledOCR; //BtnOcrCode.Enabled = Config.Func_EnabledOCR;
LstMate.Items.AddRange(Common.mateEdit.Name); LstMate.Items.AddRange(Common.mateEdit.Name);
mateCopy = Common.mateEdit.ToCopy(); mateCopy = Common.mateEdit.ToCopy();
Language.SetLanguage(this); Language.SetLanguage(this);
...@@ -241,7 +241,14 @@ namespace SmartScan ...@@ -241,7 +241,14 @@ namespace SmartScan
private void BtnScanCode_Click(object sender, EventArgs e) private void BtnScanCode_Click(object sender, EventArgs e)
{ {
if (bmp == null) return; if (bmp == null) return;
string text = Language.Dialog(LanguageDialogKey.REMIND_CLEARTEMPLATE, "Recognizing code will reset the template.Are you sure to perform the action?");
DialogResult dialogResult = new FaceMessageBox(mateCopy[mateIndex].Name, text, MessageBoxButtons.YesNo).ShowDialog();
if (dialogResult == DialogResult.No)
{
return;
}
List<CameraVisionLib.Model.BarcodeInfo> info = Common.cameraVision.GetBarCode(bmp); List<CameraVisionLib.Model.BarcodeInfo> info = Common.cameraVision.GetBarCode(bmp);
LstCode.Items.Clear(); LstCode.Items.Clear();
ImgShow.CodeCenterClear(); ImgShow.CodeCenterClear();
...@@ -252,13 +259,6 @@ namespace SmartScan ...@@ -252,13 +259,6 @@ namespace SmartScan
mateCopy[mateIndex].State = TemplateState.Unsaved; mateCopy[mateIndex].State = TemplateState.Unsaved;
Common.mateMaxCodeID = info.Count; Common.mateMaxCodeID = info.Count;
if (info.Count == 0)
{
string text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return;
}
PointF[] lst = new PointF[info.Count]; PointF[] lst = new PointF[info.Count];
for (int i = 0; i < info.Count; i++) for (int i = 0; i < info.Count; i++)
{ {
...@@ -279,10 +279,34 @@ namespace SmartScan ...@@ -279,10 +279,34 @@ namespace SmartScan
mateCopy[mateIndex].Code.Add(code); mateCopy[mateIndex].Code.Add(code);
lst[i] = info[i].Center; lst[i] = info[i].Center;
} }
if (Config.Func_EnabledOCR)
{
//保存需要识别ocr的区域
bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
int startidx = Common.mateMaxCodeID + 1;
foreach (var ocr in regOcrCodes)
{
if (string.IsNullOrEmpty(ocr)) continue;
MaterialCode code = new()
{
ID = startidx,
Text = ocr,
CodeType = Setting_Str.OCR
};
mateCopy[mateIndex].Code.Add(code);
startidx++;
}
}
if (mateCopy[mateIndex].Code.Count == 0)
{
text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return;
}
ImgShow.AddCodeCenter(lst);
LstCode.Items.AddRange(FormatCode()); LstCode.Items.AddRange(FormatCode());
LstCode.SelectedIndex = codeIndex = -1; LstCode.SelectedIndex = codeIndex = -1;
ImgShow.AddCodeCenter(lst);
} }
private void BtnExtractCode_Click(object sender, EventArgs e) private void BtnExtractCode_Click(object sender, EventArgs e)
...@@ -308,40 +332,40 @@ namespace SmartScan ...@@ -308,40 +332,40 @@ namespace SmartScan
private void BtnOcrCode_Click(object sender, EventArgs e) private void BtnOcrCode_Click(object sender, EventArgs e)
{ {
if (bmp == null) return; if (bmp == null) return;
//保存需要识别ocr的区域 ////保存需要识别ocr的区域
bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';'); //string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
LstCode.Items.Clear(); //LstCode.Items.Clear();
var ocrs = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR)); //var ocrs = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR));
foreach (var code in ocrs) //foreach (var code in ocrs)
{ //{
mateCopy[mateIndex].Code.Remove(code); // mateCopy[mateIndex].Code.Remove(code);
} //}
mateCopy[mateIndex].Match.Clear(); //mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].Ocr.Clear(); //mateCopy[mateIndex].Ocr.Clear();
if (regOcrCodes.Length == 0) //if (regOcrCodes.Length == 0)
{ //{
string text = Language.Dialog(LanguageDialogKey.CODE_COUNT); // string text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog(); // new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return; // return;
} //}
mateCopy[mateIndex].State = TemplateState.Unsaved; //mateCopy[mateIndex].State = TemplateState.Unsaved;
int startidx = Common.mateMaxCodeID + 1; //int startidx = Common.mateMaxCodeID + 1;
foreach (var ocr in regOcrCodes) //foreach (var ocr in regOcrCodes)
{ //{
if (string.IsNullOrEmpty(ocr)) continue; // if (string.IsNullOrEmpty(ocr)) continue;
MaterialCode code = new() // MaterialCode code = new()
{ // {
ID = startidx, // ID = startidx,
Text = ocr, // Text = ocr,
CodeType = Setting_Str.OCR // CodeType = Setting_Str.OCR
}; // };
mateCopy[mateIndex].Code.Add(code); // mateCopy[mateIndex].Code.Add(code);
startidx++; // startidx++;
} //}
LstCode.Items.AddRange(FormatCode()); //LstCode.Items.AddRange(FormatCode());
LstCode.SelectedIndex = codeIndex = -1; //LstCode.SelectedIndex = codeIndex = -1;
//if (codeIndex == -1) return; //if (codeIndex == -1) return;
//var m = mateCopy[mateIndex].Match.Find(m=>m.CodeID==codeIndex); //var m = mateCopy[mateIndex].Match.Find(m=>m.CodeID==codeIndex);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!