Commit a87d9d2a 贾鹏旭

Merge branch 'master' of 106.15.194.121:zdl/NS100

2 个父辈 06067e03 175c3b0a
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
<Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL"> <Reference Include="ExcelNumberFormat, Version=1.1.0.0, Culture=neutral, PublicKeyToken=23c6f5d73be07eca, processorArchitecture=MSIL">
<HintPath>..\packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath> <HintPath>..\packages\ExcelNumberFormat.1.1.0\lib\net20\ExcelNumberFormat.dll</HintPath>
</Reference> </Reference>
<Reference Include="IDHIKCamera">
<HintPath>..\SharedDll\IDHIKCamera.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.12\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
...@@ -99,6 +102,7 @@ ...@@ -99,6 +102,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="AsciiToCharReplacer.cs" /> <Compile Include="AsciiToCharReplacer.cs" />
<Compile Include="BLLCommon.cs" /> <Compile Include="BLLCommon.cs" />
<Compile Include="Camera.cs" />
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="ConvertBarcode.cs" /> <Compile Include="ConvertBarcode.cs" />
<Compile Include="Extension.cs" /> <Compile Include="Extension.cs" />
......
...@@ -12,7 +12,6 @@ namespace BLL ...@@ -12,7 +12,6 @@ namespace BLL
public static BLL.PrintLabelEdit labelEdit; public static BLL.PrintLabelEdit labelEdit;
public static BLL.MaterialEdit mateEdit; public static BLL.MaterialEdit mateEdit;
public static Model.OCR ocr; public static Model.OCR ocr;
public static Asa.Camera.VisionLib cameraVision;
public static BLL.IO_Interface ioModule; public static BLL.IO_Interface ioModule;
public static LightSource lightSource; public static LightSource lightSource;
public static ServerCommunication SCMM; public static ServerCommunication SCMM;
......
using CameraVisionLib.Model;
using DocumentFormat.OpenXml.EMMA;
using IDHIKCamera;
using Model;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace BLL
{
public class Camera
{
public static bool useIDCamera = Config.Func_UseIDCamera;
static Asa.Camera.VisionLib cameraVision;
static string cameraName = null;
public static void LoadCamera()
{
if (useIDCamera)
{
try
{
cameraVision = new Asa.Camera.VisionLib(FilePath.CONFIG_CAMERA, false);
LibLogUtil.LogEvent += LibLogUtil_LogEvent;
IDHIK.Instance.Load();
List<string> names = IDHIK.Instance.cameraName;
IDHIK.Instance.DrawLine = false;
if (names != null)
{
// hikNameList.AddRange(names);
//foreach (string name in names)
//{
// LogNet.log.Info("加载到IDHIK相机:" + name);
//}
cameraName = names.Find(s => s.Contains("ID"));
}
//IDHIK.Instance.OpenAll();
}
catch (Exception ex)
{
LogNet.log.Error("解析IDHIK出错:" + ex.StackTrace);
}
}
else
{
cameraVision = new Asa.Camera.VisionLib(FilePath.CONFIG_CAMERA, BLLCommon.config.EnabledCamera);
LogNet.log.Info("加载相机,数量:" + cameraVision.Count);
}
}
private static void LibLogUtil_LogEvent(LibLogEventArg libLogEventArg)
{
switch (libLogEventArg.Level)
{
case LibLogLevel.Debug:
LogNet.log.Debug(libLogEventArg.Msg);
break;
case LibLogLevel.Info:
LogNet.log.Info(libLogEventArg.Msg);
break;
case LibLogLevel.Warning:
LogNet.log.Warn(libLogEventArg.Msg);
break;
case LibLogLevel.Error:
LogNet.log.Error(libLogEventArg.Msg, libLogEventArg.Exception);
break;
}
}
public static bool IsConnected()
{
if (useIDCamera)
{
bool rtn = !string.IsNullOrEmpty(cameraName);
if (rtn)
{
LogNet.log.Info("扫码相机已连接");
}
else
LogNet.log.Info("扫码相机未连接");
return rtn;
}
else
{
LogNet.log.Info("相机数量为" + cameraVision.Count);
return cameraVision.Count > 0;
}
}
public static Bitmap[] Capture()
{
Bitmap[] result = new Bitmap[1];
if (useIDCamera)
{
grabOne(out Bitmap bitmap);
result[0] = bitmap;
}
else
{
cameraVision.Open();
result = cameraVision.GetImage();
cameraVision.Close();
}
return result;
}
public static Bitmap[] CaptureAndGetCode(out List<BarcodeInfo> barcodeInfos)
{
Bitmap[] result = new Bitmap[1];
barcodeInfos = new List<BarcodeInfo>();
if (useIDCamera)
{
barcodeInfos = grabOne(out Bitmap bitmap);
result[0] = bitmap;
}
else
{
cameraVision.Open();
result = cameraVision.GetImage();
cameraVision.Close();
}
return result;
}
public static List<BarcodeInfo> GetBarCode(Bitmap bitmap)
{
return cameraVision.GetBarCode(bitmap);
}
public static void Dispose()
{
if (useIDCamera)
{
}
else
{
cameraVision?.Dispose();
}
}
public static void Open()
{
if (useIDCamera)
{
IDHIK.Instance.OpenAll();
}
else
{
cameraVision?.Open();
}
}
public static void Close()
{
if (useIDCamera)
{
IDHIK.Instance.CloseAll();
}
else
{
cameraVision?.Close();
}
}
public static string[] GetBarCodeText(List<BarcodeInfo> barcodeInfos)
{
List<string> list = new List<string>();
for (int i = 0; i < barcodeInfos.Count; i++)
{
list.Add(barcodeInfos[i].Text);
}
return list.ToArray();
}
[HandleProcessCorruptedStateExceptions]
static List<BarcodeInfo> grabOne(out Bitmap bitmap)
{
bitmap = null;
List<BarcodeInfo> barcodeInfos = new List<BarcodeInfo>();
if (string.IsNullOrEmpty(cameraName))
{
return barcodeInfos;
}
try
{
bitmap = (Bitmap)IDHIK.Instance.GrabOne(cameraName, out List<CodeInfo> cc);
if (cc != null)
{
cc.ForEach(c =>
{
barcodeInfos.Add(new BarcodeInfo()
{
Center = new PointF(c.X, c.Y),
Angle = (float)c.Orientation,
CodeType = c.CodeType,
Text = c.CodeStr
});
});
}
}
catch (Exception e)
{
LogNet.log.Error($"{cameraName}取图失败:", e);
}
return barcodeInfos;
}
}
}
...@@ -335,6 +335,8 @@ namespace BLL ...@@ -335,6 +335,8 @@ namespace BLL
/// </summary> /// </summary>
[MyConfigComment("唯一码后缀编号重置策略")] [MyConfigComment("唯一码后缀编号重置策略")]
public static MyConfig<int> REEL_ID_AutoResetStrategy; public static MyConfig<int> REEL_ID_AutoResetStrategy;
[MyConfigComment("使用扫码相机")]
public static MyConfig<bool> Func_UseIDCamera=false;
public void Save() public void Save()
{ {
config.Save(); config.Save();
......
...@@ -112,6 +112,8 @@ namespace BLL ...@@ -112,6 +112,8 @@ namespace BLL
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && !extensions[0].Control.InvokeRequired)
{ {
//使用key填充时,请处理字段开头的<OCR>字段 //使用key填充时,请处理字段开头的<OCR>字段
if(key.ContainsKey(Config.DataSource_DataKey))
{
string CleanData = key[Config.DataSource_DataKey].Replace("<OCR>", ""); string CleanData = key[Config.DataSource_DataKey].Replace("<OCR>", "");
if (key.ContainsKey(Config.DataSource_DataKey) && ExtraFileData.AllData.ContainsKey(CleanData)) if (key.ContainsKey(Config.DataSource_DataKey) && ExtraFileData.AllData.ContainsKey(CleanData))
{ {
...@@ -121,6 +123,8 @@ namespace BLL ...@@ -121,6 +123,8 @@ namespace BLL
key[d.Key] = d.Value; key[d.Key] = d.Value;
} }
} }
}
//第二次刷新界面 //第二次刷新界面
for (int i = 0; i < extensions.Count; i++) for (int i = 0; i < extensions.Count; i++)
{ {
......
此文件类型无法预览
此文件类型无法预览
...@@ -36,8 +36,7 @@ namespace SmartScan ...@@ -36,8 +36,7 @@ namespace SmartScan
LogNet.log.Debug("加载语言文件夹:" + FilePath.LANGUAGE_DIR); LogNet.log.Debug("加载语言文件夹:" + FilePath.LANGUAGE_DIR);
Asa.FaceControl.Language.LoadLanguage(BLLCommon.config.Language); Asa.FaceControl.Language.LoadLanguage(BLLCommon.config.Language);
BLLCommon.cameraVision = new Asa.Camera.VisionLib(FilePath.CONFIG_CAMERA, BLLCommon.config.EnabledCamera); Camera.LoadCamera();
LogNet.log.Info("加载相机,数量:" + BLLCommon.cameraVision.Count);
if (BLLCommon.config.EnabledIO) if (BLLCommon.config.EnabledIO)
{ {
......
...@@ -33,15 +33,13 @@ namespace SmartScan ...@@ -33,15 +33,13 @@ namespace SmartScan
{ {
if (BLLCommon.config.EnabledCamera) if (BLLCommon.config.EnabledCamera)
{ {
if (BLLCommon.cameraVision.Count <= 0) if (!Camera.IsConnected())
{ {
LogNet.log.Info("相机数量为0");
LblCameraExist.BackColor = Color.Red; LblCameraExist.BackColor = Color.Red;
return false; return false;
} }
else else
{ {
LogNet.log.Info("相机数量为" + BLLCommon.cameraVision.Count);
LblCameraExist.ForeColor = Color.Lime; LblCameraExist.ForeColor = Color.Lime;
return true; return true;
} }
......
...@@ -162,7 +162,7 @@ namespace SmartScan ...@@ -162,7 +162,7 @@ namespace SmartScan
LogNet.log.Info("=====准备退出...====="); LogNet.log.Info("=====准备退出...=====");
BLLCommon.lightSource.Close(); BLLCommon.lightSource.Close();
BLLCommon.ioModule?.Close(); BLLCommon.ioModule?.Close();
BLLCommon.cameraVision?.Dispose(); Camera.Dispose();
WebService.Close(); WebService.Close();
LogNet.log.Info("=====程序结束=====\r\n"); LogNet.log.Info("=====程序结束=====\r\n");
} }
......
...@@ -41,7 +41,7 @@ namespace SmartScan ...@@ -41,7 +41,7 @@ namespace SmartScan
LogNet.log.Info("Work Start"); LogNet.log.Info("Work Start");
if (BLLCommon.config.EnabledCamera) if (BLLCommon.config.EnabledCamera)
BLLCommon.cameraVision?.Open(); Camera.Open();
if (BLLCommon.config.TriggerOpenLight) //触发时才打开光源 if (BLLCommon.config.TriggerOpenLight) //触发时才打开光源
BLLCommon.lightSource?.TurnOff(); BLLCommon.lightSource?.TurnOff();
...@@ -59,7 +59,7 @@ namespace SmartScan ...@@ -59,7 +59,7 @@ namespace SmartScan
LogNet.log.Info("Work Stop"); LogNet.log.Info("Work Stop");
if (BLLCommon.config.EnabledCamera) if (BLLCommon.config.EnabledCamera)
BLLCommon.cameraVision?.Close(); Camera.Close();
BLLCommon.lightSource?.TurnOff(); BLLCommon.lightSource?.TurnOff();
} }
...@@ -226,7 +226,7 @@ namespace SmartScan ...@@ -226,7 +226,7 @@ namespace SmartScan
BLLCommon.lightSource.TurnOn(); BLLCommon.lightSource.TurnOn();
System.Threading.Thread.Sleep(2000); //光源打开有一个由暗变亮的过程 System.Threading.Thread.Sleep(2000); //光源打开有一个由暗变亮的过程
} }
workCodeInfo = BLLCommon.cameraVision.GetBarCode(out List<Bitmap> image); List<Bitmap> image = new List<Bitmap>(Camera.CaptureAndGetCode(out workCodeInfo));
if (image.Count > 0 && !BLL.Config.Backgrounder) picShow.Image = image[0]; if (image.Count > 0 && !BLL.Config.Backgrounder) picShow.Image = image[0];
if (image.Count > 0) if (image.Count > 0)
BLLCommon.mateEdit.CurrntBitmap = image[0]; BLLCommon.mateEdit.CurrntBitmap = image[0];
...@@ -248,7 +248,7 @@ namespace SmartScan ...@@ -248,7 +248,7 @@ namespace SmartScan
return false; return false;
Bitmap bmp = null; Bitmap bmp = null;
bmp = ObjConversion.ReadImageFile(filename); bmp = ObjConversion.ReadImageFile(filename);
workCodeInfo = BLLCommon.cameraVision.GetBarCode(bmp); workCodeInfo = Camera.GetBarCode(bmp);
Common.frmMain.Invoke(delegate () Common.frmMain.Invoke(delegate ()
{ {
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
...@@ -286,7 +286,7 @@ namespace SmartScan ...@@ -286,7 +286,7 @@ namespace SmartScan
{ {
LogNet.log.Info("Work MatchingTemplate"); LogNet.log.Info("Work MatchingTemplate");
if (workCodeInfo.Count == 0) return false; if (workCodeInfo.Count == 0) return false;
originalCodeText = BLLCommon.cameraVision.GetBarCodeText(workCodeInfo); originalCodeText = Camera.GetBarCodeText(workCodeInfo);
bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out originalCodeIsUsed); bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out originalCodeIsUsed);
BLL.MatchAnalysis.ShowResult(); BLL.MatchAnalysis.ShowResult();
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using BLL; using BLL;
using CameraVisionLib.Model;
using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Spreadsheet;
using Model; using Model;
...@@ -16,7 +18,7 @@ namespace SmartScan ...@@ -16,7 +18,7 @@ namespace SmartScan
{ {
InitializeComponent(); InitializeComponent();
Asa.FaceControl.Language.SetLanguage(this); Asa.FaceControl.Language.SetLanguage(this);
BtnCameraImage.Enabled = BLLCommon.cameraVision == null ? false : BLLCommon.cameraVision.Count > 0; BtnCameraImage.Enabled = Camera.IsConnected();
} }
public Asa.FaceControl.FacePanel GetPanel() public Asa.FaceControl.FacePanel GetPanel()
...@@ -37,12 +39,10 @@ namespace SmartScan ...@@ -37,12 +39,10 @@ namespace SmartScan
{ {
BLLCommon.lightSource.TurnOff(); BLLCommon.lightSource.TurnOff();
} }
List<BarcodeInfo> barcodeInfos;
private void BtnCameraImage_Click(object sender, EventArgs e) private void BtnCameraImage_Click(object sender, EventArgs e)
{ {
BLLCommon.cameraVision.Open(); Bitmap[] result = Camera.CaptureAndGetCode(out barcodeInfos);
Bitmap[] result = BLLCommon.cameraVision.GetImage();
BLLCommon.cameraVision.Close();
if (result.Length == 0) return; if (result.Length == 0) return;
bmp = result[0]; bmp = result[0];
LstCode.Items.Clear(); LstCode.Items.Clear();
...@@ -64,7 +64,13 @@ namespace SmartScan ...@@ -64,7 +64,13 @@ 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;
List<CameraVisionLib.Model.BarcodeInfo> info = BLLCommon.cameraVision.GetBarCode(bmp); List<CameraVisionLib.Model.BarcodeInfo> info = null;
if (Camera.useIDCamera)
{
info = barcodeInfos.ToList();
}
else
info = Camera.GetBarCode(bmp);
LstCode.Items.Clear(); LstCode.Items.Clear();
PicShow.CodeCenterClear(); PicShow.CodeCenterClear();
string[] arr = new string[info.Count]; string[] arr = new string[info.Count];
......
...@@ -55,11 +55,11 @@ namespace SmartScan ...@@ -55,11 +55,11 @@ namespace SmartScan
this.panel6 = new System.Windows.Forms.Panel(); this.panel6 = new System.Windows.Forms.Panel();
this.BtnOpenLight = new Asa.FaceControl.FaceButton(); this.BtnOpenLight = new Asa.FaceControl.FaceButton();
this.BtnSaveImage = new Asa.FaceControl.FaceButton(); this.BtnSaveImage = new Asa.FaceControl.FaceButton();
this.BtnOcrCode = new Asa.FaceControl.FaceButton();
this.BtnScanCode = new Asa.FaceControl.FaceButton(); this.BtnScanCode = new Asa.FaceControl.FaceButton();
this.BtnCloseLight = new Asa.FaceControl.FaceButton(); this.BtnCloseLight = new Asa.FaceControl.FaceButton();
this.BtnCameraImage = new Asa.FaceControl.FaceButton(); this.BtnCameraImage = new Asa.FaceControl.FaceButton();
this.BtnLocalImage = new Asa.FaceControl.FaceButton(); this.BtnLocalImage = new Asa.FaceControl.FaceButton();
this.BtnOcrCode = new Asa.FaceControl.FaceButton();
this.ImgShow = new Asa.FaceControl.FacePictureBox(); this.ImgShow = new Asa.FaceControl.FacePictureBox();
this.facePanel1.SuspendLayout(); this.facePanel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
...@@ -445,11 +445,11 @@ namespace SmartScan ...@@ -445,11 +445,11 @@ namespace SmartScan
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.panel6.Controls.Add(this.BtnOpenLight); this.panel6.Controls.Add(this.BtnOpenLight);
this.panel6.Controls.Add(this.BtnSaveImage); this.panel6.Controls.Add(this.BtnSaveImage);
this.panel6.Controls.Add(this.BtnOcrCode);
this.panel6.Controls.Add(this.BtnScanCode); this.panel6.Controls.Add(this.BtnScanCode);
this.panel6.Controls.Add(this.BtnCloseLight); this.panel6.Controls.Add(this.BtnCloseLight);
this.panel6.Controls.Add(this.BtnCameraImage); this.panel6.Controls.Add(this.BtnCameraImage);
this.panel6.Controls.Add(this.BtnLocalImage); this.panel6.Controls.Add(this.BtnLocalImage);
this.panel6.Controls.Add(this.BtnOcrCode);
this.panel6.Location = new System.Drawing.Point(6, 36); this.panel6.Location = new System.Drawing.Point(6, 36);
this.panel6.Name = "panel6"; this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(571, 236); this.panel6.Size = new System.Drawing.Size(571, 236);
...@@ -491,25 +491,6 @@ namespace SmartScan ...@@ -491,25 +491,6 @@ namespace SmartScan
this.BtnSaveImage.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.BtnSaveImage.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.BtnSaveImage.Click += new System.EventHandler(this.BtnSaveImage_Click); this.BtnSaveImage.Click += new System.EventHandler(this.BtnSaveImage_Click);
// //
// BtnOcrCode
//
this.BtnOcrCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOcrCode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnOcrCode.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnOcrCode.BorderWidth = 2;
this.BtnOcrCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOcrCode.HoldPress = false;
this.BtnOcrCode.Image = global::SmartScan.Properties.Resources.OCR;
this.BtnOcrCode.Location = new System.Drawing.Point(367, 125);
this.BtnOcrCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Name = "BtnOcrCode";
this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Size = new System.Drawing.Size(200, 105);
this.BtnOcrCode.TabIndex = 19;
this.BtnOcrCode.Text = "OCR";
this.BtnOcrCode.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.BtnOcrCode.Click += new System.EventHandler(this.BtnOcrCode_Click_1);
//
// BtnScanCode // BtnScanCode
// //
this.BtnScanCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.BtnScanCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
...@@ -583,6 +564,25 @@ namespace SmartScan ...@@ -583,6 +564,25 @@ namespace SmartScan
this.BtnLocalImage.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.BtnLocalImage.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.BtnLocalImage.Click += new System.EventHandler(this.BtnLocalImage_Click); this.BtnLocalImage.Click += new System.EventHandler(this.BtnLocalImage_Click);
// //
// BtnOcrCode
//
this.BtnOcrCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOcrCode.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(20)))), ((int)(((byte)(20)))), ((int)(((byte)(20)))));
this.BtnOcrCode.BorderStyle = Asa.FaceControl.ControlShape.Rectangle;
this.BtnOcrCode.BorderWidth = 2;
this.BtnOcrCode.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(230)))), ((int)(((byte)(230)))));
this.BtnOcrCode.HoldPress = false;
this.BtnOcrCode.Image = global::SmartScan.Properties.Resources.OCR;
this.BtnOcrCode.Location = new System.Drawing.Point(367, 125);
this.BtnOcrCode.Margin = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Name = "BtnOcrCode";
this.BtnOcrCode.Padding = new System.Windows.Forms.Padding(4);
this.BtnOcrCode.Size = new System.Drawing.Size(200, 105);
this.BtnOcrCode.TabIndex = 19;
this.BtnOcrCode.Text = "OCR";
this.BtnOcrCode.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.BtnOcrCode.Click += new System.EventHandler(this.BtnOcrCode_Click_1);
//
// ImgShow // ImgShow
// //
this.ImgShow.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.ImgShow.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
......
...@@ -24,14 +24,14 @@ namespace SmartScan ...@@ -24,14 +24,14 @@ namespace SmartScan
{ {
InitializeComponent(); InitializeComponent();
BtnOcrCode.Visible = Config.Func_EnabledOCR; BtnOcrCode.Visible = Config.Func_EnabledOCR;
if (!Config.Func_EnabledOCR) //if (!Config.Func_EnabledOCR)
BtnScanCode.Width = LstCode.Width; // BtnScanCode.Width = LstCode.Width;
if (!BtnTemplateValite.Visible) if (!BtnTemplateValite.Visible)
BtnExtractCode.Width = LstCode.Width; BtnExtractCode.Width = LstCode.Width;
LstMate.Items.AddRange(BLLCommon.mateEdit.Name); LstMate.Items.AddRange(BLLCommon.mateEdit.Name);
mateCopy = BLLCommon.mateEdit.ToCopy(); mateCopy = BLLCommon.mateEdit.ToCopy();
Language.SetLanguage(this); Language.SetLanguage(this);
BtnCameraImage.Enabled = BLLCommon.cameraVision.Count > 0; BtnCameraImage.Enabled = Camera.IsConnected();
//LstMate.SelectedFirst(); //LstMate.SelectedFirst();
} }
...@@ -215,9 +215,8 @@ namespace SmartScan ...@@ -215,9 +215,8 @@ namespace SmartScan
private void BtnCameraImage_Click(object sender, EventArgs e) private void BtnCameraImage_Click(object sender, EventArgs e)
{ {
BLLCommon.cameraVision.Open(); if (mateIndex == -1) return;
Bitmap[] result = BLLCommon.cameraVision.GetImage(); Bitmap[] result = Camera.Capture();
BLLCommon.cameraVision.Close();
if (result.Length == 0) return; if (result.Length == 0) return;
bmp = result[0]; bmp = result[0];
...@@ -248,6 +247,7 @@ namespace SmartScan ...@@ -248,6 +247,7 @@ namespace SmartScan
private void BtnScanCode_Click(object sender, EventArgs e) private void BtnScanCode_Click(object sender, EventArgs e)
{ {
if (mateIndex == -1) return;
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?"); 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(); DialogResult dialogResult = new FaceMessageBox(mateCopy[mateIndex].Name, text, MessageBoxButtons.YesNo).ShowDialog();
...@@ -255,7 +255,21 @@ namespace SmartScan ...@@ -255,7 +255,21 @@ namespace SmartScan
{ {
return; return;
} }
List<CameraVisionLib.Model.BarcodeInfo> info = BLLCommon.cameraVision.GetBarCode(bmp); List<BarcodeInfo> info = null;
if (Camera.useIDCamera)
{
Bitmap[] result = Camera.CaptureAndGetCode(out info);
if (result.Length == 0) return;
bmp = result[0];
mateCopy[mateIndex].ImagePath = "";
mateCopy[mateIndex].Image = bmp;
ImgShow.Image = bmp;
}
else
{
info = Camera.GetBarCode(bmp);
}
LstCode.Items.Clear(); LstCode.Items.Clear();
ImgShow.CodeCenterClear(); ImgShow.CodeCenterClear();
mateCopy[mateIndex].Match.Clear(); mateCopy[mateIndex].Match.Clear();
...@@ -309,10 +323,10 @@ namespace SmartScan ...@@ -309,10 +323,10 @@ namespace SmartScan
AsciiToCharReplacer asciiControl = new AsciiToCharReplacer(); AsciiToCharReplacer asciiControl = new AsciiToCharReplacer();
string[] strings = null; string[] strings = null;
string codestring = asciiControl.StringToAscii(code.Text,out strings); string codestring = asciiControl.StringToAscii(code.Text, out strings);
List<MaterialCodeMatch> match = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == code.ID); List<MaterialCodeMatch> match = mateCopy[mateIndex].Match.FindAll(s => s.CodeID == code.ID);
//如果使用新方法识别ocr,去除空格 //如果使用新方法识别ocr,去除空格
if (code.CodeType=="OCR"&&codestring== "http://localhost:8090/paddle/SelectOcrMethod") if (code.CodeType == "OCR" && codestring == "http://localhost:8090/paddle/SelectOcrMethod")
{ {
codestring = code.Text.Replace(" ", ""); codestring = code.Text.Replace(" ", "");
} }
......
...@@ -61,7 +61,7 @@ namespace SmartScan ...@@ -61,7 +61,7 @@ namespace SmartScan
List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo = new(); List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo = new();
Dictionary<string, string> workCodeKeyword;// = new(StringComparer.OrdinalIgnoreCase); Dictionary<string, string> workCodeKeyword;// = new(StringComparer.OrdinalIgnoreCase);
bool[] originalCodeIsUsed = null; bool[] originalCodeIsUsed = null;
workCodeInfo = BLLCommon.cameraVision.GetBarCode(bitmap); workCodeInfo = Camera.GetBarCode(bitmap);
if (workCodeInfo.Count == 0) if (workCodeInfo.Count == 0)
return new WebResultCode() { ErrorCode = -1, Msg = "扫码失败" }; return new WebResultCode() { ErrorCode = -1, Msg = "扫码失败" };
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!