Commit 93e26866 张东亮

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

1 个父辈 a291af67
......@@ -16,6 +16,6 @@ namespace Model
public const string MATERIAL_TEMPLATE_DEL = "MaterialTemplateDel";
public const string MATERIAL_TEMPLATE_RENAME = "MaterialTemplateRename";
public const string SAVE_SUCCEED = "SaveSucceed";
public const string REMIND_CLEARTEMPLATE = "RemindClearTemplate";
}
}
此文件类型无法预览
......@@ -68,9 +68,9 @@ namespace SmartScan
this.facePanel1.Controls.Add(this.LstMate);
this.facePanel1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.facePanel1.Location = new System.Drawing.Point(4, 4);
this.facePanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.facePanel1.Margin = new System.Windows.Forms.Padding(4);
this.facePanel1.Name = "facePanel1";
this.facePanel1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.facePanel1.Padding = new System.Windows.Forms.Padding(4);
this.facePanel1.ShowText = false;
this.facePanel1.Size = new System.Drawing.Size(1173, 536);
this.facePanel1.TabIndex = 1;
......@@ -86,9 +86,9 @@ namespace SmartScan
this.BtnExtractCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnExtractCode.HoldPress = false;
this.BtnExtractCode.Location = new System.Drawing.Point(243, 409);
this.BtnExtractCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnExtractCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnExtractCode.Name = "BtnExtractCode";
this.BtnExtractCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnExtractCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnExtractCode.Size = new System.Drawing.Size(461, 56);
this.BtnExtractCode.TabIndex = 17;
this.BtnExtractCode.Text = "条码提取";
......@@ -103,12 +103,13 @@ namespace SmartScan
this.BtnOcrCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOcrCode.HoldPress = false;
this.BtnOcrCode.Location = new System.Drawing.Point(243, 473);
this.BtnOcrCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOcrCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Name = "BtnOcrCode";
this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Size = new System.Drawing.Size(227, 56);
this.BtnOcrCode.TabIndex = 16;
this.BtnOcrCode.Text = "OCR";
this.BtnOcrCode.Visible = false;
this.BtnOcrCode.Click += new System.EventHandler(this.BtnOcrCode_Click);
//
// BtnPrimaryCode
......@@ -120,9 +121,9 @@ namespace SmartScan
this.BtnPrimaryCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnPrimaryCode.HoldPress = false;
this.BtnPrimaryCode.Location = new System.Drawing.Point(477, 472);
this.BtnPrimaryCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnPrimaryCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnPrimaryCode.Name = "BtnPrimaryCode";
this.BtnPrimaryCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnPrimaryCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnPrimaryCode.Size = new System.Drawing.Size(227, 56);
this.BtnPrimaryCode.TabIndex = 15;
this.BtnPrimaryCode.Text = "特征码";
......@@ -138,9 +139,9 @@ namespace SmartScan
this.ImgShow.BorderWidth = 2;
this.ImgShow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.ImgShow.Location = new System.Drawing.Point(712, 8);
this.ImgShow.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ImgShow.Margin = new System.Windows.Forms.Padding(4);
this.ImgShow.Name = "ImgShow";
this.ImgShow.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ImgShow.Padding = new System.Windows.Forms.Padding(4);
this.ImgShow.Size = new System.Drawing.Size(453, 521);
this.ImgShow.TabIndex = 14;
this.ImgShow.Text = "facePictureBox1";
......@@ -156,9 +157,9 @@ namespace SmartScan
this.LstCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LstCode.ItemHeight = 40;
this.LstCode.Location = new System.Drawing.Point(243, 135);
this.LstCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstCode.Margin = new System.Windows.Forms.Padding(4);
this.LstCode.Name = "LstCode";
this.LstCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstCode.Padding = new System.Windows.Forms.Padding(4);
this.LstCode.SelectedIndex = -1;
this.LstCode.Size = new System.Drawing.Size(461, 266);
this.LstCode.TabIndex = 13;
......@@ -173,9 +174,9 @@ namespace SmartScan
this.BtnScanCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnScanCode.HoldPress = false;
this.BtnScanCode.Location = new System.Drawing.Point(243, 71);
this.BtnScanCode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnScanCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnScanCode.Name = "BtnScanCode";
this.BtnScanCode.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnScanCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnScanCode.Size = new System.Drawing.Size(461, 56);
this.BtnScanCode.TabIndex = 12;
this.BtnScanCode.Text = "条码识别";
......@@ -189,9 +190,9 @@ namespace SmartScan
this.BtnLocalImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnLocalImage.HoldPress = false;
this.BtnLocalImage.Location = new System.Drawing.Point(477, 8);
this.BtnLocalImage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnLocalImage.Margin = new System.Windows.Forms.Padding(4);
this.BtnLocalImage.Name = "BtnLocalImage";
this.BtnLocalImage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnLocalImage.Padding = new System.Windows.Forms.Padding(4);
this.BtnLocalImage.Size = new System.Drawing.Size(227, 56);
this.BtnLocalImage.TabIndex = 11;
this.BtnLocalImage.Text = "本地图像";
......@@ -205,9 +206,9 @@ namespace SmartScan
this.BtnCameraImage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnCameraImage.HoldPress = false;
this.BtnCameraImage.Location = new System.Drawing.Point(243, 8);
this.BtnCameraImage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCameraImage.Margin = new System.Windows.Forms.Padding(4);
this.BtnCameraImage.Name = "BtnCameraImage";
this.BtnCameraImage.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCameraImage.Padding = new System.Windows.Forms.Padding(4);
this.BtnCameraImage.Size = new System.Drawing.Size(227, 56);
this.BtnCameraImage.TabIndex = 10;
this.BtnCameraImage.Text = "相机图像";
......@@ -221,9 +222,9 @@ namespace SmartScan
this.BtnCloseLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnCloseLight.HoldPress = false;
this.BtnCloseLight.Location = new System.Drawing.Point(8, 454);
this.BtnCloseLight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCloseLight.Margin = new System.Windows.Forms.Padding(4);
this.BtnCloseLight.Name = "BtnCloseLight";
this.BtnCloseLight.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnCloseLight.Padding = new System.Windows.Forms.Padding(4);
this.BtnCloseLight.Size = new System.Drawing.Size(227, 56);
this.BtnCloseLight.TabIndex = 9;
this.BtnCloseLight.Text = "关闭";
......@@ -237,9 +238,9 @@ namespace SmartScan
this.BtnOpenLight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOpenLight.HoldPress = false;
this.BtnOpenLight.Location = new System.Drawing.Point(8, 390);
this.BtnOpenLight.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOpenLight.Margin = new System.Windows.Forms.Padding(4);
this.BtnOpenLight.Name = "BtnOpenLight";
this.BtnOpenLight.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnOpenLight.Padding = new System.Windows.Forms.Padding(4);
this.BtnOpenLight.Size = new System.Drawing.Size(227, 56);
this.BtnOpenLight.TabIndex = 8;
this.BtnOpenLight.Text = "打开光源";
......@@ -253,9 +254,9 @@ namespace SmartScan
this.BtnRenameMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnRenameMate.HoldPress = false;
this.BtnRenameMate.Location = new System.Drawing.Point(8, 326);
this.BtnRenameMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnRenameMate.Margin = new System.Windows.Forms.Padding(4);
this.BtnRenameMate.Name = "BtnRenameMate";
this.BtnRenameMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnRenameMate.Padding = new System.Windows.Forms.Padding(4);
this.BtnRenameMate.Size = new System.Drawing.Size(227, 56);
this.BtnRenameMate.TabIndex = 7;
this.BtnRenameMate.Text = "重命名";
......@@ -269,9 +270,9 @@ namespace SmartScan
this.BtnDelMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnDelMate.HoldPress = false;
this.BtnDelMate.Location = new System.Drawing.Point(8, 262);
this.BtnDelMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnDelMate.Margin = new System.Windows.Forms.Padding(4);
this.BtnDelMate.Name = "BtnDelMate";
this.BtnDelMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnDelMate.Padding = new System.Windows.Forms.Padding(4);
this.BtnDelMate.Size = new System.Drawing.Size(227, 56);
this.BtnDelMate.TabIndex = 6;
this.BtnDelMate.Text = "删除标签";
......@@ -285,9 +286,9 @@ namespace SmartScan
this.BtnAddMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnAddMate.HoldPress = false;
this.BtnAddMate.Location = new System.Drawing.Point(8, 199);
this.BtnAddMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnAddMate.Margin = new System.Windows.Forms.Padding(4);
this.BtnAddMate.Name = "BtnAddMate";
this.BtnAddMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BtnAddMate.Padding = new System.Windows.Forms.Padding(4);
this.BtnAddMate.Size = new System.Drawing.Size(227, 56);
this.BtnAddMate.TabIndex = 5;
this.BtnAddMate.Text = "新建标签";
......@@ -300,9 +301,9 @@ namespace SmartScan
this.LstMate.BorderWidth = 2;
this.LstMate.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.LstMate.Location = new System.Drawing.Point(8, 8);
this.LstMate.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstMate.Margin = new System.Windows.Forms.Padding(4);
this.LstMate.Name = "LstMate";
this.LstMate.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LstMate.Padding = new System.Windows.Forms.Padding(4);
this.LstMate.SelectedIndex = -1;
this.LstMate.Size = new System.Drawing.Size(227, 184);
this.LstMate.TabIndex = 4;
......@@ -313,7 +314,7 @@ namespace SmartScan
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.facePanel1);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "UsrMaterialTemplate";
this.Size = new System.Drawing.Size(1223, 582);
this.facePanel1.ResumeLayout(false);
......
......@@ -18,7 +18,7 @@ namespace SmartScan
public UsrMaterialTemplate()
{
InitializeComponent();
BtnOcrCode.Enabled = Config.Func_EnabledOCR;
//BtnOcrCode.Enabled = Config.Func_EnabledOCR;
LstMate.Items.AddRange(Common.mateEdit.Name);
mateCopy = Common.mateEdit.ToCopy();
Language.SetLanguage(this);
......@@ -241,7 +241,14 @@ namespace SmartScan
private void BtnScanCode_Click(object sender, EventArgs e)
{
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);
LstCode.Items.Clear();
ImgShow.CodeCenterClear();
......@@ -252,13 +259,6 @@ namespace SmartScan
mateCopy[mateIndex].State = TemplateState.Unsaved;
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];
for (int i = 0; i < info.Count; i++)
{
......@@ -279,10 +279,34 @@ namespace SmartScan
mateCopy[mateIndex].Code.Add(code);
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.SelectedIndex = codeIndex = -1;
ImgShow.AddCodeCenter(lst);
}
private void BtnExtractCode_Click(object sender, EventArgs e)
......@@ -308,40 +332,40 @@ namespace SmartScan
private void BtnOcrCode_Click(object sender, EventArgs e)
{
if (bmp == null) return;
//保存需要识别ocr的区域
bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
LstCode.Items.Clear();
var ocrs = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR));
foreach (var code in ocrs)
{
mateCopy[mateIndex].Code.Remove(code);
}
mateCopy[mateIndex].Match.Clear();
mateCopy[mateIndex].Ocr.Clear();
if (regOcrCodes.Length == 0)
{
string text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
return;
}
mateCopy[mateIndex].State = TemplateState.Unsaved;
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++;
}
////保存需要识别ocr的区域
//bmp?.Save(@"ocrt.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
//string[] regOcrCodes = PaddleOCRHelper.StartTest("..\\ocrt.jpg").Split(';');
//LstCode.Items.Clear();
//var ocrs = mateCopy[mateIndex].Code.FindAll(s => s.CodeType.Equals(Setting_Str.OCR));
//foreach (var code in ocrs)
//{
// mateCopy[mateIndex].Code.Remove(code);
//}
//mateCopy[mateIndex].Match.Clear();
//mateCopy[mateIndex].Ocr.Clear();
//if (regOcrCodes.Length == 0)
//{
// string text = Language.Dialog(LanguageDialogKey.CODE_COUNT);
// new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
// return;
//}
//mateCopy[mateIndex].State = TemplateState.Unsaved;
//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++;
//}
LstCode.Items.AddRange(FormatCode());
LstCode.SelectedIndex = codeIndex = -1;
//LstCode.Items.AddRange(FormatCode());
//LstCode.SelectedIndex = codeIndex = -1;
//if (codeIndex == -1) return;
//var m = mateCopy[mateIndex].Match.Find(m=>m.CodeID==codeIndex);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!