/// <summary> /// 条码信息类构造函数 /// </summary> /// <param name="image">识别出条码的图片</param> /// <param name="info">条形码信息</param> /// <param name="hasBarcode">构造函数是否含有条码信息</param> /// <param name="cameraIndex">相机序列</param> internal BarCodeDescribe(Bitmap image, MvCodeInfo info, bool hasBarcode, int cameraIndex) { this.cameraIndex = cameraIndex; _GrabImage = image; if (info != null) { if (hasBarcode) { _Code = new String(info.Code, 0, info.CodeLen); } else { _Code = string.Empty; } _Regions.Add(info.Region.PtArray); _Type = info.Type; this._Valid = true; _Exception = DetectExceptionType.NoExceptionType; } else { _Code = String.Empty; _Regions.Clear(); _Type = 0; this._Valid = false; _Exception = DetectExceptionType.NULLCodeExceptionType; } _ExtMessageInfo = null; }
/// <summary> /// 检查并捕获条码数据 /// </summary> /// <param name="item">条码信息</param> /// <param name="result">条码捕获结果</param> /// <returns>条码检测结果</returns> public bool CheckAndCatchBarcode(MvCodeInfo item, ref List <string> result, MvBarCodeGlobalVar.BarcodeRuleType barcodeType) { // 检查条形码有效性 if (item.Valid != 0x01ff) { return(false); } string tmp = new string(item.Code, 0, item.CodeLen); // 校验一维码字符的有效性 if (!CheckBarCodeCharacter(tmp)) { return(false); } //韵达包裹条码 if (MvBarCodeGlobalVar.BarcodeRuleType.yundaCode == barcodeType) { // 检查条形码长度 if (!CheckCodeLen(item.CodeLen)) { return(false); } } //韵达上一站和下一站条码 if (MvBarCodeGlobalVar.BarcodeRuleType.yundaSiteCode == barcodeType) { // 检查条形码长度 if ((item.CodeLen == 0x06 || item.CodeLen == 0x0b) == false) { return(false); } } // 捕获条码数据 if (result.IndexOf(tmp) == -1) { result.Add(tmp); return(true); } return(false); }