Commit 7f4d37f8 刘韬

更新点料算法,二维码识别算法

1 个父辈 9ad615d5
......@@ -510,7 +510,17 @@ namespace OnlineStore.AutoCountClient
else {
lblXrayWork.Text = "警告:点料过程中,请勿开门";
}
foreach (var cr in CodeManager.CamErrCount)
{
if (cr.Value > 5)
{
robot.inputEquip.MoveStop = true;
lblXrayWork.Text = $"扫码相机({cr.Key})拍照连续失败,请及时处理。";
lblXrayWork.Visible = true;
robot.inputEquip.Alarm(AlarmType.SuddenStop);
break;
}
}
string canScanCode = "";
lblStatus.Text = robot.GetRunStr() + canScanCode;
......
......@@ -99,6 +99,7 @@ namespace OnlineStore.AutoCountClient
}
if (!isShow)
{
Environment.CurrentDirectory = Application.StartupPath;
XmlConfigurator.Configure();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
......
......@@ -252,7 +252,7 @@ namespace CodeLibrary
{
if (HDCodeLearnHelper.DefaultBitmap != null) {
List<CodeInfo> codeList = EyemDecode.Decoder(ref HDCodeLearnHelper.DefaultBitmap);
List<CodeInfo> codeList = EyemDecode2.Decoder(ref HDCodeLearnHelper.DefaultBitmap);
HDCodeLearnHelper.DefaultBitmap.Dispose();
ShowCode(codeList);
return;
......@@ -303,7 +303,7 @@ namespace CodeLibrary
//for (int i = 0; i < 1000; i++)
//{
Bitmap b = (Bitmap)pictureBox1.Image.Clone();
codeList = EyemDecode.Decoder(ref b);
codeList = EyemDecode2.Decoder(ref b);
b.Dispose();
Thread.Sleep(10);
//}
......
......@@ -552,7 +552,7 @@ namespace CodeLibrary
string[] strarray = code.Split(';');
if (strarray.Length == 4)
{
if (strarray[0].StartsWith("L") &&
if (//strarray[0].StartsWith("L") &&
strarray[1].StartsWith("E") &&
strarray[2].StartsWith("B"))
{
......
......@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
......@@ -12,14 +13,32 @@ using static Asa.eyemLib;
namespace CodeLibrary
{
public unsafe class EyemDecode
public unsafe class EyemDecode2
{
public static string codeType = "QR_CODE|DATA_MATRIX";
public static int Init()
{
if (!File.Exists(".\\darknet\\detect-tiny.cfg") || !File.Exists(".\\darknet\\detect-tiny.weights"))
{
throw new Exception("找不到darknet\\detect-tiny.cfg|detect-tiny.weights");
}
return eyemInitNNDataCodeModel(".\\darknet\\detect-tiny.cfg", ".\\darknet\\detect-tiny.weights", "", "");
}
static EyemDecode2()
{
Init();
}
//public static List<CodeInfo> Decoder(ref Bitmap bmap, string file = null) {
// return Decoder(ref bmap, file);
//}
/// <summary>
/// 识别图像二维码
/// </summary>
/// <param name="bmap">需要手动释放这个bitmap</param>
/// <param name="file">如果传文件的话,bmp传null</param>
/// <returns></returns>
public static List<CodeInfo> Decoder(ref Bitmap bmap,string file=null)
public static List<CodeInfo> Decoder(ref Bitmap bmap, string file = null)
{
List<CodeInfo> codelist = new List<CodeInfo>();
......@@ -32,16 +51,16 @@ namespace CodeLibrary
if (file == null)
{
Rectangle rect = new Rectangle(0, 0, bmap.Width, bmap.Height);
bitmapData = bmap.LockBits(rect, ImageLockMode.ReadOnly, bmap.PixelFormat);
bitmapData = bmap.LockBits(rect, ImageLockMode.ReadWrite, bmap.PixelFormat);
eyemImage = new EyemImage();
eyemImage.ucpImage = bitmapData.Scan0;
eyemImage.iWidth = rect.Width;
eyemImage.iHeight = rect.Height;
//eyemImage.iChannel = 0;
eyemImage.iChannels = 1;
eyemImage.iDepth = 0;
}
else {
else
{
eyemImageRead(file, -1, out eyemImage);
}
......@@ -51,14 +70,18 @@ namespace CodeLibrary
eyemRect.iYs = 0;
eyemRect.iWidth = eyemImage.iWidth;
eyemRect.iHeight = eyemImage.iHeight;
string codeType = "QR_CODE|DATA_MATRIX";//QRCode
//string codeType = "QR_CODE|DATA_MATRIX"; //QRCode
int ipNum;
EyemBarCode* tpResults;
DataCodeHandle hObject = null;
try
{
int result = eyemDetectAndDecode(eyemImage, eyemRect, "", codeType, out hObject, out tpResults, out ipNum, false, 11, 5, 128, 215);
EyemImage tpDstImg;
int result = eyemDetectAndDecodeUseNN(eyemImage, eyemRect, out hObject, out tpResults, out ipNum, out _);
// eyemImageFree(ref tpDstImg);
//hObject.Dispose();
//int result = eyemDetectAndDecode(eyemImage, eyemRect, "", codeType, out hObject, out tpResults, out ipNum, false, iBlockSize, iRangeC, iSymbolMin, iSymbolMax);
HDLogUtil.info($"eyemDetectAndDecode:{result},ipNum:{ipNum}");
if (result != 0 || ipNum == 0)
return codelist;
......@@ -70,11 +93,15 @@ namespace CodeLibrary
codelist.Add(ci);
}
}
catch (Exception ex)
{
HDLogUtil.error($"" + ex.ToString());
}
finally
{
if (hObject != null)
hObject.Dispose();
if (bitmapData!=null)
if (bitmapData != null)
bmap.UnlockBits(bitmapData);
if (file != null)
eyemImageFree(ref eyemImage);
......@@ -88,9 +115,8 @@ namespace CodeLibrary
//eyemImageFree(eyemImage.ucpImage);
return codelist;
}
/*
//释放解码句柄
private class DataCodeHandle : SafeHandleZeroOrMinusOneIsInvalid
public class DataCodeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
public DataCodeHandle() : base(true) { }
protected override bool ReleaseHandle()
......@@ -99,8 +125,30 @@ namespace CodeLibrary
}
}
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, string fileName, string strCodeType, out DataCodeHandle hObject, out EyemBarCode* tpResults, out int ipNum, bool bUseNiBlack, int iBlockSize, int iRangeC, int iSymbolMin, int iSymbolMax, double dScaleUpAndDown=1, double dToleErr = 0.5, double dMinorStep = 1.0);
private static extern int eyemDetectAndDecode(EyemImage tpImage, EyemRect tpRoi, string fileName, string strCodeType, out DataCodeHandle hObject, out EyemBarCode* tpResults, out int ipNum, bool bUseNiBlack, int iBlockSize, int iRangeC, int iSymbolMin, int iSymbolMax, double dScaleUpAndDown = 1, double dToleErr = 0.5, double dMinorStep = 1.0);
/*
* 参数说明
tpImage 输入图像,可使用”eyemImageRead“接口读取图片(需与“eyemImageFree”配合使用),也可直接创建EyemImage对象。
tpRoi 感兴趣区域,尺寸不能小于iSymbolMax。
fileName 文件名,可不填。
strCodeType 所要识别条码类型,“QRCode|DataMatrix|CODE_128”等等。
hObject 结果释放句柄,配合eyemDetectAndDecodeFree使用
tpResults 识别结果
ipNum 结果数量
bUseNiBlack 使用NiBlack二值化,默认值 false。
iBlockSize 定位块大小(奇数),略大于最大定位块(只二维码),佳世达一般设置为11。
iRangeC 搜索范围,范围越大识别越好时间也相应越长,佳世达一般设置为5。
iSymbolMin 最小二维码尺寸,默认128。
iSymbolMax 最大二维码尺寸,佳世达一般设置为215。
dScaleUpAndDown 缩放,<1表示缩小,>1表示放大,=1表示不缩放
dToleErr 最大允许误差默认50%,越小越严格但可能会识别不到。
dMinorStep 步进,默认1.0。
//返回值
-3 图像不存在
-1 内存不足
0 正常
-100 未识别到条码或参数设置不正确
*/
/// <summary>
/// 读取图像
/// </summary>
......@@ -114,23 +162,51 @@ namespace CodeLibrary
/// <summary>
/// 释放图像资源
/// </summary>
/// <param name="ipImage"></param>
/// <param name="eyemImage"></param>
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern void eyemImageFree(ref EyemImage eyemImage);
public static extern void eyemImageFree(ref EyemImage eyemImage);
//释放工具
//释放解码句柄
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern bool eyemDetectAndDecodeFree(IntPtr hObject);
//基于深度学习读码程序(仅支持QR、DataMatrix)
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemDetectAndDecodeUseNN(EyemImage tpImage, EyemRect tpRoi, out DataCodeHandle hObject, out EyemBarCode* tpResults, out int ipNum, out EyemImage tpDstImg);
//加载模型配置文件
[DllImport("eyemLib.dll", CharSet = CharSet.None, CallingConvention = CallingConvention.Cdecl)]
private static extern int eyemInitNNDataCodeModel(string detectorConfigPath, string detectorModelPath, string superResolutionConfigPath, string superResolutionModelPath);
[StructLayout(LayoutKind.Sequential)]
public struct EyemImage
{
public IntPtr ucpImage; // 地址
public int iWidth; // 图像内存 x 方向大小
public int iHeight; // 图像内存 y 方向大小
/// <summary>
/// 地址
/// </summary>
public IntPtr ucpImage;
/// <summary>
/// 图像内存 x 方向大小
/// </summary>
public int iWidth;
/// <summary>
/// 图像内存 y 方向大小
/// </summary>
public int iHeight;
/// <summary>
/// iDepth:
/// uint8_t 取值范围[0, 255], iDepth = 0(常用,解码图像一般为此种格式)
/// int8_t 取值范围[-128, 127], iDepth = 1
/// uint16_t 取值范围[0, 56635], iDepth = 2(常用,点料机图像一般为此种格式)
/// int16_t 取值范围[-32768, 32767], iDepth = 3
/// int32_t 取值范围[-2147483648, 2147483647], iDepth = 4
/// float_t 取值范围[-3.4028235E38, 3.4028235E38], iDepth = 5
/// double_t 取值范围[-1.7E-308, 1.7E+308], iDepth = 6
/// </summary>
public int iDepth;
/// <summary>
/// 彩色图 iChannels=3或4(比RGB多了Alpha通道),一般为3
/// 灰度图 iChannels = 1
/// </summary>
public int iChannels; // 图像通道数
}
[StructLayout(LayoutKind.Sequential)]
public struct EyemRect
......@@ -148,7 +224,7 @@ namespace CodeLibrary
public int iCenterY; // y坐标
public IntPtr hType; // 码类型
public IntPtr hText; // 码内容
}*/
}
}
}
......@@ -102,5 +102,6 @@ namespace OnlineStore.Common
/// </summary>
public static string UseLabel = "UseLabel";
public static string OutReelCenterX = "OutReelCenterX";
}
}
......@@ -31,8 +31,21 @@ namespace OnlineStore.DeviceLibrary
public string WorkShelfId = "";
public bool AutoSendShelfOut = false;
private int LabelWaitMS = ConfigAppSettings.GetIntValue(Setting_Init.LabelWaitMS);
private int OutReelCenterX { get
{
var x = ConfigAppSettings.GetIntValue(Setting_Init.OutReelCenterX);
if (x == 0)
{
ConfigAppSettings.SaveValue(Setting_Init.OutReelCenterX, 2623);
x = 2623;
}
return x;
}
}
public OutputEquip(string cid, OutputEquip_Config config)
{
var xxx = OutReelCenterX;
baseConfig = config;
this.DeviceID = config.Id;
this.Config = config;
......
......@@ -211,12 +211,14 @@ namespace OnlineStore.DeviceLibrary
{
if (string.IsNullOrEmpty(MoveInfo.MoveParam.WareCode))
return;
int testCount = 1;
var cc = new List<CodeInfo>();
//var filename = "need";
CodeManager.CameraScan(Name, out cc, saveone, Config.CameraName);
saveone = true;
if (cc.Count == 0)
{
testCount++;
Task.Delay(1000).Wait();
CodeManager.CameraScan(Name, out cc, saveone, Config.CameraName);
}
......@@ -224,7 +226,7 @@ namespace OnlineStore.DeviceLibrary
{
MoveInfo.MoveParam.codePointer.X = cc[0].X;
MoveInfo.MoveParam.codePointer.Y = cc[0].Y;
WorkLog("取料:识别到二维码位置:X:" + MoveInfo.MoveParam.codePointer.X + ",Y:" + MoveInfo.MoveParam.codePointer.Y, 1);
WorkLog($"取料:{testCount}次识别到二维码位置:X:" + MoveInfo.MoveParam.codePointer.X + ",Y:" + MoveInfo.MoveParam.codePointer.Y, 1);
}
//else if (cc.Count > 1) {
......@@ -232,7 +234,7 @@ namespace OnlineStore.DeviceLibrary
//}
else
{
WorkLog("取料:2次没有识别到二维码", 1);
WorkLog($"取料:{testCount}次没有识别到二维码", 1);
}
doubleplate = false;
......@@ -771,14 +773,14 @@ namespace OnlineStore.DeviceLibrary
//圆心位置x2230,y2115
var posL = false;
if (SecMoveInfo.MoveParam.codePointer.X < 2273 && SecMoveInfo.MoveParam.codePointer.Y < 1225+80)
{
posL = true;
}
if (SecMoveInfo.MoveParam.codePointer.X > 2273 && SecMoveInfo.MoveParam.codePointer.Y < 1225 - 80)
if (SecMoveInfo.MoveParam.codePointer.X > OutReelCenterX)//2623)// && SecMoveInfo.MoveParam.codePointer.Y < 1225+80)
{
posL = true;
}
//if (SecMoveInfo.MoveParam.codePointer.X > 2623 && SecMoveInfo.MoveParam.codePointer.Y < 1225 - 80)
//{
// posL = true;
//}
if (SecMoveInfo.MoveParam.codePointer.Y == 0)
{ posL = false; }
......@@ -799,13 +801,13 @@ namespace OnlineStore.DeviceLibrary
/*
* R=Y_P3
* L=Y_P4
X0
___|___
------\ / T \
XRAY出料口 ----- | L * R |-----Y0 圆心位置x2273,y1225
------/ \ B /
~~~|~~~
|
Y0
___|___
------\ / T \
XRAY出料口 ----X0- | L * R |----- 圆心位置x2623,y933
------/ \ B /
~~~|~~~
|
*/
}
else if (SecMoveInfo.IsTimeOut(120))
......
......@@ -509,9 +509,11 @@ namespace OnlineStore.DeviceLibrary
//转动线体
IOMove(IO_Type.O_ELine_InStop, IO_VALUE.LOW);
IOMove(IO_Type.O_ELine_Run, IO_VALUE.HIGH);
LogUtil.info(logName + $"step 1 O_ELine_Run:{IOValue(IO_Type.O_WLine_Run)},O_ELine_InStop:{IOValue(IO_Type.O_WLine_OutStop)}");
//等待进料检测信号
bool result = WaitIo(IO_Type.O_ELine_InCheck, IO_VALUE.HIGH, 600000, logName + "等待O_ELine_InCheck检测到料架");
LogUtil.info(logName + $"step 2 O_ELine_Run:{IOValue(IO_Type.O_WLine_Run)},O_ELine_InStop:{IOValue(IO_Type.O_WLine_OutStop)}");
if (!result)
{
......@@ -526,6 +528,7 @@ namespace OnlineStore.DeviceLibrary
//等待500毫秒后停止转动
Thread.Sleep(5000);
LogUtil.info(logName + $"step 3 O_ELine_Run:{IOValue(IO_Type.O_WLine_Run)},O_ELine_InStop:{IOValue(IO_Type.O_WLine_OutStop)}");
IOMove(IO_Type.O_ELine_Run, IO_VALUE.LOW);
......@@ -562,7 +565,7 @@ namespace OnlineStore.DeviceLibrary
internal void ShelfOutProcess(string id, string rfid)
{
string logName = Name + "料串 "+rfid+"[" + Config.AgvOutName + "->AGV ] ";
string logName = "ShelfOutProcess" + "料串 "+rfid+"[" + Config.AgvOutName + "->AGV ] ";
Task.Factory.StartNew(delegate
{
try
......@@ -575,7 +578,7 @@ namespace OnlineStore.DeviceLibrary
//出口阻挡下降,出口线体转动
IOMove(IO_Type.O_WLine_OutStop, IO_VALUE.HIGH);
IOMove(IO_Type.O_WLine_Run, IO_VALUE.HIGH);
LogUtil.info(logName + $"step 1 O_WLine_Run:{IOValue(IO_Type.O_WLine_Run)},O_WLine_OutStop:{IOValue(IO_Type.O_WLine_OutStop)}");
bool result = WaitIo(IO_Type.O_WLine_OutCheck, IO_VALUE.LOW, 60000);
if (!result)
{
......@@ -586,11 +589,13 @@ namespace OnlineStore.DeviceLibrary
LogUtil.info(logName + " 已收到 O_WLine_OutCheck=LOW ,等待13000后停止转动 ");
}
Thread.Sleep(13000);
LogUtil.info(logName + $"step 2 O_WLine_Run:{IOValue(IO_Type.O_WLine_Run)},O_WLine_OutStop:{IOValue(IO_Type.O_WLine_OutStop)}");
//停止转动 ,阻挡上升
IOMove(IO_Type.O_WLine_OutStop, IO_VALUE.LOW);
//此处判断是否需要停止接料线体
IOMove(IO_Type.O_WLine_Run, IO_VALUE.LOW);
LogUtil.info(logName + $"step 3 O_WLine_Run:{IOValue(IO_Type.O_WLine_Run)},O_WLine_OutStop:{IOValue(IO_Type.O_WLine_OutStop)}");
AgvClient.SetStatus(Config.AgvOutName, "", ClientAction.FinishLeave, ClientLevel.High, true);
Thread.Sleep(3000);
......
......@@ -145,7 +145,7 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NextMoveStep(StepEnum.XW07_InLineStop);
WorkLog("料盘处理:停止入口皮带线,中间皮带线");
IOMove(IO_Type.X_InLine_Run, IO_VALUE.LOW);
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH, 600);//皮带延时,控制料盘位置
IOMove(IO_Type.X_MLine_Run, IO_VALUE.HIGH, 550);//皮带延时,控制料盘位置
}
else if (MoveInfo.IsTimeOut(20))
{
......@@ -782,25 +782,30 @@ namespace OnlineStore.DeviceLibrary
resfile = "";
//tpDstImg = new API.EyemImage();
try
{
string countStr = "";
{
Bitmap dst = null;
int[] countStr = new int[4];
int result = 0;
CountParam.SignType type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize; ;
if (param.Sign == CountParam.SignType.AUTO)
{
result = XrayImage.GetLocalCount(fileP, 200, out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
result = XrayImage.GetLocalCount(fileP, 200, out countStr, out dst);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
}
else {
result = XrayImage.GetLocalCountIrregular(fileP, 200, type.ToString(), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
result = XrayImage.GetLocalCountIrregular(fileP, 200, type.ToString(), out countStr, out dst);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
}
if (dst != null)
{
dst.Save("ResOut\\" + Path.GetFileNameWithoutExtension(fileP) + "-Mark.png");
dst.Dispose();
}
if (countStr != null)
{
string[] array = countStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
count = (from a in array where int.TryParse(a, out _) && int.Parse(a) > 0 select int.Parse(a)).FirstOrDefault();
count = (from a in countStr where a > 0 select a).FirstOrDefault();
}
else {
count = 0;
......@@ -832,25 +837,30 @@ namespace OnlineStore.DeviceLibrary
//tpDstImg = new API.EyemImage();
try
{
string countStr = "";
Bitmap dst = null;
int[] countStr = new int[4];
int result = 0;
CountParam.SignType type = param.Sign;
int threshold = param.Threshold;
int windowsize = param.WindowSize; ;
if (param.Sign == CountParam.SignType.AUTO)
{
result = XrayImage.GetLocalCount(eyemImage, 200,Path.GetFileNameWithoutExtension(fileP), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
result = XrayImage.GetLocalCount(eyemImage, 250,Path.GetFileNameWithoutExtension(fileP), out countStr, out dst);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCount 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
}
else
{
result = XrayImage.GetLocalCountIrregular(eyemImage, 200,Path.GetFileNameWithoutExtension(fileP), type.ToString(), out countStr, out _);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + countStr + "】");
result = XrayImage.GetLocalCountIrregular(eyemImage, 250,Path.GetFileNameWithoutExtension(fileP), type.ToString(), out countStr, out dst);
LogUtil.info("GetCountResult " + type + " 调用 GetLocalCountIrregular 【" + fileP + "】【" + threshold + "】【" + windowsize + "】,返回【" + result + "】,结果【" + string.Join(",", countStr) + "】");
}
if (dst != null)
{
dst.Save("ResOut\\" + Path.GetFileNameWithoutExtension(fileP) + "-Mark.png");
dst.Dispose();
}
if (countStr != null)
{
string[] array = countStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
count = (from a in array where int.TryParse(a, out _) && int.Parse(a) > 0 select int.Parse(a)).FirstOrDefault();
count = (from a in countStr where a > 0 select a).FirstOrDefault();
}
else
{
......
......@@ -100,12 +100,16 @@ namespace OnlineStore.DeviceLibrary
}
private static int ScanCount = 0;
private static int codeCount = ConfigAppSettings.GetIntValue(Setting_Init.CodeCount);
public static Dictionary<string, int> CamErrCount = new Dictionary<string, int>();
public static List<string> CameraScan(string deviceName, params string[] cameraList) {
return CameraScan(deviceName, out _, true, cameraList);
}
[HandleProcessCorruptedStateExceptions]
public static List<string> CameraScan(string deviceName, out List<CodeInfo> ccall, bool nosave,params string[] cameraList)
{
if (!CamErrCount.ContainsKey(deviceName))
CamErrCount.Add(deviceName, 0);
List<string> codeList = new List<string>();
List<CodeInfo> cc;
ccall = new List<CodeInfo>();
......@@ -140,14 +144,16 @@ namespace OnlineStore.DeviceLibrary
ho_Image = Camera._cam.CaptureOnImage(cameraName, out bmp);
if (ho_Image == null)
{
CamErrCount[deviceName]++;
LogUtil.error(deviceName + " 【" + cameraName + "】第2次取图片失败[" + Camera._cam.ErrInfo + "],关闭相机");
continue;
}
}
CamErrCount[deviceName] = 0;
LogUtil.debug(deviceName + " 【" + cameraName + "】取图片完成,开始扫码");
string r = "";
List<CodeInfo> tlci = EyemDecode.Decoder(ref bmp);
List<CodeInfo> tlci = EyemDecode2.Decoder(ref bmp);
foreach (CodeInfo code in tlci) {
LogUtil.info(deviceName + " 【" + cameraName + "】[eyemDecode]" + code.CodeType + "(X: " + code.X + ",Y: " + code.Y + ") " + code.CodeStr);
......@@ -302,9 +308,9 @@ namespace OnlineStore.DeviceLibrary
foreach (string code in codes)
{
string[] strarray = code.Split(';');
if (strarray.Length == 4)
if (strarray.Length >= 4)
{
if (strarray[0].StartsWith("L") &&
if (//strarray[0].StartsWith("L") &&
strarray[1].StartsWith("E") &&
strarray[2].StartsWith("B"))
{
......@@ -391,7 +397,7 @@ namespace OnlineStore.DeviceLibrary
}
code = ReplaceCode(code);
if (String.IsNullOrEmpty(code))
if (string.IsNullOrEmpty(code))
{
return "";
}
......@@ -406,10 +412,11 @@ namespace OnlineStore.DeviceLibrary
string[] codearray = ReplaceCode(cc).Split(';');
if (codearray.Length >= 4)
{
if (codearray[0].StartsWith("L") &&
if (//codearray[0].StartsWith("L") &&
codearray[1].StartsWith("E") &&
codearray[2].StartsWith("B") &&
codearray[2].Length >= 13)
codearray[2].StartsWith("B")
//&& codearray[2].Length >= 13
)
// if (codearray[2].StartsWith("B") && codearray[2].Length >= 13 && codearray[3].StartsWith("R"))
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!