Commit 68183dbb 王海洋

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

1 个父辈 e503d6e7
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="90000000" maxBufferPoolSize="90000000" maxBufferSize="90000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas maxStringContentLength="90000000" maxArrayLength="90000000" maxBytesPerRead="90000000" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="90000000" maxBufferPoolSize="90000000" maxBufferSize="90000000" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:01:00" sendTimeout="00:01:00">
<readerQuotas maxStringContentLength="90000000" maxArrayLength="90000000" maxBytesPerRead="90000000" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
......@@ -44,5 +45,16 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<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>
\ No newline at end of file
......@@ -44,6 +44,7 @@ namespace SmartScan
public static FrmMain mon_frmMain;
public FrmMain()
{
//成静态变量赋值为本窗体
//kmon
//2025-6-24
......@@ -62,6 +63,8 @@ namespace SmartScan
// wpf更新字体
UpdateNS_VericalMenuControl();
//初始化图片界面
//先注释
//kmon
InitializeImageControls();
// 添加窗体大小调整事件
this.Resize += YourWinFormClass_Resize;
......
......@@ -26,7 +26,7 @@ namespace SmartScan
private bool isTouch = false;
private readonly FacePictureBox picShow;
private readonly FaceButton btnMatchedName;
//private readonly System.Windows.Forms.Panel wpfImagePanel;
public List<CameraVisionLib.Model.BarcodeInfo> workCodeInfo;
public Dictionary<string, string> workCodeKeyword;
public string[] originalCodeText;
......@@ -39,7 +39,7 @@ namespace SmartScan
{
picShow = (FacePictureBox)Common.frmMain.Controls["PicShow"];
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
Bitmap bmp = null;
bmp = ObjConversion.ReadImageFile(filename);
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 ()
{
if (!BLL.Config.Backgrounder)
......@@ -504,6 +532,34 @@ namespace SmartScan
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控件中
private void DisplayBitmapInWpfControl(Bitmap bitmap)
{
......@@ -644,7 +700,9 @@ namespace SmartScan
center[i] = workCodeInfo[i].Center;
if (!BLL.Config.Backgrounder)
picShow.AddCodeCenter(center);
System.Windows.Forms.Application.DoEvents();
System.Windows.Forms.Application.DoEvents();
}
public bool MatchingTemplate()
......
......@@ -2,6 +2,7 @@
using Asa.FaceControl;
using BLL;
using CameraVisionLib.Model;
using DocumentFormat.OpenXml.EMMA;
using Model;
using SmartScan.SetControl.WPF.Model;
using System;
......@@ -90,7 +91,24 @@ namespace SmartScan.SetControl.WPF
{
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();
......@@ -101,6 +119,11 @@ namespace SmartScan.SetControl.WPF
if (data3.Items.Count > 0)
data3.SelectedIndex = -1;
bmp = (Bitmap)ImgShow.Image;
//给条码加上识别数字
//kmon
//2025-6-25
}
else
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!