Commit 68183dbb 王海洋

将物料模板识别区域用数字标识

1 个父辈 e503d6e7
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
</startup> </startup>
<appSettings> <appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" /> <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings> </appSettings>
<system.serviceModel> <system.serviceModel>
<bindings> <bindings>
...@@ -44,5 +45,16 @@ ...@@ -44,5 +45,16 @@
</dependentAssembly> </dependentAssembly>
</assemblyBinding> </assemblyBinding>
</runtime> </runtime>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
...@@ -44,6 +44,7 @@ namespace SmartScan ...@@ -44,6 +44,7 @@ namespace SmartScan
public static FrmMain mon_frmMain; public static FrmMain mon_frmMain;
public FrmMain() public FrmMain()
{ {
//成静态变量赋值为本窗体 //成静态变量赋值为本窗体
//kmon //kmon
//2025-6-24 //2025-6-24
...@@ -62,6 +63,8 @@ namespace SmartScan ...@@ -62,6 +63,8 @@ namespace SmartScan
// wpf更新字体 // wpf更新字体
UpdateNS_VericalMenuControl(); UpdateNS_VericalMenuControl();
//初始化图片界面 //初始化图片界面
//先注释
//kmon
InitializeImageControls(); InitializeImageControls();
// 添加窗体大小调整事件 // 添加窗体大小调整事件
this.Resize += YourWinFormClass_Resize; this.Resize += YourWinFormClass_Resize;
......
...@@ -26,7 +26,7 @@ namespace SmartScan ...@@ -26,7 +26,7 @@ namespace SmartScan
private bool isTouch = false; private bool isTouch = false;
private readonly FacePictureBox picShow; private readonly FacePictureBox picShow;
private readonly FaceButton btnMatchedName; private readonly FaceButton btnMatchedName;
//private readonly System.Windows.Forms.Panel wpfImagePanel;
public List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo; public List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo;
public Dictionary<string, string> workCodeKeyword; public Dictionary<string, string> workCodeKeyword;
public string[] originalCodeText; public string[] originalCodeText;
...@@ -39,7 +39,7 @@ namespace SmartScan ...@@ -39,7 +39,7 @@ namespace SmartScan
{ {
picShow = (FacePictureBox)Common.frmMain.Controls["PicShow"]; picShow = (FacePictureBox)Common.frmMain.Controls["PicShow"];
btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"]; btnMatchedName = (FaceButton)Common.frmMain.Controls["BtnMatchedName"];
//wpfImagePanel = Common.frmMain.Controls.Find("wpf_image", true)[0] as System.Windows.Forms.Panel;
} }
...@@ -481,6 +481,34 @@ namespace SmartScan ...@@ -481,6 +481,34 @@ namespace SmartScan
Bitmap bmp = null; Bitmap bmp = null;
bmp = ObjConversion.ReadImageFile(filename); bmp = ObjConversion.ReadImageFile(filename);
workCodeInfo = Camera.GetBarCode(bmp); workCodeInfo = Camera.GetBarCode(bmp);
//在图片画出识别的二维码
//kmon
//2025-6-25
int contenI = 1;
workCodeInfo.ForEach(info =>
{
//原本是画框,角度不对
//PointF[] points = GetRotatedRectanglePoints(info.Center, info.Size.Width, info.Size.Height, info.Angle+90);
//using (Pen pen = new Pen(Color.Red, 2))
//{
//System.Drawing.Graphics g = Graphics.FromImage(bmp);
//g.DrawLines(Pens.Red, points);
//}
//修改为写数字
using (System.Drawing.Graphics g = Graphics.FromImage(bmp))
{
string str = contenI.ToString();
Font font = new Font("Arial", 40);
SizeF textSize=g.MeasureString(str, font);
g.DrawString(str, font, Brushes.Red, info.Center);
}
contenI++;
});
Common.frmMain.Invoke(delegate () Common.frmMain.Invoke(delegate ()
{ {
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
...@@ -504,6 +532,34 @@ namespace SmartScan ...@@ -504,6 +532,34 @@ namespace SmartScan
LogNet.log.Info("条码个数:" + workCodeInfo.Count); LogNet.log.Info("条码个数:" + workCodeInfo.Count);
} }
//根据中心点取四个角的坐标
//kmon
//2025-6-25
//private PointF[] GetRotatedRectanglePoints(PointF center, float length, float width, float angle)
//{
// // 将角度转换为弧度
// float radians =(float) (angle * (Math.PI / 4));
// float halfLength = length / 2;
// float halfWidth = width / 2;
// PointF[] points = new PointF[4];
// points[0] = new PointF(center.X + halfLength, center.Y - halfWidth); // 左上角
// points[1] = new PointF(center.X + halfLength, center.Y + halfWidth); // 右下角
// points[2] = new PointF(center.X - halfLength, center.Y + halfWidth); // 左下角
// points[3] = new PointF(center.X - halfLength, center.Y - halfWidth); // 右上角
// // 应用旋转变换
// PointF[] rotatedPoints = new PointF[4];
// for (int i = 0; i < points.Length; i++)
// {
// float dx = points[i].X - center.X;
// float dy = points[i].Y - center.Y;
// float newX = center.X + (dx * (float)Math.Cos(radians) - dy * (float)Math.Sin(radians));
// float newY = center.Y + (dx * (float)Math.Sin(radians) + dy * (float)Math.Cos(radians));
// rotatedPoints[i] = new PointF(newX, newY);
// }
// return rotatedPoints;
//}
// 新增方法:将Bitmap显示在WPF控件中 // 新增方法:将Bitmap显示在WPF控件中
private void DisplayBitmapInWpfControl(Bitmap bitmap) private void DisplayBitmapInWpfControl(Bitmap bitmap)
{ {
...@@ -645,6 +701,8 @@ namespace SmartScan ...@@ -645,6 +701,8 @@ namespace SmartScan
if (!BLL.Config.Backgrounder) if (!BLL.Config.Backgrounder)
picShow.AddCodeCenter(center); picShow.AddCodeCenter(center);
System.Windows.Forms.Application.DoEvents(); System.Windows.Forms.Application.DoEvents();
} }
public bool MatchingTemplate() public bool MatchingTemplate()
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Asa.FaceControl; using Asa.FaceControl;
using BLL; using BLL;
using CameraVisionLib.Model; using CameraVisionLib.Model;
using DocumentFormat.OpenXml.EMMA;
using Model; using Model;
using SmartScan.SetControl.WPF.Model; using SmartScan.SetControl.WPF.Model;
using System; using System;
...@@ -90,7 +91,24 @@ namespace SmartScan.SetControl.WPF ...@@ -90,7 +91,24 @@ namespace SmartScan.SetControl.WPF
{ {
if (System.IO.File.Exists(iamgepath)) if (System.IO.File.Exists(iamgepath))
{ // 加载并显示图像 { // 加载并显示图像
ImgShow.Image = ObjConversion.ReadImageFile(iamgepath);
var bitMap= (Bitmap)ObjConversion.ReadImageFile(iamgepath);
int contenI = 1;
mateCopy[mateIndex].Code.ForEach(codeInfo =>
{
PointF ConterPoint;
using (System.Drawing.Graphics g = Graphics.FromImage(bitMap))
{
ConterPoint = new PointF(codeInfo.CenterX,codeInfo.CenterY);
string str = contenI.ToString();
Font font = new Font("Arial", 20);
SizeF textSize = g.MeasureString(str, font);
g.DrawString(str, font, System.Drawing.Brushes.Red, ConterPoint);
}
contenI++;
});
ImgShow.Image = bitMap;
// 清除并填充条码列表 // 清除并填充条码列表
codeItems.Clear(); codeItems.Clear();
...@@ -101,6 +119,11 @@ namespace SmartScan.SetControl.WPF ...@@ -101,6 +119,11 @@ namespace SmartScan.SetControl.WPF
if (data3.Items.Count > 0) if (data3.Items.Count > 0)
data3.SelectedIndex = -1; data3.SelectedIndex = -1;
bmp = (Bitmap)ImgShow.Image; bmp = (Bitmap)ImgShow.Image;
//给条码加上识别数字
//kmon
//2025-6-25
} }
else else
{ {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!