@@ -15,6 +15,7 @@ using System.Security.Cryptography.Xml; | |||
using System.Text; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Windows.Forms; | |||
using static Org.BouncyCastle.Math.EC.ECCurve; | |||
namespace MaiMuControl.Device.CamDev.IKapCamera | |||
@@ -908,6 +909,7 @@ namespace MaiMuControl.Device.CamDev.IKapCamera | |||
{ | |||
try | |||
{ | |||
WriteSysEditLog("采集", "FrameReady"); | |||
Stopwatch stopwatch = Stopwatch.StartNew(); | |||
stopwatch.Start(); | |||
int nCurFrameIndex = 0; | |||
@@ -927,10 +929,12 @@ namespace MaiMuControl.Device.CamDev.IKapCamera | |||
{ | |||
CopyMemory(m_pUserBuffer, hPtr, _nBufferSize); | |||
Mat mat = new Mat(imgHeight, imgWidth, MatType.CV_8UC3, m_pUserBuffer); | |||
lock (frameQueue) | |||
frameQueue.Enqueue( mat.Clone()); | |||
frameQueue.Enqueue(new Mat(imgHeight, imgWidth, MatType.CV_8UC3, m_pUserBuffer)); | |||
//Mat mat = new Mat(imgHeight, imgWidth, MatType.CV_8UC3, m_pUserBuffer); | |||
//lock (frameQueue) | |||
// frameQueue.Enqueue( mat.Clone()); | |||
//PhotoNumCacheEvent?.BeginInvoke(frameQueue.Count, null, null); | |||
} | |||
//lock (m_mutexImage) | |||
@@ -954,7 +958,8 @@ namespace MaiMuControl.Device.CamDev.IKapCamera | |||
} | |||
//m_nCurFrameIndex++; | |||
//m_nCurFrameIndex = m_nCurFrameIndex % m_nFrameCount; | |||
stopwatch.Stop(); | |||
stopwatch.Stop(); | |||
WriteSysEditLog("采集", $"FrameGet({frameQueue.Count})-time:{stopwatch.ElapsedMilliseconds}"); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -973,6 +978,33 @@ namespace MaiMuControl.Device.CamDev.IKapCamera | |||
} | |||
#endregion | |||
#region 操作日志 | |||
public void WriteSysEditLog(string tag, string info) | |||
{ | |||
try | |||
{ | |||
string Path = Application.StartupPath + "\\CamLogFiles"; | |||
if (!File.Exists(Path)) | |||
{ | |||
DirectoryInfo directoryInfo = new DirectoryInfo(Path); | |||
directoryInfo.Create(); | |||
} | |||
string directory = Path + "\\" + DateTime.Now.ToString("yyyyMM") + "\\"; | |||
if (!System.IO.Directory.Exists(directory)) | |||
System.IO.Directory.CreateDirectory(directory); | |||
string writelog = "[操作] " + DateTime.Now.ToString("HH:mm:ss.fff") + ": " + $"{tag}-{info}"; | |||
File.AppendAllText(directory + $"Cam{_DevNo}_{_SerialNumber}-" + DateTime.Now.ToString("yyyyMMdd") + ".log", writelog + "\r\n\r\n"); | |||
} | |||
catch | |||
{ | |||
} | |||
} | |||
#endregion | |||
/* | |||
* @brief:设置相机特征值 | |||
* @param [in] featureName:特征名[ExposureTime,Gain] | |||
@@ -132,6 +132,8 @@ | |||
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); | |||
this.uiTitel1 = new MaiMuControl.UIKits.MaiMuMenu.UITitel(); | |||
this.timer1 = new System.Windows.Forms.Timer(this.components); | |||
this.tabPage12 = new System.Windows.Forms.TabPage(); | |||
this.button21 = new System.Windows.Forms.Button(); | |||
this.menuStrip1.SuspendLayout(); | |||
this.tabControl1.SuspendLayout(); | |||
this.tabPage1.SuspendLayout(); | |||
@@ -150,6 +152,7 @@ | |||
this.tabPage9.SuspendLayout(); | |||
this.tabPage10.SuspendLayout(); | |||
this.tabPage11.SuspendLayout(); | |||
this.tabPage12.SuspendLayout(); | |||
this.SuspendLayout(); | |||
// | |||
// button1 | |||
@@ -283,6 +286,7 @@ | |||
this.tabControl1.Controls.Add(this.tabPage9); | |||
this.tabControl1.Controls.Add(this.tabPage10); | |||
this.tabControl1.Controls.Add(this.tabPage11); | |||
this.tabControl1.Controls.Add(this.tabPage12); | |||
this.tabControl1.Location = new System.Drawing.Point(12, 132); | |||
this.tabControl1.Name = "tabControl1"; | |||
this.tabControl1.SelectedIndex = 0; | |||
@@ -1194,6 +1198,27 @@ | |||
this.timer1.Interval = 10; | |||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); | |||
// | |||
// tabPage12 | |||
// | |||
this.tabPage12.Controls.Add(this.button21); | |||
this.tabPage12.Location = new System.Drawing.Point(4, 22); | |||
this.tabPage12.Name = "tabPage12"; | |||
this.tabPage12.Padding = new System.Windows.Forms.Padding(3); | |||
this.tabPage12.Size = new System.Drawing.Size(888, 530); | |||
this.tabPage12.TabIndex = 11; | |||
this.tabPage12.Text = "Himage"; | |||
this.tabPage12.UseVisualStyleBackColor = true; | |||
// | |||
// button21 | |||
// | |||
this.button21.Location = new System.Drawing.Point(121, 87); | |||
this.button21.Name = "button21"; | |||
this.button21.Size = new System.Drawing.Size(75, 23); | |||
this.button21.TabIndex = 0; | |||
this.button21.Text = "单次旋转"; | |||
this.button21.UseVisualStyleBackColor = true; | |||
this.button21.Click += new System.EventHandler(this.button21_Click); | |||
// | |||
// Form1 | |||
// | |||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); | |||
@@ -1238,6 +1263,7 @@ | |||
this.tabPage10.PerformLayout(); | |||
this.tabPage11.ResumeLayout(false); | |||
this.tabPage11.PerformLayout(); | |||
this.tabPage12.ResumeLayout(false); | |||
this.ResumeLayout(false); | |||
this.PerformLayout(); | |||
@@ -1347,6 +1373,8 @@ | |||
private ImageToolKits.ImageBox imageBox4; | |||
private ImageToolKits.ImageBox imageBox3; | |||
private System.Windows.Forms.Timer timer1; | |||
private System.Windows.Forms.TabPage tabPage12; | |||
private System.Windows.Forms.Button button21; | |||
} | |||
} | |||
@@ -38,6 +38,9 @@ using System.Collections; | |||
using Google.Protobuf.Collections; | |||
using ImageToolKits; | |||
using static System.Net.Mime.MediaTypeNames; | |||
using MaiMuControl.ImageKits; | |||
using System.Diagnostics; | |||
using System.Security.Cryptography; | |||
namespace MaiMuControl | |||
{ | |||
@@ -146,7 +149,7 @@ namespace MaiMuControl | |||
private void button4_Click(object sender, EventArgs e) | |||
{ | |||
HObject image = new HImage(); | |||
HTuple ImagePath = @"C:\Users\fang\Desktop\Size_SNLP20230915463_I111_X152.5008_Y-576.0998_PI_TW7.5 (良品) 10 Gerber\1.bmp"; | |||
HTuple ImagePath = @"E:\CPL\environment\test.bmp"; | |||
HOperatorSet.ReadImage(out image, ImagePath); | |||
Mat img = CamDev.HImageToMat(image); | |||
this.imageBox1.RefreshWindow(img); | |||
@@ -1080,6 +1083,19 @@ namespace MaiMuControl | |||
} | |||
#endregion | |||
private void button21_Click(object sender, EventArgs e) | |||
{ | |||
Stopwatch stopWatch = new Stopwatch(); | |||
HObject image = new HImage(); | |||
HTuple ImagePath = @"E:\CPL\environment\test.bmp"; | |||
HOperatorSet.ReadImage(out image, ImagePath); | |||
stopWatch.Restart(); | |||
HObject xyImg = HImageToolKits.HImageMirrorXY(image); | |||
Console.WriteLine($"旋转时间-》{stopWatch.ElapsedMilliseconds}"); | |||
HOperatorSet.WriteImage(xyImg, "bmp", 0, "mirrir.bmp"); | |||
} | |||
} | |||
@@ -0,0 +1,41 @@ | |||
using HalconDotNet; | |||
using OpenCvSharp.Flann; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace MaiMuControl.ImageKits | |||
{ | |||
public class HImageToolKits | |||
{ | |||
/// <summary> | |||
/// 图片XY镜像 | |||
/// </summary> | |||
/// <param name="image"></param> | |||
/// <returns></returns> | |||
public static HObject HImageMirrorXY(HObject image) | |||
{ | |||
HObject MirrorImg = new HObject(); | |||
HOperatorSet.MirrorImage(image, out MirrorImg, "diagonal"); | |||
//image = MirrorImg.Clone(); | |||
return MirrorImg; | |||
} | |||
/// <summary> | |||
/// 水平拼接 | |||
/// </summary> | |||
/// <param name="image1"></param> | |||
/// <param name="image2"></param> | |||
/// <returns></returns> | |||
public static HObject HImageHconcat(HObject image1, HObject image2) | |||
{ | |||
HObject temp = image1.ConcatObj(image2); | |||
HObject outImage = new HObject(); | |||
HOperatorSet.TileImages(temp, out outImage, 1, "horizontal"); | |||
return outImage; | |||
} | |||
} | |||
} |
@@ -236,6 +236,7 @@ | |||
<Compile Include="Form1.Designer.cs"> | |||
<DependentUpon>Form1.cs</DependentUpon> | |||
</Compile> | |||
<Compile Include="ImageKits\HImageToolKits.cs" /> | |||
<Compile Include="Program.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
<Compile Include="SysStatusMgr\CloudMgr\CloudMgr.cs" /> | |||
@@ -365,9 +365,6 @@ E:\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.pdb | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\Yolo5.dll | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\IKapBoardClassLibrary.dll | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\IKapC.NET.dll | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\MaiMuControl.dll.config | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\MaiMuControl.dll | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.dll | |||
D:\CPL\MaiMuControl\MaiMuControl\bin\x64\Debug\MaiMuControl.pdb | |||
D:\CPL\MaiMuControl\MaiMuControl\bin\x64\Debug\AdvMotAPI.dll | |||
D:\CPL\MaiMuControl\MaiMuControl\bin\x64\Debug\Automation.BDaq4.dll | |||
@@ -522,3 +519,6 @@ F:\CPL\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.csproj.CoreCompileIn | |||
F:\CPL\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuCon.DA45789F.Up2Date | |||
F:\CPL\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.dll | |||
F:\CPL\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.pdb | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\MaiMuControl.dll.config | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\bin\x64\Debug\MaiMuControl.dll | |||
E:\CPL\迈沐智能项目\模块化\Code\MaiMuControl\MaiMuControl\obj\x64\Debug\MaiMuControl.dll |