Commit 7a8e3a3a 刘韬

后天模式 reelid转换异常的问题

1 个父辈 f9bd0599
using Asa.FaceControl; using Asa.FaceControl;
using DocumentFormat.OpenXml.Drawing.Charts;
using Model; using Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
...@@ -98,11 +97,12 @@ namespace BLL ...@@ -98,11 +97,12 @@ namespace BLL
// 定义事件 // 定义事件
protected virtual void OnKeySet(string templateName,string[] originalCode, Dictionary<string, string> key, bool hasMatch) protected virtual void OnKeySet(string templateName, string[] originalCode, Dictionary<string, string> key, bool hasMatch)
{ {
extension.set(templateName , originalCode, key, hasMatch); extension.set(templateName, originalCode, key, hasMatch);
} }
public Dictionary<string, string> GetUIKeywords() { public Dictionary<string, string> GetUIKeywords()
{
return extension.GetUIKeywords(); return extension.GetUIKeywords();
} }
protected virtual void CheckText(string text) protected virtual void CheckText(string text)
...@@ -280,7 +280,7 @@ namespace BLL ...@@ -280,7 +280,7 @@ namespace BLL
if (findOk) if (findOk)
{ {
// 添加或替换自增ID // 添加或替换自增ID
if (!string.IsNullOrEmpty(config.ReelIDKeyWord) && isdisplay) if (!string.IsNullOrEmpty(config.ReelIDKeyWord) && isdisplay)
{ {
var Reelidstr = GetReelid(); var Reelidstr = GetReelid();
...@@ -335,9 +335,9 @@ namespace BLL ...@@ -335,9 +335,9 @@ namespace BLL
// } // }
if (extensions != null && !extensions[0].Control.InvokeRequired) if (extensions != null && extensions.Count > 0 && !extensions[0].Control.InvokeRequired)
{ {
LogNet.log.Info($"OnKeySet3"); LogNet.log.Info($"OnKeySet3");
OnKeySet(templateName, originalCode, key, hasMatch); OnKeySet(templateName, originalCode, key, hasMatch);
...@@ -424,7 +424,7 @@ namespace BLL ...@@ -424,7 +424,7 @@ namespace BLL
LogNet.log.Error("GetHttpReelID:" + errmsg); LogNet.log.Error("GetHttpReelID:" + errmsg);
return false; return false;
} }
LogNet.log.Error("GetHttpReelID:true" ); LogNet.log.Error("GetHttpReelID:true");
//key["ReelID"] = newid; //key["ReelID"] = newid;
} }
if (extensions != null && extensions.Count > 0 && !extensions[0].Control.InvokeRequired) if (extensions != null && extensions.Count > 0 && !extensions[0].Control.InvokeRequired)
...@@ -484,12 +484,12 @@ namespace BLL ...@@ -484,12 +484,12 @@ namespace BLL
private string GetReelid() private string GetReelid()
{ {
LogNet.log.Debug("Enter GetReelid Method"); LogNet.log.Info("Enter GetReelid Method");
if (extensions != null) //if (extensions != null)
{ //{
int idIndex = extensions.FindIndex(match => match.Key == config.ReelIDKeyWord); // int idIndex = extensions.FindIndex(match => match.Key == config.ReelIDKeyWord);
if (idIndex == -1) return ""; // if (idIndex == -1) return "";
} //}
// 读取参数 // 读取参数
string matchPattern = config.ReelIDMatch; string matchPattern = config.ReelIDMatch;
...@@ -498,7 +498,7 @@ namespace BLL ...@@ -498,7 +498,7 @@ namespace BLL
// 处理字符类型关键字 // 处理字符类型关键字
List<string> characterTypeKeywords = ParseCharacterTypeKeywords(); List<string> characterTypeKeywords = ParseCharacterTypeKeywords();
LogNet.log.Debug($"字符类型关键字: {string.Join(", ", characterTypeKeywords)}"); LogNet.log.Info($"字符类型关键字: {string.Join(", ", characterTypeKeywords)}");
// 解析模板中的所有关键字 // 解析模板中的所有关键字
string[] keys = ObjConversion.StrGetKey(matchPattern); string[] keys = ObjConversion.StrGetKey(matchPattern);
...@@ -618,14 +618,14 @@ namespace BLL ...@@ -618,14 +618,14 @@ namespace BLL
} }
return reelID; return reelID;
} }
private void GetHttpReelID(object sender, EventArgs e) private void GetHttpReelID(object sender, EventArgs e)
{ {
updatereelid(lastkey, out _); updatereelid(lastkey, out _);
LogNet.log.Info($"updatereelid GetHttpReelID"); LogNet.log.Info($"updatereelid GetHttpReelID");
} }
private void BtnSkip_Click(object sender, EventArgs e) private void BtnSkip_Click(object sender, EventArgs e)
{ {
string title = Language.Dialog("Notice", "提示"); string title = Language.Dialog("Notice", "提示");
string msg = Language.Dialog("SkipOperation", "是否跳过此操作?"); string msg = Language.Dialog("SkipOperation", "是否跳过此操作?");
bool result = MessageboxNeo.Show(title, msg, "NEO SCAN", true); bool result = MessageboxNeo.Show(title, msg, "NEO SCAN", true);
...@@ -633,7 +633,7 @@ namespace BLL ...@@ -633,7 +633,7 @@ namespace BLL
{ {
lastKeys = null; lastKeys = null;
BLLCommon.extension.labelText = Language.Dialog("Waiting", "等待中"); BLLCommon.extension.labelText = Language.Dialog("Waiting", "等待中");
} }
} }
public void CheckClear() public void CheckClear()
{ {
...@@ -665,9 +665,9 @@ namespace BLL ...@@ -665,9 +665,9 @@ namespace BLL
} }
return keyValues; return keyValues;
} }
private void PrintLabel(Dictionary<string,string> printKey) private void PrintLabel(Dictionary<string, string> printKey)
{ {
LogNet.log.Info("Enter PrintLabel Method: "+ JsonConvert.SerializeObject(printKey)); LogNet.log.Info("Enter PrintLabel Method: " + JsonConvert.SerializeObject(printKey));
if (printKey == null) return; if (printKey == null) return;
...@@ -722,7 +722,7 @@ namespace BLL ...@@ -722,7 +722,7 @@ namespace BLL
} }
} }
#endregion #endregion
Printing?.Invoke(printKey); Printing?.Invoke(printKey);
bool close = ConfigHelper.Config.Get("isprinclose", false); bool close = ConfigHelper.Config.Get("isprinclose", false);
...@@ -852,7 +852,7 @@ namespace BLL ...@@ -852,7 +852,7 @@ namespace BLL
{ {
LogNet.log.Error($"替换数据时出错:{ex.Message}"); LogNet.log.Error($"替换数据时出错:{ex.Message}");
} }
} }
//private void GetDataButtonClick(object sender, EventArgs e) //private void GetDataButtonClick(object sender, EventArgs e)
//{ //{
......
...@@ -145,10 +145,10 @@ namespace BLL ...@@ -145,10 +145,10 @@ namespace BLL
mateName = ""; mateName = "";
keyword = new Dictionary<string, string>(); keyword = new Dictionary<string, string>();
LogNet.log.Info($"code数量:{code.Count}"); LogNet.log.Info($"读取到条码数量:{code.Count}");
code.ForEach((c) => code.ForEach((c) =>
{ {
LogNet.log.Info($"扫描到 {c.Angle}, {c.CodeType},{c.Text}"); LogNet.log.Info($"读取到条码 [{c.Center},R:{c.Angle}]{c.CodeType}: {c.Text}");
}); });
MatchAnalysis.StartNewAnalysis(code); MatchAnalysis.StartNewAnalysis(code);
if (Config.Func_EnabledOCR) if (Config.Func_EnabledOCR)
......
...@@ -22,7 +22,7 @@ namespace SmartScan ...@@ -22,7 +22,7 @@ namespace SmartScan
//this.Height = 738; //this.Height = 738;
this.Top = 15; this.Top = 15;
this.Left = 0; this.Left = 0;
WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务 //WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
LogNet.log = log4net.LogManager.GetLogger("SmartScan"); LogNet.log = log4net.LogManager.GetLogger("SmartScan");
} }
......
...@@ -310,28 +310,42 @@ namespace SmartScan.PlusSettingFrm ...@@ -310,28 +310,42 @@ namespace SmartScan.PlusSettingFrm
if (isvaor) if (isvaor)
{ {
bool isbarcode = true;
if (codeType.StartsWith("QR Code")) if (codeType.StartsWith("QR Code"))
{ {
int deg = Angle; int deg = Angle;
deg += 90; deg += 90;
if (deg > 360) if (deg > 360)
deg = deg - 360; deg = deg - 360;
angle = ScanningCameraAngle(deg,0); angle = ScanningCameraAngle(deg, 0);
isbarcode = false;
LogUtil.info($"QR Code转换后角度,Angle:{Angle}, deg:{angle}");
Angle = angle;
} }
else if (codeType.StartsWith("Data Matrix")) else if (codeType.StartsWith("Data Matrix"))
{ {
angle = ScanningCameraAngle(Angle, 0); int deg = Angle;
angle = ScanningCameraAngle(deg, 0);
isbarcode = false;
LogUtil.info($"Data Matrix转换后角度,Angle:{Angle}, deg:{angle}");
Angle = angle;
}
//Angle = Angle + 270;
if (isbarcode)
{
var dc1 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle, 50), centrality);
var dc2 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle + 180, 50), centrality);
if (dc2 > dc1)
Angle = Angle + 180;
if (Angle > 360)
Angle = Angle - 360;
LogUtil.info($"结合盘心计算后, dc1:{dc1}, dc2:{dc2}, deg:{Angle}");
}
else
{
LogUtil.info($"二维码转换后角度, deg:{Angle}");
} }
Angle = Angle + 270;
var dc1 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle, 50), centrality);
var dc2 = LabelingPosition.distance(LabelingPosition.PointWithAngle(lable, Angle + 180, 50), centrality);
//if (dc2 > dc1)
// Angle = Angle + 180;
if (Angle > 360)
Angle = Angle - 360;
LogUtil.info($"结合盘心计算后, dc1:{dc1}, dc2:{dc2}, deg:{Angle}");
angle = Angle + 83 + labelangle; angle = Angle + 83 + labelangle;
if (angle > 360) if (angle > 360)
...@@ -362,7 +376,7 @@ namespace SmartScan.PlusSettingFrm ...@@ -362,7 +376,7 @@ namespace SmartScan.PlusSettingFrm
{ {
angle = 360 - angles + rotationAngle; angle = 360 - angles + rotationAngle;
} }
angle += 90; angle -= 90;
if (angle >= 360) if (angle >= 360)
{ {
angle -= 360; angle -= 360;
......
...@@ -267,7 +267,7 @@ namespace SmartScan ...@@ -267,7 +267,7 @@ namespace SmartScan
BLLCommon.mateEdit.CurrntBitmap = DeepClone(bitmap); BLLCommon.mateEdit.CurrntBitmap = DeepClone(bitmap);
bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch); bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch);
LogNet.log.Info("模板匹配结果:" + rtn); LogNet.log.Info("模板匹配结果1:" + rtn);
WebResultCode webResultCode = null; WebResultCode webResultCode = null;
Dictionary<string, string> keys = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); Dictionary<string, string> keys = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (var item in workCodeKeyword) foreach (var item in workCodeKeyword)
...@@ -278,6 +278,7 @@ namespace SmartScan ...@@ -278,6 +278,7 @@ namespace SmartScan
if (!BLLCommon.extension.SetKey(mateName,null, keys, rtn, out string errmsg)) if (!BLLCommon.extension.SetKey(mateName,null, keys, rtn, out string errmsg))
{ {
webResultCode = new WebResultCode() { ErrorCode = -2, Msg = errmsg }; webResultCode = new WebResultCode() { ErrorCode = -2, Msg = errmsg };
LogNet.log.Info("模板匹配结果2:" + JsonConvert.SerializeObject(webResultCode));
} }
if (webResultCode != null || !rtn) if (webResultCode != null || !rtn)
...@@ -326,7 +327,9 @@ namespace SmartScan ...@@ -326,7 +327,9 @@ namespace SmartScan
{ {
result.Add(new KeyValuePair<string, string>(wc.Key, wc.Value)); result.Add(new KeyValuePair<string, string>(wc.Key, wc.Value));
} }
return new WebResultCode() { workCodeKeyword = result, workCodeInfo = workCodeInfo }; webResultCode = new WebResultCode() { workCodeKeyword = result, workCodeInfo = workCodeInfo };
LogNet.log.Info("模板匹配结果2:" + JsonConvert.SerializeObject(webResultCode));
return webResultCode;
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -360,6 +363,7 @@ namespace SmartScan ...@@ -360,6 +363,7 @@ namespace SmartScan
} }
public WebResultCode ProcessBitmaps(BitmapData bitmapData) public WebResultCode ProcessBitmaps(BitmapData bitmapData)
{ {
LogNet.log.Info("====开始WebCall匹配=========================");
BLLCommon.mateEdit.CurrntBitmap?.Dispose(); BLLCommon.mateEdit.CurrntBitmap?.Dispose();
Bitmap bitmap = null; Bitmap bitmap = null;
MemoryStream stream = null; MemoryStream stream = null;
...@@ -450,7 +454,9 @@ namespace SmartScan ...@@ -450,7 +454,9 @@ namespace SmartScan
} }
if (!BLLCommon.extension.SetKey(mateName,null, keys, rtn, out string errmsg)) if (!BLLCommon.extension.SetKey(mateName,null, keys, rtn, out string errmsg))
{ {
return new WebResultCode() { ErrorCode = -2, Msg = errmsg }; var webResultCode1 = new WebResultCode() { ErrorCode = -2, Msg = errmsg };
LogNet.log.Info("模板匹配结果: " + JsonConvert.SerializeObject(webResultCode1));
return webResultCode1;
} }
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>(); List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
workCodeKeyword = WebserverReplaceData(keys); workCodeKeyword = WebserverReplaceData(keys);
...@@ -466,7 +472,9 @@ namespace SmartScan ...@@ -466,7 +472,9 @@ namespace SmartScan
IsCodeUsed = aMatch.IsCodeUsed IsCodeUsed = aMatch.IsCodeUsed
}; };
LogNet.log.Info($"返回坐标及角度X={newPosition.X};Y={newPosition.Y};角度={newPosition.Angle}"); LogNet.log.Info($"返回坐标及角度X={newPosition.X};Y={newPosition.Y};角度={newPosition.Angle}");
return new WebResultCode() { workCodeKeyword = result, workCodeInfo = workCodeInfo, PositionAngle = newPosition }; var webResultCode = new WebResultCode() { workCodeKeyword = result, workCodeInfo = workCodeInfo, PositionAngle = newPosition };
LogNet.log.Info("模板匹配结果: " + JsonConvert.SerializeObject(webResultCode));
return webResultCode;
} }
catch (Exception ex) catch (Exception ex)
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!