最新程序
This commit is contained in:
parent
c1c0e0697c
commit
132fd6e1b3
@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.8.34316.72
|
VisualStudioVersion = 17.8.34316.72
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HisenceYoloDetection", "HisenceYoloDetection\HisenceYoloDetection.csproj", "{0DE28139-2917-4B58-8240-4B4E11114730}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HisenceYoloDetection", "HisenceYoloDetection\HisenceYoloDetection.csproj", "{0DE28139-2917-4B58-8240-4B4E11114730}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XKRS.UI", "XKRS.UI\XKRS.UI.csproj", "{CE386374-EE63-4DF9-8A95-6AECCA4969F8}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -21,6 +23,14 @@ Global
|
|||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.Build.0 = Release|Any CPU
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.ActiveCfg = Release|X64
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.ActiveCfg = Release|X64
|
||||||
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.Build.0 = Release|X64
|
{0DE28139-2917-4B58-8240-4B4E11114730}.Release|X64.Build.0 = Release|X64
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Debug|X64.ActiveCfg = Debug|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Debug|X64.Build.0 = Debug|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Release|X64.ActiveCfg = Release|Any CPU
|
||||||
|
{CE386374-EE63-4DF9-8A95-6AECCA4969F8}.Release|X64.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -31,7 +31,7 @@ namespace HisenceYoloDetection
|
|||||||
Console.WriteLine($"Error loading image {path1}");
|
Console.WriteLine($"Error loading image {path1}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cv2.Resize(img1, img1, new Size(550, 270));
|
// Cv2.Resize(img1, img1, new Size(550, 270));
|
||||||
Mat gimg1 = new Mat();
|
Mat gimg1 = new Mat();
|
||||||
Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
|
Cv2.CvtColor(img1, gimg1, ColorConversionCodes.BGR2GRAY);
|
||||||
Mat thr1 = new Mat();
|
Mat thr1 = new Mat();
|
||||||
@ -55,7 +55,7 @@ namespace HisenceYoloDetection
|
|||||||
// Console.WriteLine($"Error loading image {path2}");
|
// Console.WriteLine($"Error loading image {path2}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cv2.Resize(img2, img2, new Size(550, 270));
|
// Cv2.Resize(img2, img2, new Size(550, 270));
|
||||||
Mat gimg2 = new Mat();
|
Mat gimg2 = new Mat();
|
||||||
Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
|
Cv2.CvtColor(img2, gimg2, ColorConversionCodes.BGR2GRAY);
|
||||||
Mat thr2 = new Mat();
|
Mat thr2 = new Mat();
|
||||||
@ -93,20 +93,24 @@ namespace HisenceYoloDetection
|
|||||||
{
|
{
|
||||||
matCutblack2.SetTo(Scalar.Black);
|
matCutblack2.SetTo(Scalar.Black);
|
||||||
}
|
}
|
||||||
|
Cv2.Resize(thr1, thr1, new Size(550, 270));
|
||||||
|
Cv2.Resize(thr2, thr2, new Size(550, 270));
|
||||||
|
DateTime dt= DateTime.Now;
|
||||||
|
string filename= dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
||||||
|
|
||||||
string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_thr1.png");
|
string savePath4 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_thr1.png");
|
||||||
// 保存结果
|
// 保存结果
|
||||||
|
|
||||||
Cv2.ImWrite(savePath4, thr1);
|
Cv2.ImWrite(savePath4, thr1);
|
||||||
string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_thr2.png");
|
string savePath3 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_thr2.png");
|
||||||
// 保存结果
|
// 保存结果
|
||||||
|
|
||||||
Cv2.ImWrite(savePath3, thr2);
|
Cv2.ImWrite(savePath3, thr2);
|
||||||
|
|
||||||
// 创建卷积核
|
// 创建卷积核
|
||||||
Mat filter1 = new Mat(17, 17, MatType.CV_32F, new Scalar(0));
|
Mat filter1 = new Mat(15, 15, MatType.CV_32F, new Scalar(0));
|
||||||
filter1.Row(8).SetTo(new Scalar(0.025));
|
filter1.Row(7).SetTo(new Scalar(0.025));
|
||||||
filter1.Col(8).SetTo(new Scalar(0.025));
|
filter1.Col(7).SetTo(new Scalar(0.025));
|
||||||
|
|
||||||
// 应用卷积
|
// 应用卷积
|
||||||
Mat final_result1 = new Mat();
|
Mat final_result1 = new Mat();
|
||||||
@ -175,11 +179,11 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_Rect.png");
|
string savePath2 = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_Rect.png");
|
||||||
// 保存结果
|
// 保存结果
|
||||||
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
|
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
|
||||||
Cv2.ImWrite(savePath2, img2);
|
Cv2.ImWrite(savePath2, img2);
|
||||||
string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + "_diff.png");
|
string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path1) + filename+"_diff.png");
|
||||||
// 保存结果
|
// 保存结果
|
||||||
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
|
//string savePath = Path.Combine(saveDir, Path.GetFileNameWithoutExtension(path2) + "_diff.png");
|
||||||
Cv2.ImWrite(savePath, blackhatImg);
|
Cv2.ImWrite(savePath, blackhatImg);
|
||||||
@ -188,14 +192,21 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
public static Rect strChangeRect(string strrect)
|
public static Rect strChangeRect(string strrect)
|
||||||
{
|
{
|
||||||
string[] rectstr = strrect.Split(",");
|
if (!string.IsNullOrEmpty(strrect))
|
||||||
int areaX = int.Parse(rectstr[0]);
|
{
|
||||||
int areaY = int.Parse(rectstr[1]);
|
string[] rectstr = strrect.Split(",");
|
||||||
int areaWidth = int.Parse(rectstr[2]);
|
int areaX = int.Parse(rectstr[0]);
|
||||||
int areaHeight = int.Parse(rectstr[3]);
|
int areaY = int.Parse(rectstr[1]);
|
||||||
|
int areaWidth = int.Parse(rectstr[2]);
|
||||||
|
int areaHeight = int.Parse(rectstr[3]);
|
||||||
|
|
||||||
Rect rect = new Rect(areaX, areaY, areaWidth, areaHeight);
|
Rect rect = new Rect(areaX, areaY, areaWidth, areaHeight);
|
||||||
return rect;
|
return rect;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
return new Rect(0,0,0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string rectChangeStr(Rect area)
|
public static string rectChangeStr(Rect area)
|
||||||
|
546
HisenceYoloDetection/HikCamera.cs
Normal file
546
HisenceYoloDetection/HikCamera.cs
Normal file
@ -0,0 +1,546 @@
|
|||||||
|
|
||||||
|
using MvCamCtrl.NET;
|
||||||
|
using OpenCvSharp;
|
||||||
|
using OpenCvSharp.Dnn;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace YSDetection
|
||||||
|
{
|
||||||
|
public class HikCamera
|
||||||
|
{
|
||||||
|
[DllImport("kernel32.dll", EntryPoint = "CopyMemory", SetLastError = false)]
|
||||||
|
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
|
||||||
|
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO_LIST m_stDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||||
|
int nRet = MyCamera.MV_OK;
|
||||||
|
MyCamera.cbExceptiondelegate pCallBackFunc;
|
||||||
|
private MyCamera device = new MyCamera();
|
||||||
|
bool m_bGrabbing = false;
|
||||||
|
Thread m_hReceiveThread = null;
|
||||||
|
MyCamera.MV_FRAME_OUT_INFO_EX m_stFrameInfo = new MyCamera.MV_FRAME_OUT_INFO_EX();
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO stDevInfo = new MyCamera.MV_CC_DEVICE_INFO();
|
||||||
|
// ch:用于从驱动获取图像的缓存 | en:Buffer for getting image from driver
|
||||||
|
UInt32 m_nBufSizeForDriver = 0;
|
||||||
|
IntPtr m_BufForDriver = IntPtr.Zero;
|
||||||
|
private static Object BufForDriverLock = new Object();
|
||||||
|
bool _snapFlag = false;
|
||||||
|
public MyCamera.cbOutputExdelegate ImageCallback;
|
||||||
|
MyCamera.MV_FRAME_OUT _frame = new MyCamera.MV_FRAME_OUT();
|
||||||
|
readonly ManualResetEvent _snapHandle = new ManualResetEvent(false);
|
||||||
|
|
||||||
|
//ImageSet _bufferImgSet = null;
|
||||||
|
ManualResetEvent _bufferHandle = new ManualResetEvent(false);
|
||||||
|
public Action<DateTime, Mat, int> OnHImageOutput { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 相机拍照计数
|
||||||
|
/// </summary>
|
||||||
|
public volatile int SnapshotCount = 0;
|
||||||
|
public bool Ifsucess = false;
|
||||||
|
public HikCamera() { }
|
||||||
|
private void DeviceListAcq()
|
||||||
|
{
|
||||||
|
// ch:创建设备列表 | en:Create Device List
|
||||||
|
System.GC.Collect();
|
||||||
|
// cbDeviceList.Items.Clear();
|
||||||
|
// m_stDeviceList.nDeviceNum = 0;
|
||||||
|
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_stDeviceList);
|
||||||
|
if (0 != nRet)
|
||||||
|
{
|
||||||
|
// ShowErrorMsg("Enumerate devices fail!", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:在窗体列表中显示设备名 | en:Display device name in the form list
|
||||||
|
for (int i = 0; i < m_stDeviceList.nDeviceNum; i++)
|
||||||
|
{
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||||
|
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||||
|
{
|
||||||
|
MyCamera.MV_GIGE_DEVICE_INFO gigeInfo = (MyCamera.MV_GIGE_DEVICE_INFO)MyCamera.ByteToStruct(device.SpecialInfo.stGigEInfo, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||||
|
|
||||||
|
if (gigeInfo.chUserDefinedName != "")
|
||||||
|
{
|
||||||
|
//cbDeviceList.Items.Add("GEV: " + gigeInfo.chUserDefinedName + " (" + gigeInfo.chSerialNumber + ")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// cbDeviceList.Items.Add("GEV: " + gigeInfo.chManufacturerName + " " + gigeInfo.chModelName + " (" + gigeInfo.chSerialNumber + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||||
|
{
|
||||||
|
MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)MyCamera.ByteToStruct(device.SpecialInfo.stUsb3VInfo, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||||
|
if (usbInfo.chUserDefinedName != "")
|
||||||
|
{
|
||||||
|
//cbDeviceList.Items.Add("U3V: " + usbInfo.chUserDefinedName + " (" + usbInfo.chSerialNumber + ")");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//cbDeviceList.Items.Add("U3V: " + usbInfo.chManufacturerName + " " + usbInfo.chModelName + " (" + usbInfo.chSerialNumber + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:选择第一项 | en:Select the first item
|
||||||
|
if (m_stDeviceList.nDeviceNum != 0)
|
||||||
|
{
|
||||||
|
//cbDeviceList.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Start()
|
||||||
|
{
|
||||||
|
#region 枚举相机后根据IP地址匹配连接相机
|
||||||
|
//将IP地址转换为字节数组
|
||||||
|
uint intAddress = 0;
|
||||||
|
if (/*(IIConfig.HikCameraType == EnumHelper.HikCameraType.Gige) &&*/ (!string.IsNullOrWhiteSpace("169.254.127.84")))
|
||||||
|
{
|
||||||
|
byte[] IPArr = IPAddress.Parse("169.254.127.84").GetAddressBytes();
|
||||||
|
for (int i = 0; i < IPArr.Length; i++)
|
||||||
|
{
|
||||||
|
intAddress += (uint)(IPArr[i] << (IPArr.Length - 1 - i) * 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO_LIST m_pDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||||
|
|
||||||
|
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList);
|
||||||
|
if (0 != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Enumerate devices fail!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, $"搜索获取{m_pDeviceList.nDeviceNum.ToInt()}台相机在线", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCameraFound = false;
|
||||||
|
for (int i = 0; i < m_pDeviceList.nDeviceNum; i++)
|
||||||
|
{
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||||
|
IntPtr buffer = IntPtr.Zero;
|
||||||
|
|
||||||
|
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||||
|
{
|
||||||
|
buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0);
|
||||||
|
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||||
|
|
||||||
|
if (stGigEDev.nCurrentIp == intAddress)
|
||||||
|
{
|
||||||
|
stDevInfo = device;
|
||||||
|
isCameraFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||||
|
{
|
||||||
|
//buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0);
|
||||||
|
//MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||||
|
//if (usbInfo.chSerialNumber == IConfig.SerialNum)
|
||||||
|
//{
|
||||||
|
// stDevInfo = device;
|
||||||
|
// isCameraFound = true;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
//释放内存空间
|
||||||
|
//Marshal.FreeHGlobal(buffer);
|
||||||
|
|
||||||
|
if (isCameraFound)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCameraFound)
|
||||||
|
{
|
||||||
|
throw new Exception($"相机未能找到");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
// ch:创建设备 | en: Create device
|
||||||
|
nRet = device.MV_CC_CreateDevice_NET(ref stDevInfo);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Create device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:打开设备 | en:Open device
|
||||||
|
nRet = device.MV_CC_OpenDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Open device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||||
|
if (stDevInfo.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||||
|
{
|
||||||
|
int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
|
||||||
|
if (nPacketSize > 0)
|
||||||
|
{
|
||||||
|
nRet = device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize);
|
||||||
|
if (nRet != MyCamera.MV_OK)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Warning: Set Packet Size failed {0:x8}", nRet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Warning: Get Packet Size failed {0:x8}", nPacketSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:注册异常回调函数 | en:Register Exception Callback
|
||||||
|
nRet = device.MV_CC_RegisterExceptionCallBack_NET(pCallBackFunc, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Register expection callback failed:{nRet}");
|
||||||
|
}
|
||||||
|
GC.KeepAlive(pCallBackFunc);
|
||||||
|
|
||||||
|
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||||
|
device.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);// ch:工作在连续模式 | en:Acquisition On Continuous Mode
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
device.MV_CC_SetEnumValue_NET("TriggerMode", 0); // ch:连续模式 | en:Continuous
|
||||||
|
|
||||||
|
// ch:注册回调函数 | en:Register image callback
|
||||||
|
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||||
|
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Register image callback failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ch:设置触发模式为off || en:set trigger mode as off
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set TriggerMode failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||||
|
// 1 - Line1;
|
||||||
|
// 2 - Line2;
|
||||||
|
// 3 - Line3;
|
||||||
|
// 4 - Counter;
|
||||||
|
// 7 - Software;
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Line0 Trigger failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:注册回调函数 | en:Register image callback
|
||||||
|
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||||
|
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Register image callback failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Software Trigger failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ch:开启抓图 || en: start grab image
|
||||||
|
nRet = device.MV_CC_StartGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ifsucess = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
if(Ifsucess)
|
||||||
|
{
|
||||||
|
// IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||||
|
|
||||||
|
|
||||||
|
// ch:停止抓图 | en:Stop grab image
|
||||||
|
nRet = device.MV_CC_StopGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:关闭设备 | en:Close device
|
||||||
|
nRet = device.MV_CC_CloseDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Close device failed{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:销毁设备 | en:Destroy device
|
||||||
|
nRet = device.MV_CC_DestroyDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Destroy device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ifsucess = false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
void ImageCallbackFunc(IntPtr pData, ref MyCamera.MV_FRAME_OUT_INFO_EX pFrameInfo, IntPtr pUser)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// if (false)
|
||||||
|
// {
|
||||||
|
// // SnapshotCount++;
|
||||||
|
// Interlocked.Increment(ref SnapshotCount);
|
||||||
|
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机硬触发...");
|
||||||
|
|
||||||
|
// //LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机硬触发");
|
||||||
|
// //Stopwatch sw = new Stopwatch();
|
||||||
|
// //sw.Start();
|
||||||
|
|
||||||
|
// int nWidth = pFrameInfo.nWidth;
|
||||||
|
// int nHeight = pFrameInfo.nHeight;
|
||||||
|
|
||||||
|
// //HImage hImage = new HImage();
|
||||||
|
// //HObject Hobj = new HObject();
|
||||||
|
// //IntPtr pTemp = IntPtr.Zero;
|
||||||
|
// //hImage.GenImage1((HTuple)"byte", nWidth, nHeight, pData);
|
||||||
|
|
||||||
|
// //var imgSet = new ImageSet
|
||||||
|
// //{
|
||||||
|
// // HImage = hImage,
|
||||||
|
// // ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||||
|
// //};
|
||||||
|
|
||||||
|
|
||||||
|
// //测试图片颜色
|
||||||
|
|
||||||
|
// //if (IsColor(pFrameInfo.enPixelType))
|
||||||
|
// //{
|
||||||
|
// // //pFrameInfo.enPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||||
|
|
||||||
|
// // // 彩色图
|
||||||
|
// // switch (pFrameInfo.enPixelType)
|
||||||
|
// // {
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gr", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_rg", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gb", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_bg", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||||
|
// {
|
||||||
|
// // Console.WriteLine("image pixel format is rgb8...");
|
||||||
|
// //pTemp = pData;
|
||||||
|
// //HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// //HobjectToRGBHimage(Hobj, ref hImage);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机数据转换完成 ...");
|
||||||
|
|
||||||
|
// //if (!IsMonoData(pFrameInfo.enPixelType))
|
||||||
|
// //{
|
||||||
|
// // pImageBuf = Marshal.AllocHGlobal((int)stFrameInfo.nWidth * stFrameInfo.nHeight * 3);
|
||||||
|
// // HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
//#if false
|
||||||
|
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
|
||||||
|
// {
|
||||||
|
// //加入内部队列
|
||||||
|
// InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
// //业务图片处理加入外部队列
|
||||||
|
// var outImgSet = CopyImageSet(imgSet);
|
||||||
|
|
||||||
|
// if (IIConfig.IsDirectHardwareTrigger)
|
||||||
|
// {
|
||||||
|
// //传感器直接触发 收到图片后 传出
|
||||||
|
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _bufferImgSet = outImgSet;
|
||||||
|
// //_bufferImgSetQueue.Enqueue(outImgSet);
|
||||||
|
// _bufferHandle.Set();
|
||||||
|
// }
|
||||||
|
// ClearImageSet(imgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($">>>> 像素类型:{pFrameInfo.enPixelType}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//#else
|
||||||
|
// //加入内部队列
|
||||||
|
// InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
// //业务图片处理加入外部队列
|
||||||
|
// var outImgSet = CopyImageSet(imgSet);
|
||||||
|
|
||||||
|
|
||||||
|
// // LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机回调 OnHImageOutput ...");
|
||||||
|
// if (IIConfig.IsDirectHardwareTrigger)
|
||||||
|
// {
|
||||||
|
// // 传感器直接触发 收到图片后 传出
|
||||||
|
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _bufferImgSet = outImgSet;
|
||||||
|
// // _bufferImgSetQueue.Enqueue(outImgSet);
|
||||||
|
// _bufferHandle.Set();
|
||||||
|
// }
|
||||||
|
// //处理完图片 会清理内部队列的图像
|
||||||
|
// DisplayAndSaveOriginImage(imgSet.Id);
|
||||||
|
// //ClearImageSet(imgSet);
|
||||||
|
//#endif
|
||||||
|
// }
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
if (_snapFlag)
|
||||||
|
{
|
||||||
|
_snapFlag = false;
|
||||||
|
_frame = new MyCamera.MV_FRAME_OUT
|
||||||
|
{
|
||||||
|
stFrameInfo = pFrameInfo,
|
||||||
|
pBufAddr = pData
|
||||||
|
};
|
||||||
|
_snapHandle.Set();
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}相机取像异常,{ex.GetExceptionMessage()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Snapshot()
|
||||||
|
{
|
||||||
|
Stopwatch sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
// ImageSet set = new ImageSet();
|
||||||
|
// set.SnapshotCount = SnapshotCount;
|
||||||
|
// set.SnapshotFileName = SnapshotFileNames;
|
||||||
|
|
||||||
|
//InitialImageSet(set);
|
||||||
|
MyCamera.MV_FRAME_OUT frameInfo = new MyCamera.MV_FRAME_OUT();
|
||||||
|
nRet = MyCamera.MV_OK;
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
// ch: 触发命令 || en: Trigger command
|
||||||
|
nRet = device.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"相机拍照触发失败:{nRet}");
|
||||||
|
}
|
||||||
|
|
||||||
|
nRet = device.MV_CC_GetImageBuffer_NET(ref frameInfo, 1000);
|
||||||
|
nRet = device.MV_CC_FreeImageBuffer_NET(ref frameInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_snapHandle.Reset();
|
||||||
|
_snapFlag = true;
|
||||||
|
_snapHandle.WaitOne();
|
||||||
|
//lock (_imgCallBackLock)
|
||||||
|
{
|
||||||
|
frameInfo.stFrameInfo = _frame.stFrameInfo;
|
||||||
|
frameInfo.pBufAddr = _frame.pBufAddr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:获取一帧图像 | en:Get one image
|
||||||
|
if (MyCamera.MV_OK == nRet)
|
||||||
|
{
|
||||||
|
if (frameInfo.pBufAddr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (nRet == MyCamera.MV_OK)
|
||||||
|
{
|
||||||
|
var pFrameInfo = frameInfo.stFrameInfo;
|
||||||
|
Mat mat=new Mat(pFrameInfo.nHeight, pFrameInfo.nWidth, MatType.CV_8UC3, frameInfo.pBufAddr);
|
||||||
|
OnHImageOutput?.Invoke(DateTime.Now, mat, SnapshotCount);
|
||||||
|
mat.ImWrite("D://123.jpg");
|
||||||
|
//HImage hImage = new HImage();
|
||||||
|
//HObject Hobj = new HObject();
|
||||||
|
//IntPtr pTemp = IntPtr.Zero;
|
||||||
|
//hImage.GenImage1("byte", pFrameInfo.nWidth, pFrameInfo.nHeight, frameInfo.pBufAddr);
|
||||||
|
|
||||||
|
////hImage.ConvertHImageTo16GrayBitmap();
|
||||||
|
//var imgSet = new ImageSet
|
||||||
|
//{
|
||||||
|
// HImage = hImage,
|
||||||
|
// ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||||
|
//};
|
||||||
|
//if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||||
|
//{
|
||||||
|
// // Console.WriteLine("image pixel format is rgb8...");
|
||||||
|
// pTemp = frameInfo.pBufAddr;
|
||||||
|
// HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// HobjectToRGBHimage(Hobj, ref hImage);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//加入内部队列
|
||||||
|
//InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
////业务图片处理加入外部队列
|
||||||
|
//var outImgSet = CopyImageSet(imgSet);
|
||||||
|
//OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||||
|
//DisplayAndSaveOriginImage(imgSet.Id);
|
||||||
|
//HikToBitmap(pFrameInfo, frameInfo.pBufAddr);
|
||||||
|
//Generate8GrayImageByPointer((int)nWidth, (int)nHeight, frameInfo.pBufAddr, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Grap Image Failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.Stop();
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"取像耗时:{sw.ElapsedMilliseconds} ms");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
893
HisenceYoloDetection/HikCameraDriver.cs
Normal file
893
HisenceYoloDetection/HikCameraDriver.cs
Normal file
@ -0,0 +1,893 @@
|
|||||||
|
|
||||||
|
using MvCamCtrl.NET;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Net;
|
||||||
|
using OpenCvSharp;
|
||||||
|
using DVPCameraType;
|
||||||
|
using System.Reflection.Metadata;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//[Device("HikCamera", "海康相机", EnumHelper.DeviceAttributeType.Device)]
|
||||||
|
public class HikCameraDriver
|
||||||
|
{
|
||||||
|
|
||||||
|
#region CameraBase
|
||||||
|
//public IOperationConfig GetOperationConfigFromDevice()
|
||||||
|
// {
|
||||||
|
// HikCameraOperationConfig opConfig = new HikCameraOperationConfig();
|
||||||
|
|
||||||
|
// MyCamera.MVCC_FLOATVALUE stParam = new MyCamera.MVCC_FLOATVALUE();
|
||||||
|
// int nRet = device.MV_CC_GetFloatValue_NET("ExposureTime", ref stParam);
|
||||||
|
// if (MyCamera.MV_OK == nRet)
|
||||||
|
// {
|
||||||
|
// opConfig.Exposure = stParam.fCurValue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// nRet = device.MV_CC_GetFloatValue_NET("Gain", ref stParam);
|
||||||
|
// if (MyCamera.MV_OK == nRet)
|
||||||
|
// {
|
||||||
|
// opConfig.Gain = stParam.fCurValue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return opConfig;
|
||||||
|
// }
|
||||||
|
public bool IfSuccess = false;
|
||||||
|
|
||||||
|
float _lastExposure = 0;
|
||||||
|
float _lastGain = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 相机拍照计数
|
||||||
|
/// </summary>
|
||||||
|
public volatile int SnapshotCount = 0;
|
||||||
|
//public void UploadOperationConfig(IOperationConfig config)
|
||||||
|
//{
|
||||||
|
// if (CurrentState != EnumHelper.DeviceState.DSOpen)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// CameraOprerationConfigBase opConfig = config as CameraOprerationConfigBase;
|
||||||
|
|
||||||
|
// int nRet;
|
||||||
|
|
||||||
|
// if (opConfig.Exposure != 0 && opConfig.Exposure != _lastExposure)
|
||||||
|
// {
|
||||||
|
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", opConfig.Exposure);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Exposure set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _lastExposure = opConfig.Exposure;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (opConfig.Gain != 0 && opConfig.Gain != _lastGain)
|
||||||
|
// {
|
||||||
|
// device.MV_CC_SetEnumValue_NET("GainAuto", 0);
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("Gain", opConfig.Gain);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Gain set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _lastGain = opConfig.Gain;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public Action<DateTime, Mat, int> OnHImageOutput { get; set; }
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
|
||||||
|
//_bufferImgSetQueue = new ConcurrentQueue<ImageSet>();
|
||||||
|
//_bufferImgSet = new ImageSet();
|
||||||
|
//pCallBackFunc = new MyCamera.cbExceptiondelegate(cbExceptiondelegate);
|
||||||
|
#if false
|
||||||
|
#region 根据IP连接相机
|
||||||
|
|
||||||
|
stDevInfo.nTLayerType = MyCamera.MV_GIGE_DEVICE;
|
||||||
|
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = new MyCamera.MV_GIGE_DEVICE_INFO();
|
||||||
|
//string strCurrentIp = IIConfig.CameraIP;// ch:需要连接的相机ip(根据实际填充)
|
||||||
|
|
||||||
|
//string strNetExport = IIConfig.ComputerIP; // ch:相机对应的网卡ip(根据实际填充)
|
||||||
|
|
||||||
|
string strCurrentIp = "192.168.1.21";// ch:需要连接的相机ip(根据实际填充)
|
||||||
|
|
||||||
|
string strNetExport = "192.168.1.20"; // ch:相机对应的网卡ip(根据实际填充)
|
||||||
|
|
||||||
|
var parts = strCurrentIp.Split('.');
|
||||||
|
int nIp1 = Convert.ToInt32(parts[0]);
|
||||||
|
int nIp2 = Convert.ToInt32(parts[1]);
|
||||||
|
int nIp3 = Convert.ToInt32(parts[2]);
|
||||||
|
int nIp4 = Convert.ToInt32(parts[3]);
|
||||||
|
stGigEDev.nCurrentIp = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||||
|
|
||||||
|
parts = strNetExport.Split('.');
|
||||||
|
nIp1 = Convert.ToInt32(parts[0]);
|
||||||
|
nIp2 = Convert.ToInt32(parts[1]);
|
||||||
|
nIp3 = Convert.ToInt32(parts[2]);
|
||||||
|
nIp4 = Convert.ToInt32(parts[3]);
|
||||||
|
stGigEDev.nNetExport = (uint)((nIp1 << 24) | (nIp2 << 16) | (nIp3 << 8) | nIp4);
|
||||||
|
|
||||||
|
IntPtr stGigeInfoPtr = Marshal.AllocHGlobal(216);
|
||||||
|
Marshal.StructureToPtr(stGigEDev, stGigeInfoPtr, false);
|
||||||
|
stDevInfo.SpecialInfo.stGigEInfo = new Byte[540];
|
||||||
|
Marshal.Copy(stGigeInfoPtr, stDevInfo.SpecialInfo.stGigEInfo, 0, 540);
|
||||||
|
//释放内存空间
|
||||||
|
Marshal.FreeHGlobal(stGigeInfoPtr);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Pause()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Resume()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Start(string v)
|
||||||
|
{
|
||||||
|
#region 枚举相机后根据IP地址匹配连接相机
|
||||||
|
//将IP地址转换为字节数组
|
||||||
|
uint intAddress = 0;
|
||||||
|
if (/*(IIConfig.HikCameraType == EnumHelper.HikCameraType.Gige) &&*/ (!string.IsNullOrWhiteSpace("192.168.1.21")))
|
||||||
|
{
|
||||||
|
byte[] IPArr = IPAddress.Parse("192.168.1.21").GetAddressBytes();
|
||||||
|
for (int i = 0; i < IPArr.Length; i++)
|
||||||
|
{
|
||||||
|
intAddress += (uint)(IPArr[i] << (IPArr.Length - 1 - i) * 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO_LIST m_pDeviceList = new MyCamera.MV_CC_DEVICE_INFO_LIST();
|
||||||
|
|
||||||
|
int nRet = MyCamera.MV_CC_EnumDevices_NET(MyCamera.MV_GIGE_DEVICE | MyCamera.MV_USB_DEVICE, ref m_pDeviceList);
|
||||||
|
if (0 != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Enumerate devices fail!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, $"搜索获取{m_pDeviceList.nDeviceNum.ToInt()}台相机在线", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isCameraFound = false;
|
||||||
|
for (int i = 0; i < m_pDeviceList.nDeviceNum; i++)
|
||||||
|
{
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_pDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO));
|
||||||
|
IntPtr buffer = IntPtr.Zero;
|
||||||
|
|
||||||
|
if (device.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||||
|
{
|
||||||
|
buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stGigEInfo, 0);
|
||||||
|
MyCamera.MV_GIGE_DEVICE_INFO stGigEDev = (MyCamera.MV_GIGE_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_GIGE_DEVICE_INFO));
|
||||||
|
|
||||||
|
if (stGigEDev.nCurrentIp == intAddress)
|
||||||
|
{
|
||||||
|
stDevInfo = device;
|
||||||
|
isCameraFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (device.nTLayerType == MyCamera.MV_USB_DEVICE)
|
||||||
|
{
|
||||||
|
//buffer = Marshal.UnsafeAddrOfPinnedArrayElement(device.SpecialInfo.stUsb3VInfo, 0);
|
||||||
|
//MyCamera.MV_USB3_DEVICE_INFO usbInfo = (MyCamera.MV_USB3_DEVICE_INFO)Marshal.PtrToStructure(buffer, typeof(MyCamera.MV_USB3_DEVICE_INFO));
|
||||||
|
//if (usbInfo.chSerialNumber == IConfig.SerialNum)
|
||||||
|
//{
|
||||||
|
// stDevInfo = device;
|
||||||
|
// isCameraFound = true;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
//释放内存空间
|
||||||
|
//Marshal.FreeHGlobal(buffer);
|
||||||
|
|
||||||
|
if (isCameraFound)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isCameraFound)
|
||||||
|
{
|
||||||
|
throw new Exception($"相机未能找到");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
// ch:创建设备 | en: Create device
|
||||||
|
nRet = device.MV_CC_CreateDevice_NET(ref stDevInfo);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Create device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:打开设备 | en:Open device
|
||||||
|
nRet = device.MV_CC_OpenDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Open device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ch:探测网络最佳包大小(只对GigE相机有效) | en:Detection network optimal package size(It only works for the GigE camera)
|
||||||
|
if (stDevInfo.nTLayerType == MyCamera.MV_GIGE_DEVICE)
|
||||||
|
{
|
||||||
|
int nPacketSize = device.MV_CC_GetOptimalPacketSize_NET();
|
||||||
|
if (nPacketSize > 0)
|
||||||
|
{
|
||||||
|
nRet = device.MV_CC_SetIntValue_NET("GevSCPSPacketSize", (uint)nPacketSize);
|
||||||
|
if (nRet != MyCamera.MV_OK)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Warning: Set Packet Size failed {0:x8}", nRet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Warning: Get Packet Size failed {0:x8}", nPacketSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:注册异常回调函数 | en:Register Exception Callback
|
||||||
|
nRet = device.MV_CC_RegisterExceptionCallBack_NET(pCallBackFunc, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Register expection callback failed:{nRet}");
|
||||||
|
}
|
||||||
|
GC.KeepAlive(pCallBackFunc);
|
||||||
|
|
||||||
|
// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||||
|
device.MV_CC_SetEnumValue_NET("AcquisitionMode", 2);// ch:工作在连续模式 | en:Acquisition On Continuous Mode
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
device.MV_CC_SetEnumValue_NET("TriggerMode", 0); // ch:连续模式 | en:Continuous
|
||||||
|
|
||||||
|
// ch:注册回调函数 | en:Register image callback
|
||||||
|
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||||
|
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Register image callback failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ch:设置触发模式为off || en:set trigger mode as off
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set TriggerMode failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||||
|
// 1 - Line1;
|
||||||
|
// 2 - Line2;
|
||||||
|
// 3 - Line3;
|
||||||
|
// 4 - Counter;
|
||||||
|
// 7 - Software;
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Line0 Trigger failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:注册回调函数 | en:Register image callback
|
||||||
|
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||||
|
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Register image callback failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Software Trigger failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ch:开启抓图 || en: start grab image
|
||||||
|
nRet = device.MV_CC_StartGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IfSuccess = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (IIConfig.DefaultExposure != 0)
|
||||||
|
//{
|
||||||
|
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", IIConfig.DefaultExposure);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Exposure set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (IIConfig.Gain >= 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Gain set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//// 设置 触发延迟
|
||||||
|
//if (IIConfig.TriggerDelay > 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||||
|
// if (MyCamera.MV_OK != nRet)
|
||||||
|
// {
|
||||||
|
// throw new Exception("Set TriggerDelay failed!");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (IIConfig.LineDebouncerTime > 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||||
|
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void IIConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == "IsHardwareTrigger" && !false)
|
||||||
|
{
|
||||||
|
// ch:停止抓图 | en:Stop grab image
|
||||||
|
nRet = device.MV_CC_StopGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false)
|
||||||
|
{
|
||||||
|
// ch:触发源选择:0 - Line0; | en:Trigger source select:0 - Line0;
|
||||||
|
// 1 - Line1;
|
||||||
|
// 2 - Line2;
|
||||||
|
// 3 - Line3;
|
||||||
|
// 4 - Counter;
|
||||||
|
// 7 - Software;
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 0);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Line0 Trigger failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:注册回调函数 | en:Register image callback
|
||||||
|
ImageCallback = new MyCamera.cbOutputExdelegate(ImageCallbackFunc);
|
||||||
|
nRet = device.MV_CC_RegisterImageCallBackEx_NET(ImageCallback, IntPtr.Zero);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Register image callback failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nRet = device.MV_CC_SetEnumValue_NET("TriggerSource", 7);
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception("Set Software Trigger failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:开启抓图 || en: start grab image
|
||||||
|
nRet = device.MV_CC_StartGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (IIConfig.DefaultExposure != 0)
|
||||||
|
//{
|
||||||
|
// device.MV_CC_SetEnumValue_NET("ExposureAuto", 0);
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("ExposureTime", IIConfig.DefaultExposure);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Exposure set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (IIConfig.Gain >= 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("Gain", IIConfig.Gain);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"Gain set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//// 设置 触发延迟
|
||||||
|
//if (IIConfig.TriggerDelay > 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetFloatValue_NET("TriggerDelay", IIConfig.TriggerDelay);
|
||||||
|
// if (MyCamera.MV_OK != nRet)
|
||||||
|
// {
|
||||||
|
// throw new Exception("Set TriggerDelay failed!");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (IIConfig.LineDebouncerTime > 0)
|
||||||
|
//{
|
||||||
|
// nRet = device.MV_CC_SetIntValue_NET("LineDebouncerTime", (uint)IIConfig.LineDebouncerTime);
|
||||||
|
// if (nRet != MyCamera.MV_OK)
|
||||||
|
// {
|
||||||
|
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
// IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||||
|
|
||||||
|
|
||||||
|
// ch:停止抓图 | en:Stop grab image
|
||||||
|
nRet = device.MV_CC_StopGrabbing_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:关闭设备 | en:Close device
|
||||||
|
nRet = device.MV_CC_CloseDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Close device failed{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:销毁设备 | en:Destroy device
|
||||||
|
nRet = device.MV_CC_DestroyDevice_NET();
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"Destroy device failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region HikCamera
|
||||||
|
public MyCamera.cbOutputExdelegate ImageCallback;
|
||||||
|
MyCamera.MV_FRAME_OUT _frame = new MyCamera.MV_FRAME_OUT();
|
||||||
|
readonly ManualResetEvent _snapHandle = new ManualResetEvent(false);
|
||||||
|
bool _snapFlag = false;
|
||||||
|
|
||||||
|
//ImageSet _bufferImgSet = null;
|
||||||
|
ManualResetEvent _bufferHandle = new ManualResetEvent(false);
|
||||||
|
//ConcurrentQueue<ImageSet> _bufferImgSetQueue = new ConcurrentQueue<ImageSet>();
|
||||||
|
//volatile ImageSet _bufferImgSet = new ImageSet();
|
||||||
|
|
||||||
|
|
||||||
|
void ImageCallbackFunc(IntPtr pData, ref MyCamera.MV_FRAME_OUT_INFO_EX pFrameInfo, IntPtr pUser)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// if (false)
|
||||||
|
// {
|
||||||
|
// // SnapshotCount++;
|
||||||
|
// Interlocked.Increment(ref SnapshotCount);
|
||||||
|
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机硬触发...");
|
||||||
|
|
||||||
|
// //LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机硬触发");
|
||||||
|
// //Stopwatch sw = new Stopwatch();
|
||||||
|
// //sw.Start();
|
||||||
|
|
||||||
|
// int nWidth = pFrameInfo.nWidth;
|
||||||
|
// int nHeight = pFrameInfo.nHeight;
|
||||||
|
|
||||||
|
// //HImage hImage = new HImage();
|
||||||
|
// //HObject Hobj = new HObject();
|
||||||
|
// //IntPtr pTemp = IntPtr.Zero;
|
||||||
|
// //hImage.GenImage1((HTuple)"byte", nWidth, nHeight, pData);
|
||||||
|
|
||||||
|
// //var imgSet = new ImageSet
|
||||||
|
// //{
|
||||||
|
// // HImage = hImage,
|
||||||
|
// // ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||||
|
// //};
|
||||||
|
|
||||||
|
|
||||||
|
// //测试图片颜色
|
||||||
|
|
||||||
|
// //if (IsColor(pFrameInfo.enPixelType))
|
||||||
|
// //{
|
||||||
|
// // //pFrameInfo.enPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed;
|
||||||
|
|
||||||
|
// // // 彩色图
|
||||||
|
// // switch (pFrameInfo.enPixelType)
|
||||||
|
// // {
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gr", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_rg", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_gb", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // case MyCamera.MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||||
|
// // imgSet.HImage = imgSet.HImage.CfaToRgb("bayer_bg", "bilinear");
|
||||||
|
// // imgSet.HImage = imgSet.HImage.ConvertHObjectToHImage();
|
||||||
|
// // break;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||||
|
// {
|
||||||
|
// // Console.WriteLine("image pixel format is rgb8...");
|
||||||
|
// //pTemp = pData;
|
||||||
|
// //HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// //HobjectToRGBHimage(Hobj, ref hImage);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机数据转换完成 ...");
|
||||||
|
|
||||||
|
// //if (!IsMonoData(pFrameInfo.enPixelType))
|
||||||
|
// //{
|
||||||
|
// // pImageBuf = Marshal.AllocHGlobal((int)stFrameInfo.nWidth * stFrameInfo.nHeight * 3);
|
||||||
|
// // HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
|
||||||
|
//#if false
|
||||||
|
// if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8)
|
||||||
|
// {
|
||||||
|
// //加入内部队列
|
||||||
|
// InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
// //业务图片处理加入外部队列
|
||||||
|
// var outImgSet = CopyImageSet(imgSet);
|
||||||
|
|
||||||
|
// if (IIConfig.IsDirectHardwareTrigger)
|
||||||
|
// {
|
||||||
|
// //传感器直接触发 收到图片后 传出
|
||||||
|
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _bufferImgSet = outImgSet;
|
||||||
|
// //_bufferImgSetQueue.Enqueue(outImgSet);
|
||||||
|
// _bufferHandle.Set();
|
||||||
|
// }
|
||||||
|
// ClearImageSet(imgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Console.WriteLine($">>>> 像素类型:{pFrameInfo.enPixelType}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//#else
|
||||||
|
// //加入内部队列
|
||||||
|
// InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
// //业务图片处理加入外部队列
|
||||||
|
// var outImgSet = CopyImageSet(imgSet);
|
||||||
|
|
||||||
|
|
||||||
|
// // LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||||
|
|
||||||
|
// // Console.WriteLine($">>>> {IIConfig.Name} 相机回调 OnHImageOutput ...");
|
||||||
|
// if (IIConfig.IsDirectHardwareTrigger)
|
||||||
|
// {
|
||||||
|
// // 传感器直接触发 收到图片后 传出
|
||||||
|
// OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _bufferImgSet = outImgSet;
|
||||||
|
// // _bufferImgSetQueue.Enqueue(outImgSet);
|
||||||
|
// _bufferHandle.Set();
|
||||||
|
// }
|
||||||
|
// //处理完图片 会清理内部队列的图像
|
||||||
|
// DisplayAndSaveOriginImage(imgSet.Id);
|
||||||
|
// //ClearImageSet(imgSet);
|
||||||
|
//#endif
|
||||||
|
// }
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
if (_snapFlag)
|
||||||
|
{
|
||||||
|
_snapFlag = false;
|
||||||
|
_frame = new MyCamera.MV_FRAME_OUT
|
||||||
|
{
|
||||||
|
stFrameInfo = pFrameInfo,
|
||||||
|
pBufAddr = pData
|
||||||
|
};
|
||||||
|
_snapHandle.Set();
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}相机取像异常,{ex.GetExceptionMessage()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//bool IsColor(MvGvspPixelType enType)
|
||||||
|
//{
|
||||||
|
// switch (enType)
|
||||||
|
// {
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BGR8_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_YUV422_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_YUV422_YUYV_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGR8:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerRG8:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGB8:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerBG8:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGB10:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGB10_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerBG10:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerBG10_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerRG10:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerRG10_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGR10:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGR10_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGB12:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGB12_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerBG12:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerBG12_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerRG12:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerRG12_Packed:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGR12:
|
||||||
|
// case MvGvspPixelType.PixelType_Gvsp_BayerGR12_Packed:
|
||||||
|
// return true;
|
||||||
|
// default:
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
private bool IsMonoData(MyCamera.MvGvspPixelType enGvspPixelType)
|
||||||
|
{
|
||||||
|
switch (enGvspPixelType)
|
||||||
|
{
|
||||||
|
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8:
|
||||||
|
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono10:
|
||||||
|
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono10_Packed:
|
||||||
|
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono12:
|
||||||
|
case MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono12_Packed:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RefreshImageBufferHandle()
|
||||||
|
{
|
||||||
|
//_bufferImgSet?.Dispose();
|
||||||
|
//_bufferImgSet = null;
|
||||||
|
|
||||||
|
_bufferHandle.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
object _bufferLock = new object();
|
||||||
|
|
||||||
|
|
||||||
|
//public void CameraOpModeChanged(EnumHelper.CameraOpMode opMode)
|
||||||
|
//{
|
||||||
|
// if (opMode == EnumHelper.CameraOpMode.ContinuousMode)
|
||||||
|
// {
|
||||||
|
// device.MV_CC_SetEnumValue_NET("TriggerMode", 0);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// device.MV_CC_SetEnumValue_NET("TriggerMode", 1);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public void Snapshot(int pageBum, string napshotFileName)
|
||||||
|
{
|
||||||
|
//SnapshotCount = pageBum;
|
||||||
|
//SnapshotFileNames = napshotFileName;
|
||||||
|
|
||||||
|
Snapshot();
|
||||||
|
}
|
||||||
|
public void Snapshot()
|
||||||
|
{
|
||||||
|
Stopwatch sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
// ImageSet set = new ImageSet();
|
||||||
|
// set.SnapshotCount = SnapshotCount;
|
||||||
|
// set.SnapshotFileName = SnapshotFileNames;
|
||||||
|
|
||||||
|
//InitialImageSet(set);
|
||||||
|
MyCamera.MV_FRAME_OUT frameInfo = new MyCamera.MV_FRAME_OUT();
|
||||||
|
nRet = MyCamera.MV_OK;
|
||||||
|
if (true)
|
||||||
|
{
|
||||||
|
// ch: 触发命令 || en: Trigger command
|
||||||
|
nRet = device.MV_CC_SetCommandValue_NET("TriggerSoftware");
|
||||||
|
if (MyCamera.MV_OK != nRet)
|
||||||
|
{
|
||||||
|
throw new Exception($"相机拍照触发失败:{nRet}");
|
||||||
|
}
|
||||||
|
|
||||||
|
nRet = device.MV_CC_GetImageBuffer_NET(ref frameInfo, 1000);
|
||||||
|
nRet = device.MV_CC_FreeImageBuffer_NET(ref frameInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_snapHandle.Reset();
|
||||||
|
_snapFlag = true;
|
||||||
|
_snapHandle.WaitOne();
|
||||||
|
//lock (_imgCallBackLock)
|
||||||
|
{
|
||||||
|
frameInfo.stFrameInfo = _frame.stFrameInfo;
|
||||||
|
frameInfo.pBufAddr = _frame.pBufAddr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ch:获取一帧图像 | en:Get one image
|
||||||
|
if (MyCamera.MV_OK == nRet)
|
||||||
|
{
|
||||||
|
if (frameInfo.pBufAddr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
if (nRet == MyCamera.MV_OK)
|
||||||
|
{
|
||||||
|
var pFrameInfo = frameInfo.stFrameInfo;
|
||||||
|
|
||||||
|
Mat _mat = new Mat(pFrameInfo.nWidth, pFrameInfo.nHeight, MatType.CV_8UC3, frameInfo.pBufAddr);
|
||||||
|
OnHImageOutput?.Invoke(DateTime.Now, _mat, SnapshotCount);
|
||||||
|
// mat.ImWrite("D://123mat.jpg");
|
||||||
|
//HImage hImage = new HImage();
|
||||||
|
//HObject Hobj = new HObject();
|
||||||
|
//IntPtr pTemp = IntPtr.Zero;
|
||||||
|
//hImage.GenImage1("byte", pFrameInfo.nWidth, pFrameInfo.nHeight, frameInfo.pBufAddr);
|
||||||
|
|
||||||
|
////hImage.ConvertHImageTo16GrayBitmap();
|
||||||
|
//var imgSet = new ImageSet
|
||||||
|
//{
|
||||||
|
// HImage = hImage,
|
||||||
|
// ImageSaveOption = IConfig.ImageSaveOption.Copy()
|
||||||
|
//};
|
||||||
|
//if (pFrameInfo.enPixelType == MyCamera.MvGvspPixelType.PixelType_Gvsp_RGB8_Packed)
|
||||||
|
//{
|
||||||
|
// // Console.WriteLine("image pixel format is rgb8...");
|
||||||
|
// pTemp = frameInfo.pBufAddr;
|
||||||
|
// HOperatorSet.GenImageInterleaved(out Hobj, (HTuple)pTemp, (HTuple)"rgb", (HTuple)pFrameInfo.nWidth, (HTuple)pFrameInfo.nHeight, -1, "byte", 0, 0, 0, 0, -1, 0);
|
||||||
|
// HobjectToRGBHimage(Hobj, ref hImage);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//加入内部队列
|
||||||
|
//InitialImageSet(imgSet);
|
||||||
|
|
||||||
|
////业务图片处理加入外部队列
|
||||||
|
//var outImgSet = CopyImageSet(imgSet);
|
||||||
|
//OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"{Name}相机取像, 次数:{SnapshotCount}");
|
||||||
|
//DisplayAndSaveOriginImage(imgSet.Id);
|
||||||
|
//HikToBitmap(pFrameInfo, frameInfo.pBufAddr);
|
||||||
|
//Generate8GrayImageByPointer((int)nWidth, (int)nHeight, frameInfo.pBufAddr, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Grap Image Failed:{nRet:x8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.Stop();
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"取像耗时:{sw.ElapsedMilliseconds} ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
readonly MyCamera device = new MyCamera();
|
||||||
|
MyCamera.MV_CC_DEVICE_INFO stDevInfo = new MyCamera.MV_CC_DEVICE_INFO();
|
||||||
|
int nRet = MyCamera.MV_OK;
|
||||||
|
MyCamera.cbExceptiondelegate pCallBackFunc;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取曝光
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public double dvpGetExposure()
|
||||||
|
//{
|
||||||
|
// dvpStatus status;
|
||||||
|
// double exposure = 0;
|
||||||
|
// float gain = 0;
|
||||||
|
// if (IsValidHandle(m_handle))
|
||||||
|
// {
|
||||||
|
// // 读取曝光
|
||||||
|
// status = DVPCamera.dvpGetExposure(m_handle, ref exposure);
|
||||||
|
// if (status == dvpStatus.DVP_STATUS_OK)
|
||||||
|
// {
|
||||||
|
// //opConfig.Exposure = (float)exposure;
|
||||||
|
// return exposure;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return exposure;
|
||||||
|
//}
|
||||||
|
///// <summary>
|
||||||
|
///// 获取增益
|
||||||
|
///// </summary>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public float dvpGetAnalogGain()
|
||||||
|
//{
|
||||||
|
// dvpStatus status;
|
||||||
|
// double exposure = 0;
|
||||||
|
// float gain = 0;
|
||||||
|
// if (IsValidHandle(m_handle))
|
||||||
|
// {
|
||||||
|
// // 读取曝光
|
||||||
|
// status = DVPCamera.dvpGetAnalogGain(m_handle, ref gain);
|
||||||
|
// if (status == dvpStatus.DVP_STATUS_OK)
|
||||||
|
// {
|
||||||
|
// //opConfig.Exposure = (float)exposure;
|
||||||
|
// return gain;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return gain;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// ch:回调函数 | en:Callback function
|
||||||
|
//private void cbExceptiondelegate(uint nMsgType, IntPtr pUser)
|
||||||
|
//{
|
||||||
|
// if (nMsgType == MyCamera.MV_EXCEPTION_DEV_DISCONNECT)
|
||||||
|
// {
|
||||||
|
// if (CurrentState != EnumHelper.DeviceState.DSClose)
|
||||||
|
// {
|
||||||
|
// int reTryTimes = 3;
|
||||||
|
// do
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// Task.Delay(1000).Wait();
|
||||||
|
// Stop();
|
||||||
|
|
||||||
|
// Start();
|
||||||
|
// reTryTimes = -1;
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// reTryTimes--;
|
||||||
|
|
||||||
|
// if (reTryTimes > 0)
|
||||||
|
// {
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Information, $"{this.Name}重新连接异常,{ex.GetExceptionMessage()}");
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// throw ex;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } while (reTryTimes > 0);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
@ -8,12 +8,17 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Platforms>AnyCPU;X64</Platforms>
|
<Platforms>AnyCPU;X64</Platforms>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<ApplicationIcon>bin\X64\Debug\net7.0-windows\Logo.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="MelsecPLCTCPDriver.cs~RFacf25a.TMP" />
|
<None Remove="MelsecPLCTCPDriver.cs~RFacf25a.TMP" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="bin\X64\Debug\net7.0-windows\Logo.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
@ -24,6 +29,10 @@
|
|||||||
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
|
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\XKRS.UI\XKRS.UI.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="DVPCameraCS64">
|
<Reference Include="DVPCameraCS64">
|
||||||
<HintPath>..\libs\DVPCameraCS_Net6.0\x64\DVPCameraCS64.dll</HintPath>
|
<HintPath>..\libs\DVPCameraCS_Net6.0\x64\DVPCameraCS64.dll</HintPath>
|
||||||
@ -31,6 +40,9 @@
|
|||||||
<Reference Include="HslCommunication">
|
<Reference Include="HslCommunication">
|
||||||
<HintPath>..\libs\HslCommunication.dll</HintPath>
|
<HintPath>..\libs\HslCommunication.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="MvCameraControl.Net">
|
||||||
|
<HintPath>..\libs\HikCamera\MvCameraControl.Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="PaddleOCRSharp">
|
<Reference Include="PaddleOCRSharp">
|
||||||
<HintPath>bin\X64\Debug\net7.0-windows\PaddleOCRSharp.dll</HintPath>
|
<HintPath>bin\X64\Debug\net7.0-windows\PaddleOCRSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -44,8 +56,4 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
297
HisenceYoloDetection/MainForm.Designer.cs
generated
297
HisenceYoloDetection/MainForm.Designer.cs
generated
@ -29,6 +29,14 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
components = new System.ComponentModel.Container();
|
||||||
|
OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat4 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat5 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat6 = new OpenCvSharp.Mat();
|
||||||
|
OpenCvSharp.Mat mat7 = new OpenCvSharp.Mat();
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||||
tabPage2 = new TabPage();
|
tabPage2 = new TabPage();
|
||||||
panel1 = new Panel();
|
panel1 = new Panel();
|
||||||
groupBox5 = new GroupBox();
|
groupBox5 = new GroupBox();
|
||||||
@ -90,6 +98,8 @@
|
|||||||
showPLC = new TextBox();
|
showPLC = new TextBox();
|
||||||
readPLc = new TextBox();
|
readPLc = new TextBox();
|
||||||
tabPage1 = new TabPage();
|
tabPage1 = new TabPage();
|
||||||
|
CamShow2 = new XKRS.UI.Canvas();
|
||||||
|
CamShow1 = new XKRS.UI.Canvas();
|
||||||
groupBox3 = new GroupBox();
|
groupBox3 = new GroupBox();
|
||||||
SnapshotCam2 = new Button();
|
SnapshotCam2 = new Button();
|
||||||
button3 = new Button();
|
button3 = new Button();
|
||||||
@ -101,7 +111,6 @@
|
|||||||
tbExposure2 = new TextBox();
|
tbExposure2 = new TextBox();
|
||||||
label7 = new Label();
|
label7 = new Label();
|
||||||
label8 = new Label();
|
label8 = new Label();
|
||||||
pictureBox2 = new PictureBox();
|
|
||||||
groupBox1 = new GroupBox();
|
groupBox1 = new GroupBox();
|
||||||
SnapshotCam1 = new Button();
|
SnapshotCam1 = new Button();
|
||||||
button2 = new Button();
|
button2 = new Button();
|
||||||
@ -113,11 +122,11 @@
|
|||||||
tbExposure = new TextBox();
|
tbExposure = new TextBox();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
label4 = new Label();
|
label4 = new Label();
|
||||||
pictureBox1 = new PictureBox();
|
|
||||||
tabControl1 = new TabControl();
|
tabControl1 = new TabControl();
|
||||||
tabPage5 = new TabPage();
|
tabPage5 = new TabPage();
|
||||||
panel4 = new Panel();
|
panel4 = new Panel();
|
||||||
panel5 = new Panel();
|
panel5 = new Panel();
|
||||||
|
DefetShow5 = new XKRS.UI.Canvas();
|
||||||
panel8 = new Panel();
|
panel8 = new Panel();
|
||||||
RefeshData = new Button();
|
RefeshData = new Button();
|
||||||
实时显示 = new Label();
|
实时显示 = new Label();
|
||||||
@ -135,8 +144,11 @@
|
|||||||
InitMachine = new Button();
|
InitMachine = new Button();
|
||||||
panel6 = new Panel();
|
panel6 = new Panel();
|
||||||
groupBox2 = new GroupBox();
|
groupBox2 = new GroupBox();
|
||||||
ResultMat2Show = new PictureBox();
|
DefetShow4 = new XKRS.UI.Canvas();
|
||||||
|
DefetShow3 = new XKRS.UI.Canvas();
|
||||||
|
DefetShow2 = new XKRS.UI.Canvas();
|
||||||
originMat2Show = new PictureBox();
|
originMat2Show = new PictureBox();
|
||||||
|
DefetShow1 = new XKRS.UI.Canvas();
|
||||||
ResultMatShow2 = new PictureBox();
|
ResultMatShow2 = new PictureBox();
|
||||||
originMatShow2 = new PictureBox();
|
originMatShow2 = new PictureBox();
|
||||||
originMatShow = new PictureBox();
|
originMatShow = new PictureBox();
|
||||||
@ -146,7 +158,6 @@
|
|||||||
WhiteBanCbx = new CheckBox();
|
WhiteBanCbx = new CheckBox();
|
||||||
label33 = new Label();
|
label33 = new Label();
|
||||||
label28 = new Label();
|
label28 = new Label();
|
||||||
button1 = new Button();
|
|
||||||
openModelBtn = new Button();
|
openModelBtn = new Button();
|
||||||
modelChangeCbx = new TextBox();
|
modelChangeCbx = new TextBox();
|
||||||
label34 = new Label();
|
label34 = new Label();
|
||||||
@ -186,7 +197,6 @@
|
|||||||
timer6 = new System.Windows.Forms.Timer(components);
|
timer6 = new System.Windows.Forms.Timer(components);
|
||||||
richTextBox1 = new RichTextBox();
|
richTextBox1 = new RichTextBox();
|
||||||
contextMenuStrip1 = new ContextMenuStrip(components);
|
contextMenuStrip1 = new ContextMenuStrip(components);
|
||||||
dataGridView1 = new DataGridView();
|
|
||||||
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||||
tabPage2.SuspendLayout();
|
tabPage2.SuspendLayout();
|
||||||
panel1.SuspendLayout();
|
panel1.SuspendLayout();
|
||||||
@ -195,9 +205,7 @@
|
|||||||
ModeleShow.SuspendLayout();
|
ModeleShow.SuspendLayout();
|
||||||
tabPage1.SuspendLayout();
|
tabPage1.SuspendLayout();
|
||||||
groupBox3.SuspendLayout();
|
groupBox3.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
|
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
|
||||||
tabControl1.SuspendLayout();
|
tabControl1.SuspendLayout();
|
||||||
tabPage5.SuspendLayout();
|
tabPage5.SuspendLayout();
|
||||||
panel4.SuspendLayout();
|
panel4.SuspendLayout();
|
||||||
@ -206,7 +214,6 @@
|
|||||||
((System.ComponentModel.ISupportInitialize)OKOrNGShow).BeginInit();
|
((System.ComponentModel.ISupportInitialize)OKOrNGShow).BeginInit();
|
||||||
panel6.SuspendLayout();
|
panel6.SuspendLayout();
|
||||||
groupBox2.SuspendLayout();
|
groupBox2.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)ResultMat2Show).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)originMat2Show).BeginInit();
|
((System.ComponentModel.ISupportInitialize)originMat2Show).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)ResultMatShow2).BeginInit();
|
((System.ComponentModel.ISupportInitialize)ResultMatShow2).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)originMatShow2).BeginInit();
|
((System.ComponentModel.ISupportInitialize)originMatShow2).BeginInit();
|
||||||
@ -215,7 +222,6 @@
|
|||||||
tabPage3.SuspendLayout();
|
tabPage3.SuspendLayout();
|
||||||
panel2.SuspendLayout();
|
panel2.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)InsertDataDgv).BeginInit();
|
((System.ComponentModel.ISupportInitialize)InsertDataDgv).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// tabPage2
|
// tabPage2
|
||||||
@ -224,7 +230,7 @@
|
|||||||
tabPage2.Location = new Point(4, 26);
|
tabPage2.Location = new Point(4, 26);
|
||||||
tabPage2.Name = "tabPage2";
|
tabPage2.Name = "tabPage2";
|
||||||
tabPage2.Padding = new Padding(3);
|
tabPage2.Padding = new Padding(3);
|
||||||
tabPage2.Size = new Size(1276, 499);
|
tabPage2.Size = new Size(1319, 765);
|
||||||
tabPage2.TabIndex = 1;
|
tabPage2.TabIndex = 1;
|
||||||
tabPage2.Text = "PLC";
|
tabPage2.Text = "PLC";
|
||||||
tabPage2.UseVisualStyleBackColor = true;
|
tabPage2.UseVisualStyleBackColor = true;
|
||||||
@ -815,18 +821,60 @@
|
|||||||
//
|
//
|
||||||
// tabPage1
|
// tabPage1
|
||||||
//
|
//
|
||||||
|
tabPage1.Controls.Add(CamShow2);
|
||||||
|
tabPage1.Controls.Add(CamShow1);
|
||||||
tabPage1.Controls.Add(groupBox3);
|
tabPage1.Controls.Add(groupBox3);
|
||||||
tabPage1.Controls.Add(pictureBox2);
|
|
||||||
tabPage1.Controls.Add(groupBox1);
|
tabPage1.Controls.Add(groupBox1);
|
||||||
tabPage1.Controls.Add(pictureBox1);
|
|
||||||
tabPage1.Location = new Point(4, 26);
|
tabPage1.Location = new Point(4, 26);
|
||||||
tabPage1.Name = "tabPage1";
|
tabPage1.Name = "tabPage1";
|
||||||
tabPage1.Padding = new Padding(3);
|
tabPage1.Padding = new Padding(3);
|
||||||
tabPage1.Size = new Size(1276, 499);
|
tabPage1.Size = new Size(1319, 765);
|
||||||
tabPage1.TabIndex = 0;
|
tabPage1.TabIndex = 0;
|
||||||
tabPage1.Text = "相机";
|
tabPage1.Text = "相机";
|
||||||
tabPage1.UseVisualStyleBackColor = true;
|
tabPage1.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
// CamShow2
|
||||||
|
//
|
||||||
|
CamShow2.AllowSelectDefect = true;
|
||||||
|
CamShow2.BrushColor = null;
|
||||||
|
CamShow2.ImagePath = "";
|
||||||
|
mat1.IsEnabledDispose = true;
|
||||||
|
CamShow2.ImaMAt = mat1;
|
||||||
|
CamShow2.ImgData = null;
|
||||||
|
CamShow2.Location = new Point(578, 6);
|
||||||
|
CamShow2.MoveStep = 5F;
|
||||||
|
CamShow2.Name = "CamShow2";
|
||||||
|
CamShow2.Route = 0D;
|
||||||
|
CamShow2.Scale = 1D;
|
||||||
|
CamShow2.Size = new Size(690, 310);
|
||||||
|
CamShow2.TabIndex = 21;
|
||||||
|
CamShow2.WholeScale = 0F;
|
||||||
|
CamShow2.XMove = 0F;
|
||||||
|
CamShow2.XScale = 0F;
|
||||||
|
CamShow2.YMove = 0F;
|
||||||
|
CamShow2.YScale = 0F;
|
||||||
|
//
|
||||||
|
// CamShow1
|
||||||
|
//
|
||||||
|
CamShow1.AllowSelectDefect = true;
|
||||||
|
CamShow1.BrushColor = null;
|
||||||
|
CamShow1.ImagePath = "";
|
||||||
|
mat2.IsEnabledDispose = true;
|
||||||
|
CamShow1.ImaMAt = mat2;
|
||||||
|
CamShow1.ImgData = null;
|
||||||
|
CamShow1.Location = new Point(14, 6);
|
||||||
|
CamShow1.MoveStep = 5F;
|
||||||
|
CamShow1.Name = "CamShow1";
|
||||||
|
CamShow1.Route = 0D;
|
||||||
|
CamShow1.Scale = 1D;
|
||||||
|
CamShow1.Size = new Size(546, 293);
|
||||||
|
CamShow1.TabIndex = 20;
|
||||||
|
CamShow1.WholeScale = 0F;
|
||||||
|
CamShow1.XMove = 0F;
|
||||||
|
CamShow1.XScale = 0F;
|
||||||
|
CamShow1.YMove = 0F;
|
||||||
|
CamShow1.YScale = 0F;
|
||||||
|
//
|
||||||
// groupBox3
|
// groupBox3
|
||||||
//
|
//
|
||||||
groupBox3.Controls.Add(SnapshotCam2);
|
groupBox3.Controls.Add(SnapshotCam2);
|
||||||
@ -936,15 +984,6 @@
|
|||||||
label8.TabIndex = 0;
|
label8.TabIndex = 0;
|
||||||
label8.Text = "曝光";
|
label8.Text = "曝光";
|
||||||
//
|
//
|
||||||
// pictureBox2
|
|
||||||
//
|
|
||||||
pictureBox2.Location = new Point(566, 6);
|
|
||||||
pictureBox2.Name = "pictureBox2";
|
|
||||||
pictureBox2.Size = new Size(464, 293);
|
|
||||||
pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
||||||
pictureBox2.TabIndex = 18;
|
|
||||||
pictureBox2.TabStop = false;
|
|
||||||
//
|
|
||||||
// groupBox1
|
// groupBox1
|
||||||
//
|
//
|
||||||
groupBox1.Controls.Add(SnapshotCam1);
|
groupBox1.Controls.Add(SnapshotCam1);
|
||||||
@ -993,6 +1032,7 @@
|
|||||||
bnSetParam.TabIndex = 7;
|
bnSetParam.TabIndex = 7;
|
||||||
bnSetParam.Text = "设置参数";
|
bnSetParam.Text = "设置参数";
|
||||||
bnSetParam.UseVisualStyleBackColor = true;
|
bnSetParam.UseVisualStyleBackColor = true;
|
||||||
|
bnSetParam.Click += bnSetParam_Click;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
@ -1055,15 +1095,6 @@
|
|||||||
label4.TabIndex = 0;
|
label4.TabIndex = 0;
|
||||||
label4.Text = "曝光";
|
label4.Text = "曝光";
|
||||||
//
|
//
|
||||||
// pictureBox1
|
|
||||||
//
|
|
||||||
pictureBox1.Location = new Point(8, 6);
|
|
||||||
pictureBox1.Name = "pictureBox1";
|
|
||||||
pictureBox1.Size = new Size(535, 293);
|
|
||||||
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
||||||
pictureBox1.TabIndex = 0;
|
|
||||||
pictureBox1.TabStop = false;
|
|
||||||
//
|
|
||||||
// tabControl1
|
// tabControl1
|
||||||
//
|
//
|
||||||
tabControl1.Controls.Add(tabPage1);
|
tabControl1.Controls.Add(tabPage1);
|
||||||
@ -1074,7 +1105,7 @@
|
|||||||
tabControl1.Location = new Point(0, 0);
|
tabControl1.Location = new Point(0, 0);
|
||||||
tabControl1.Name = "tabControl1";
|
tabControl1.Name = "tabControl1";
|
||||||
tabControl1.SelectedIndex = 0;
|
tabControl1.SelectedIndex = 0;
|
||||||
tabControl1.Size = new Size(1284, 529);
|
tabControl1.Size = new Size(1327, 795);
|
||||||
tabControl1.TabIndex = 0;
|
tabControl1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// tabPage5
|
// tabPage5
|
||||||
@ -1082,7 +1113,7 @@
|
|||||||
tabPage5.Controls.Add(panel4);
|
tabPage5.Controls.Add(panel4);
|
||||||
tabPage5.Location = new Point(4, 26);
|
tabPage5.Location = new Point(4, 26);
|
||||||
tabPage5.Name = "tabPage5";
|
tabPage5.Name = "tabPage5";
|
||||||
tabPage5.Size = new Size(1276, 499);
|
tabPage5.Size = new Size(1319, 765);
|
||||||
tabPage5.TabIndex = 3;
|
tabPage5.TabIndex = 3;
|
||||||
tabPage5.Text = "流程";
|
tabPage5.Text = "流程";
|
||||||
tabPage5.UseVisualStyleBackColor = true;
|
tabPage5.UseVisualStyleBackColor = true;
|
||||||
@ -1093,19 +1124,41 @@
|
|||||||
panel4.Dock = DockStyle.Fill;
|
panel4.Dock = DockStyle.Fill;
|
||||||
panel4.Location = new Point(0, 0);
|
panel4.Location = new Point(0, 0);
|
||||||
panel4.Name = "panel4";
|
panel4.Name = "panel4";
|
||||||
panel4.Size = new Size(1276, 499);
|
panel4.Size = new Size(1319, 765);
|
||||||
panel4.TabIndex = 0;
|
panel4.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// panel5
|
// panel5
|
||||||
//
|
//
|
||||||
|
panel5.Controls.Add(DefetShow5);
|
||||||
panel5.Controls.Add(panel8);
|
panel5.Controls.Add(panel8);
|
||||||
panel5.Controls.Add(panel6);
|
panel5.Controls.Add(panel6);
|
||||||
panel5.Dock = DockStyle.Top;
|
panel5.Dock = DockStyle.Top;
|
||||||
panel5.Location = new Point(0, 0);
|
panel5.Location = new Point(0, 0);
|
||||||
panel5.Name = "panel5";
|
panel5.Name = "panel5";
|
||||||
panel5.Size = new Size(1276, 577);
|
panel5.Size = new Size(1319, 762);
|
||||||
panel5.TabIndex = 0;
|
panel5.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// DefetShow5
|
||||||
|
//
|
||||||
|
DefetShow5.AllowSelectDefect = true;
|
||||||
|
DefetShow5.BrushColor = null;
|
||||||
|
DefetShow5.ImagePath = "";
|
||||||
|
mat3.IsEnabledDispose = true;
|
||||||
|
DefetShow5.ImaMAt = mat3;
|
||||||
|
DefetShow5.ImgData = null;
|
||||||
|
DefetShow5.Location = new Point(853, 464);
|
||||||
|
DefetShow5.MoveStep = 5F;
|
||||||
|
DefetShow5.Name = "DefetShow5";
|
||||||
|
DefetShow5.Route = 0D;
|
||||||
|
DefetShow5.Scale = 1D;
|
||||||
|
DefetShow5.Size = new Size(254, 196);
|
||||||
|
DefetShow5.TabIndex = 10;
|
||||||
|
DefetShow5.WholeScale = 0F;
|
||||||
|
DefetShow5.XMove = 0F;
|
||||||
|
DefetShow5.XScale = 0F;
|
||||||
|
DefetShow5.YMove = 0F;
|
||||||
|
DefetShow5.YScale = 0F;
|
||||||
|
//
|
||||||
// panel8
|
// panel8
|
||||||
//
|
//
|
||||||
panel8.Controls.Add(RefeshData);
|
panel8.Controls.Add(RefeshData);
|
||||||
@ -1124,13 +1177,13 @@
|
|||||||
panel8.Controls.Add(InitMachine);
|
panel8.Controls.Add(InitMachine);
|
||||||
panel8.Location = new Point(853, 0);
|
panel8.Location = new Point(853, 0);
|
||||||
panel8.Name = "panel8";
|
panel8.Name = "panel8";
|
||||||
panel8.Size = new Size(440, 496);
|
panel8.Size = new Size(440, 458);
|
||||||
panel8.TabIndex = 2;
|
panel8.TabIndex = 2;
|
||||||
panel8.Paint += panel8_Paint;
|
panel8.Paint += panel8_Paint;
|
||||||
//
|
//
|
||||||
// RefeshData
|
// RefeshData
|
||||||
//
|
//
|
||||||
RefeshData.Location = new Point(38, 442);
|
RefeshData.Location = new Point(24, 340);
|
||||||
RefeshData.Name = "RefeshData";
|
RefeshData.Name = "RefeshData";
|
||||||
RefeshData.Size = new Size(94, 43);
|
RefeshData.Size = new Size(94, 43);
|
||||||
RefeshData.TabIndex = 13;
|
RefeshData.TabIndex = 13;
|
||||||
@ -1261,46 +1314,125 @@
|
|||||||
panel6.Controls.Add(groupBox2);
|
panel6.Controls.Add(groupBox2);
|
||||||
panel6.Location = new Point(0, 0);
|
panel6.Location = new Point(0, 0);
|
||||||
panel6.Name = "panel6";
|
panel6.Name = "panel6";
|
||||||
panel6.Size = new Size(847, 531);
|
panel6.Size = new Size(847, 759);
|
||||||
panel6.TabIndex = 1;
|
panel6.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// groupBox2
|
// groupBox2
|
||||||
//
|
//
|
||||||
groupBox2.AutoSize = true;
|
groupBox2.AutoSize = true;
|
||||||
groupBox2.Controls.Add(ResultMat2Show);
|
groupBox2.Controls.Add(DefetShow4);
|
||||||
|
groupBox2.Controls.Add(DefetShow3);
|
||||||
|
groupBox2.Controls.Add(DefetShow2);
|
||||||
groupBox2.Controls.Add(originMat2Show);
|
groupBox2.Controls.Add(originMat2Show);
|
||||||
|
groupBox2.Controls.Add(DefetShow1);
|
||||||
groupBox2.Controls.Add(ResultMatShow2);
|
groupBox2.Controls.Add(ResultMatShow2);
|
||||||
groupBox2.Controls.Add(originMatShow2);
|
groupBox2.Controls.Add(originMatShow2);
|
||||||
groupBox2.Controls.Add(originMatShow);
|
groupBox2.Controls.Add(originMatShow);
|
||||||
groupBox2.Controls.Add(ResultMatShow);
|
groupBox2.Controls.Add(ResultMatShow);
|
||||||
groupBox2.Location = new Point(8, 4);
|
groupBox2.Location = new Point(8, 4);
|
||||||
groupBox2.Name = "groupBox2";
|
groupBox2.Name = "groupBox2";
|
||||||
groupBox2.Size = new Size(839, 493);
|
groupBox2.Size = new Size(885, 768);
|
||||||
groupBox2.TabIndex = 0;
|
groupBox2.TabIndex = 0;
|
||||||
groupBox2.TabStop = false;
|
groupBox2.TabStop = false;
|
||||||
groupBox2.Text = "图片";
|
groupBox2.Text = "图片";
|
||||||
|
groupBox2.Enter += groupBox2_Enter;
|
||||||
//
|
//
|
||||||
// ResultMat2Show
|
// DefetShow4
|
||||||
//
|
//
|
||||||
ResultMat2Show.Location = new Point(574, 245);
|
DefetShow4.AllowSelectDefect = true;
|
||||||
ResultMat2Show.Name = "ResultMat2Show";
|
DefetShow4.BrushColor = null;
|
||||||
ResultMat2Show.Size = new Size(259, 213);
|
DefetShow4.ImagePath = "";
|
||||||
ResultMat2Show.SizeMode = PictureBoxSizeMode.StretchImage;
|
mat4.IsEnabledDispose = true;
|
||||||
ResultMat2Show.TabIndex = 7;
|
DefetShow4.ImaMAt = mat4;
|
||||||
ResultMat2Show.TabStop = false;
|
DefetShow4.ImgData = null;
|
||||||
|
DefetShow4.Location = new Point(574, 460);
|
||||||
|
DefetShow4.MoveStep = 5F;
|
||||||
|
DefetShow4.Name = "DefetShow4";
|
||||||
|
DefetShow4.Route = 0D;
|
||||||
|
DefetShow4.Scale = 1D;
|
||||||
|
DefetShow4.Size = new Size(265, 196);
|
||||||
|
DefetShow4.TabIndex = 11;
|
||||||
|
DefetShow4.WholeScale = 0F;
|
||||||
|
DefetShow4.XMove = 0F;
|
||||||
|
DefetShow4.XScale = 0F;
|
||||||
|
DefetShow4.YMove = 0F;
|
||||||
|
DefetShow4.YScale = 0F;
|
||||||
|
//
|
||||||
|
// DefetShow3
|
||||||
|
//
|
||||||
|
DefetShow3.AllowSelectDefect = true;
|
||||||
|
DefetShow3.BrushColor = null;
|
||||||
|
DefetShow3.ImagePath = "";
|
||||||
|
mat5.IsEnabledDispose = true;
|
||||||
|
DefetShow3.ImaMAt = mat5;
|
||||||
|
DefetShow3.ImgData = null;
|
||||||
|
DefetShow3.Location = new Point(303, 460);
|
||||||
|
DefetShow3.MoveStep = 5F;
|
||||||
|
DefetShow3.Name = "DefetShow3";
|
||||||
|
DefetShow3.Route = 0D;
|
||||||
|
DefetShow3.Scale = 1D;
|
||||||
|
DefetShow3.Size = new Size(265, 196);
|
||||||
|
DefetShow3.TabIndex = 10;
|
||||||
|
DefetShow3.WholeScale = 0F;
|
||||||
|
DefetShow3.XMove = 0F;
|
||||||
|
DefetShow3.XScale = 0F;
|
||||||
|
DefetShow3.YMove = 0F;
|
||||||
|
DefetShow3.YScale = 0F;
|
||||||
|
//
|
||||||
|
// DefetShow2
|
||||||
|
//
|
||||||
|
DefetShow2.AllowSelectDefect = true;
|
||||||
|
DefetShow2.BrushColor = null;
|
||||||
|
DefetShow2.ImagePath = "";
|
||||||
|
mat6.IsEnabledDispose = true;
|
||||||
|
DefetShow2.ImaMAt = mat6;
|
||||||
|
DefetShow2.ImgData = null;
|
||||||
|
DefetShow2.Location = new Point(6, 460);
|
||||||
|
DefetShow2.MoveStep = 5F;
|
||||||
|
DefetShow2.Name = "DefetShow2";
|
||||||
|
DefetShow2.Route = 0D;
|
||||||
|
DefetShow2.Scale = 1D;
|
||||||
|
DefetShow2.Size = new Size(285, 196);
|
||||||
|
DefetShow2.TabIndex = 9;
|
||||||
|
DefetShow2.WholeScale = 0F;
|
||||||
|
DefetShow2.XMove = 0F;
|
||||||
|
DefetShow2.XScale = 0F;
|
||||||
|
DefetShow2.YMove = 0F;
|
||||||
|
DefetShow2.YScale = 0F;
|
||||||
//
|
//
|
||||||
// originMat2Show
|
// originMat2Show
|
||||||
//
|
//
|
||||||
originMat2Show.Location = new Point(574, 22);
|
originMat2Show.Location = new Point(574, 21);
|
||||||
originMat2Show.Name = "originMat2Show";
|
originMat2Show.Name = "originMat2Show";
|
||||||
originMat2Show.Size = new Size(259, 213);
|
originMat2Show.Size = new Size(271, 213);
|
||||||
originMat2Show.SizeMode = PictureBoxSizeMode.StretchImage;
|
originMat2Show.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
originMat2Show.TabIndex = 6;
|
originMat2Show.TabIndex = 8;
|
||||||
originMat2Show.TabStop = false;
|
originMat2Show.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// DefetShow1
|
||||||
|
//
|
||||||
|
DefetShow1.AllowSelectDefect = true;
|
||||||
|
DefetShow1.BrushColor = null;
|
||||||
|
DefetShow1.ImagePath = "";
|
||||||
|
mat7.IsEnabledDispose = true;
|
||||||
|
DefetShow1.ImaMAt = mat7;
|
||||||
|
DefetShow1.ImgData = null;
|
||||||
|
DefetShow1.Location = new Point(574, 245);
|
||||||
|
DefetShow1.MoveStep = 5F;
|
||||||
|
DefetShow1.Name = "DefetShow1";
|
||||||
|
DefetShow1.Route = 0D;
|
||||||
|
DefetShow1.Scale = 1D;
|
||||||
|
DefetShow1.Size = new Size(262, 209);
|
||||||
|
DefetShow1.TabIndex = 7;
|
||||||
|
DefetShow1.WholeScale = 0F;
|
||||||
|
DefetShow1.XMove = 0F;
|
||||||
|
DefetShow1.XScale = 0F;
|
||||||
|
DefetShow1.YMove = 0F;
|
||||||
|
DefetShow1.YScale = 0F;
|
||||||
|
//
|
||||||
// ResultMatShow2
|
// ResultMatShow2
|
||||||
//
|
//
|
||||||
ResultMatShow2.Location = new Point(297, 246);
|
ResultMatShow2.Location = new Point(297, 241);
|
||||||
ResultMatShow2.Name = "ResultMatShow2";
|
ResultMatShow2.Name = "ResultMatShow2";
|
||||||
ResultMatShow2.Size = new Size(271, 213);
|
ResultMatShow2.Size = new Size(271, 213);
|
||||||
ResultMatShow2.SizeMode = PictureBoxSizeMode.StretchImage;
|
ResultMatShow2.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
@ -1309,7 +1441,7 @@
|
|||||||
//
|
//
|
||||||
// originMatShow2
|
// originMatShow2
|
||||||
//
|
//
|
||||||
originMatShow2.Location = new Point(6, 250);
|
originMatShow2.Location = new Point(6, 241);
|
||||||
originMatShow2.Name = "originMatShow2";
|
originMatShow2.Name = "originMatShow2";
|
||||||
originMatShow2.Size = new Size(285, 213);
|
originMatShow2.Size = new Size(285, 213);
|
||||||
originMatShow2.SizeMode = PictureBoxSizeMode.StretchImage;
|
originMatShow2.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
@ -1339,7 +1471,7 @@
|
|||||||
tabPage3.Controls.Add(panel2);
|
tabPage3.Controls.Add(panel2);
|
||||||
tabPage3.Location = new Point(4, 26);
|
tabPage3.Location = new Point(4, 26);
|
||||||
tabPage3.Name = "tabPage3";
|
tabPage3.Name = "tabPage3";
|
||||||
tabPage3.Size = new Size(1276, 499);
|
tabPage3.Size = new Size(1319, 765);
|
||||||
tabPage3.TabIndex = 4;
|
tabPage3.TabIndex = 4;
|
||||||
tabPage3.Text = "录入新型号";
|
tabPage3.Text = "录入新型号";
|
||||||
tabPage3.UseVisualStyleBackColor = true;
|
tabPage3.UseVisualStyleBackColor = true;
|
||||||
@ -1349,7 +1481,6 @@
|
|||||||
panel2.Controls.Add(WhiteBanCbx);
|
panel2.Controls.Add(WhiteBanCbx);
|
||||||
panel2.Controls.Add(label33);
|
panel2.Controls.Add(label33);
|
||||||
panel2.Controls.Add(label28);
|
panel2.Controls.Add(label28);
|
||||||
panel2.Controls.Add(button1);
|
|
||||||
panel2.Controls.Add(openModelBtn);
|
panel2.Controls.Add(openModelBtn);
|
||||||
panel2.Controls.Add(modelChangeCbx);
|
panel2.Controls.Add(modelChangeCbx);
|
||||||
panel2.Controls.Add(label34);
|
panel2.Controls.Add(label34);
|
||||||
@ -1402,7 +1533,7 @@
|
|||||||
// label33
|
// label33
|
||||||
//
|
//
|
||||||
label33.AutoSize = true;
|
label33.AutoSize = true;
|
||||||
label33.Location = new Point(373, 245);
|
label33.Location = new Point(366, 246);
|
||||||
label33.Name = "label33";
|
label33.Name = "label33";
|
||||||
label33.Size = new Size(140, 17);
|
label33.Size = new Size(140, 17);
|
||||||
label33.TabIndex = 39;
|
label33.TabIndex = 39;
|
||||||
@ -1417,15 +1548,6 @@
|
|||||||
label28.TabIndex = 14;
|
label28.TabIndex = 14;
|
||||||
label28.Text = "第一次拍照Z轴";
|
label28.Text = "第一次拍照Z轴";
|
||||||
//
|
//
|
||||||
// button1
|
|
||||||
//
|
|
||||||
button1.Location = new Point(896, 110);
|
|
||||||
button1.Name = "button1";
|
|
||||||
button1.Size = new Size(93, 23);
|
|
||||||
button1.TabIndex = 38;
|
|
||||||
button1.Text = "识别到log";
|
|
||||||
button1.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// openModelBtn
|
// openModelBtn
|
||||||
//
|
//
|
||||||
openModelBtn.Location = new Point(1042, 15);
|
openModelBtn.Location = new Point(1042, 15);
|
||||||
@ -1455,7 +1577,7 @@
|
|||||||
//
|
//
|
||||||
// button4
|
// button4
|
||||||
//
|
//
|
||||||
button4.Location = new Point(691, 110);
|
button4.Location = new Point(697, 110);
|
||||||
button4.Name = "button4";
|
button4.Name = "button4";
|
||||||
button4.Size = new Size(75, 23);
|
button4.Size = new Size(75, 23);
|
||||||
button4.TabIndex = 32;
|
button4.TabIndex = 32;
|
||||||
@ -1465,7 +1587,7 @@
|
|||||||
//
|
//
|
||||||
// OpenTwoDirBtn
|
// OpenTwoDirBtn
|
||||||
//
|
//
|
||||||
OpenTwoDirBtn.Location = new Point(691, 199);
|
OpenTwoDirBtn.Location = new Point(697, 202);
|
||||||
OpenTwoDirBtn.Name = "OpenTwoDirBtn";
|
OpenTwoDirBtn.Name = "OpenTwoDirBtn";
|
||||||
OpenTwoDirBtn.Size = new Size(75, 23);
|
OpenTwoDirBtn.Size = new Size(75, 23);
|
||||||
OpenTwoDirBtn.TabIndex = 31;
|
OpenTwoDirBtn.TabIndex = 31;
|
||||||
@ -1475,7 +1597,7 @@
|
|||||||
//
|
//
|
||||||
// OpenDirBtn
|
// OpenDirBtn
|
||||||
//
|
//
|
||||||
OpenDirBtn.Location = new Point(691, 151);
|
OpenDirBtn.Location = new Point(697, 154);
|
||||||
OpenDirBtn.Name = "OpenDirBtn";
|
OpenDirBtn.Name = "OpenDirBtn";
|
||||||
OpenDirBtn.Size = new Size(75, 23);
|
OpenDirBtn.Size = new Size(75, 23);
|
||||||
OpenDirBtn.TabIndex = 30;
|
OpenDirBtn.TabIndex = 30;
|
||||||
@ -1538,7 +1660,7 @@
|
|||||||
// label24
|
// label24
|
||||||
//
|
//
|
||||||
label24.AutoSize = true;
|
label24.AutoSize = true;
|
||||||
label24.Location = new Point(397, 116);
|
label24.Location = new Point(366, 116);
|
||||||
label24.Name = "label24";
|
label24.Name = "label24";
|
||||||
label24.Size = new Size(56, 17);
|
label24.Size = new Size(56, 17);
|
||||||
label24.TabIndex = 23;
|
label24.TabIndex = 23;
|
||||||
@ -1575,7 +1697,7 @@
|
|||||||
//
|
//
|
||||||
moveTwoYbox.Location = new Point(472, 12);
|
moveTwoYbox.Location = new Point(472, 12);
|
||||||
moveTwoYbox.Name = "moveTwoYbox";
|
moveTwoYbox.Name = "moveTwoYbox";
|
||||||
moveTwoYbox.Size = new Size(213, 23);
|
moveTwoYbox.Size = new Size(219, 23);
|
||||||
moveTwoYbox.TabIndex = 19;
|
moveTwoYbox.TabIndex = 19;
|
||||||
moveTwoYbox.Text = "0";
|
moveTwoYbox.Text = "0";
|
||||||
//
|
//
|
||||||
@ -1590,9 +1712,9 @@
|
|||||||
//
|
//
|
||||||
// moveTwoXbox
|
// moveTwoXbox
|
||||||
//
|
//
|
||||||
moveTwoXbox.Location = new Point(122, 242);
|
moveTwoXbox.Location = new Point(111, 243);
|
||||||
moveTwoXbox.Name = "moveTwoXbox";
|
moveTwoXbox.Name = "moveTwoXbox";
|
||||||
moveTwoXbox.Size = new Size(213, 23);
|
moveTwoXbox.Size = new Size(224, 23);
|
||||||
moveTwoXbox.TabIndex = 17;
|
moveTwoXbox.TabIndex = 17;
|
||||||
moveTwoXbox.Text = "54964";
|
moveTwoXbox.Text = "54964";
|
||||||
//
|
//
|
||||||
@ -1705,7 +1827,7 @@
|
|||||||
richTextBox1.Dock = DockStyle.Bottom;
|
richTextBox1.Dock = DockStyle.Bottom;
|
||||||
richTextBox1.Location = new Point(0, 801);
|
richTextBox1.Location = new Point(0, 801);
|
||||||
richTextBox1.Name = "richTextBox1";
|
richTextBox1.Name = "richTextBox1";
|
||||||
richTextBox1.Size = new Size(1284, 176);
|
richTextBox1.Size = new Size(1327, 176);
|
||||||
richTextBox1.TabIndex = 1;
|
richTextBox1.TabIndex = 1;
|
||||||
richTextBox1.Text = "";
|
richTextBox1.Text = "";
|
||||||
//
|
//
|
||||||
@ -1714,24 +1836,14 @@
|
|||||||
contextMenuStrip1.Name = "contextMenuStrip1";
|
contextMenuStrip1.Name = "contextMenuStrip1";
|
||||||
contextMenuStrip1.Size = new Size(61, 4);
|
contextMenuStrip1.Size = new Size(61, 4);
|
||||||
//
|
//
|
||||||
// dataGridView1
|
|
||||||
//
|
|
||||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridView1.Dock = DockStyle.Fill;
|
|
||||||
dataGridView1.Location = new Point(0, 529);
|
|
||||||
dataGridView1.Name = "dataGridView1";
|
|
||||||
dataGridView1.RowTemplate.Height = 25;
|
|
||||||
dataGridView1.Size = new Size(1284, 272);
|
|
||||||
dataGridView1.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(1284, 977);
|
ClientSize = new Size(1327, 977);
|
||||||
Controls.Add(dataGridView1);
|
|
||||||
Controls.Add(richTextBox1);
|
Controls.Add(richTextBox1);
|
||||||
Controls.Add(tabControl1);
|
Controls.Add(tabControl1);
|
||||||
|
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
Text = "海信视觉防差错";
|
Text = "海信视觉防差错";
|
||||||
Load += MainForm_Load;
|
Load += MainForm_Load;
|
||||||
@ -1746,10 +1858,8 @@
|
|||||||
tabPage1.ResumeLayout(false);
|
tabPage1.ResumeLayout(false);
|
||||||
groupBox3.ResumeLayout(false);
|
groupBox3.ResumeLayout(false);
|
||||||
groupBox3.PerformLayout();
|
groupBox3.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
|
|
||||||
groupBox1.ResumeLayout(false);
|
groupBox1.ResumeLayout(false);
|
||||||
groupBox1.PerformLayout();
|
groupBox1.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
|
||||||
tabControl1.ResumeLayout(false);
|
tabControl1.ResumeLayout(false);
|
||||||
tabPage5.ResumeLayout(false);
|
tabPage5.ResumeLayout(false);
|
||||||
panel4.ResumeLayout(false);
|
panel4.ResumeLayout(false);
|
||||||
@ -1760,7 +1870,6 @@
|
|||||||
panel6.ResumeLayout(false);
|
panel6.ResumeLayout(false);
|
||||||
panel6.PerformLayout();
|
panel6.PerformLayout();
|
||||||
groupBox2.ResumeLayout(false);
|
groupBox2.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)ResultMat2Show).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)originMat2Show).EndInit();
|
((System.ComponentModel.ISupportInitialize)originMat2Show).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)ResultMatShow2).EndInit();
|
((System.ComponentModel.ISupportInitialize)ResultMatShow2).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)originMatShow2).EndInit();
|
((System.ComponentModel.ISupportInitialize)originMatShow2).EndInit();
|
||||||
@ -1770,7 +1879,6 @@
|
|||||||
panel2.ResumeLayout(false);
|
panel2.ResumeLayout(false);
|
||||||
panel2.PerformLayout();
|
panel2.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)InsertDataDgv).EndInit();
|
((System.ComponentModel.ISupportInitialize)InsertDataDgv).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1779,7 +1887,6 @@
|
|||||||
private TabPage tabPage1;
|
private TabPage tabPage1;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Button Cam1OpenBtn;
|
private Button Cam1OpenBtn;
|
||||||
private PictureBox pictureBox1;
|
|
||||||
private TabControl tabControl1;
|
private TabControl tabControl1;
|
||||||
private TabPage tabPage5;
|
private TabPage tabPage5;
|
||||||
private Panel panel4;
|
private Panel panel4;
|
||||||
@ -1797,7 +1904,6 @@
|
|||||||
private TextBox tbExposure;
|
private TextBox tbExposure;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label4;
|
private Label label4;
|
||||||
private PictureBox pictureBox2;
|
|
||||||
private Button button2;
|
private Button button2;
|
||||||
private Button SnapshotCam1;
|
private Button SnapshotCam1;
|
||||||
private Button InitMachine;
|
private Button InitMachine;
|
||||||
@ -1851,7 +1957,6 @@
|
|||||||
private Label label15;
|
private Label label15;
|
||||||
private Button StartDecBtn;
|
private Button StartDecBtn;
|
||||||
private ContextMenuStrip contextMenuStrip1;
|
private ContextMenuStrip contextMenuStrip1;
|
||||||
private DataGridView dataGridView1;
|
|
||||||
private Button InsertSqlBtn;
|
private Button InsertSqlBtn;
|
||||||
private PictureBox ResultMatShow2;
|
private PictureBox ResultMatShow2;
|
||||||
private PictureBox originMatShow2;
|
private PictureBox originMatShow2;
|
||||||
@ -1896,8 +2001,6 @@
|
|||||||
private GroupBox groupBox5;
|
private GroupBox groupBox5;
|
||||||
private TextBox DistanceShow;
|
private TextBox DistanceShow;
|
||||||
private Label label21;
|
private Label label21;
|
||||||
private PictureBox originMat2Show;
|
|
||||||
private PictureBox ResultMat2Show;
|
|
||||||
private TabPage tabPage3;
|
private TabPage tabPage3;
|
||||||
private Panel panel2;
|
private Panel panel2;
|
||||||
private Button button4;
|
private Button button4;
|
||||||
@ -1935,5 +2038,13 @@
|
|||||||
private Button button1;
|
private Button button1;
|
||||||
private Label label33;
|
private Label label33;
|
||||||
private CheckBox WhiteBanCbx;
|
private CheckBox WhiteBanCbx;
|
||||||
|
private XKRS.UI.Canvas DefetShow1;
|
||||||
|
private XKRS.UI.Canvas CamShow1;
|
||||||
|
private XKRS.UI.Canvas CamShow2;
|
||||||
|
private XKRS.UI.Canvas DefetShow5;
|
||||||
|
private XKRS.UI.Canvas DefetShow4;
|
||||||
|
private XKRS.UI.Canvas DefetShow3;
|
||||||
|
private XKRS.UI.Canvas DefetShow2;
|
||||||
|
private PictureBox originMat2Show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,16 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
MGSCameraDriver Cam1 = new MGSCameraDriver();
|
MGSCameraDriver Cam1 = new MGSCameraDriver();
|
||||||
MGSCameraDriver Cam2 = new MGSCameraDriver();
|
MGSCameraDriver Cam2 = new MGSCameraDriver();
|
||||||
|
|
||||||
|
// HikCameraDriver Cam1 = new HikCameraDriver();
|
||||||
|
//HikCameraDriver Cam2 = new HikCameraDriver();
|
||||||
|
|
||||||
SQLiteHelper sqlhelper = new SQLiteHelper();
|
SQLiteHelper sqlhelper = new SQLiteHelper();
|
||||||
TCPClienDriver Scanner = new TCPClienDriver();
|
TCPClienDriver Scanner = new TCPClienDriver();
|
||||||
MelsecPLCTCPDriver melsecPLCTCPDriver = new MelsecPLCTCPDriver();
|
MelsecPLCTCPDriver melsecPLCTCPDriver = new MelsecPLCTCPDriver();
|
||||||
SimboObjectDetection simboObjectDetection = new SimboObjectDetection();
|
SimboObjectDetection simboObjectDetection = new SimboObjectDetection();
|
||||||
SimboObjectDetection simboObjectDetButton = new SimboObjectDetection();
|
SimboObjectDetection simboObjectDetButton = new SimboObjectDetection();
|
||||||
// CheckDiffSciHelper checkDiffSciHelper = new CheckDiffSciHelper();
|
// CheckDiffSciHelper checkDiffSciHelper = new CheckDiffSciHelper();
|
||||||
// ManagerModelHelper managerModelHelper = new ManagerModelHelper();
|
// ManagerModelHelper managerModelHelper = new ManagerModelHelper();
|
||||||
|
|
||||||
PaddleOcrModel paddleOcrModel = new PaddleOcrModel();
|
PaddleOcrModel paddleOcrModel = new PaddleOcrModel();
|
||||||
@ -172,9 +176,9 @@ namespace HisenceYoloDetection
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void MainForm_Load(object sender, EventArgs e)
|
private void MainForm_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
string vBarPath = "D:\\Hisence\\类型\\Lp\\202452414231.jpg";
|
string vBarPath = "D:\\Hisence\\类型\\Lp\\202452414231.jpg";
|
||||||
string vCam1OnePath = "D:\\Hisence\\类型\\Lp\\001.jpg";
|
string vCam1OnePath = "D:\\Hisence\\类型\\Lp\\001.jpg";
|
||||||
@ -182,6 +186,9 @@ namespace HisenceYoloDetection
|
|||||||
string vModelChangePath = "D:\\Hisence\\config\\chinese.json";
|
string vModelChangePath = "D:\\Hisence\\config\\chinese.json";
|
||||||
string LablePathstr = "D:\\Hisence\\ClassName.txt";//标签路径
|
string LablePathstr = "D:\\Hisence\\ClassName.txt";//标签路径
|
||||||
string LablePathButtonstr = "D:\\Hisence\\ClassNameButton.txt";//标签路径
|
string LablePathButtonstr = "D:\\Hisence\\ClassNameButton.txt";//标签路径
|
||||||
|
//Mat cameraMat = Cv2.ImRead(vCam1TwoPath);
|
||||||
|
// canvas1.ImagePath = vCam1TwoPath;
|
||||||
|
// DefetShow.ImaMAt = cameraMat;
|
||||||
if (File.Exists(LablePathButtonstr) && File.Exists(vBarPath) && File.Exists(vCam1OnePath) && File.Exists(vCam1TwoPath) && File.Exists(vModelChangePath))
|
if (File.Exists(LablePathButtonstr) && File.Exists(vBarPath) && File.Exists(vCam1OnePath) && File.Exists(vCam1TwoPath) && File.Exists(vModelChangePath))
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -378,8 +385,8 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
private void bnGetParam_Click(object sender, EventArgs e)
|
private void bnGetParam_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
tbExposure.Text = Cam1.dvpGetExposure().ToString();
|
// tbExposure.Text = Cam1.dvpGetExposure().ToString();
|
||||||
tbGain.Text = Cam1.dvpGetAnalogGain().ToString();
|
// tbGain.Text = Cam1.dvpGetAnalogGain().ToString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +461,7 @@ namespace HisenceYoloDetection
|
|||||||
//初始化相机
|
//初始化相机
|
||||||
|
|
||||||
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
||||||
dataGridView1.DataSource = dataSet.Tables[0];
|
//dataGridView1.DataSource = dataSet.Tables[0];
|
||||||
|
|
||||||
Cam1.Start("Cam1");
|
Cam1.Start("Cam1");
|
||||||
if (Cam1.IfSuccess)
|
if (Cam1.IfSuccess)
|
||||||
@ -486,10 +493,10 @@ namespace HisenceYoloDetection
|
|||||||
melsecPLCTCPDriver.WriteInt("524", 0);//定位松开
|
melsecPLCTCPDriver.WriteInt("524", 0);//定位松开
|
||||||
melsecPLCTCPDriver.WriteInt("406", 60000); //写入手动速度
|
melsecPLCTCPDriver.WriteInt("406", 60000); //写入手动速度
|
||||||
melsecPLCTCPDriver.WriteInt("416", 8000);
|
melsecPLCTCPDriver.WriteInt("416", 8000);
|
||||||
melsecPLCTCPDriver.WriteInt("426", 8000);
|
melsecPLCTCPDriver.WriteInt("426", 10000);
|
||||||
melsecPLCTCPDriver.WriteInt("404", 100000); //写入定位速度
|
melsecPLCTCPDriver.WriteInt("404", 100000); //写入定位速度
|
||||||
melsecPLCTCPDriver.WriteInt("414", 8000);
|
melsecPLCTCPDriver.WriteInt("414", 8000);
|
||||||
melsecPLCTCPDriver.WriteInt("424", 8000);
|
melsecPLCTCPDriver.WriteInt("424", 10000);
|
||||||
|
|
||||||
|
|
||||||
melsecPLCTCPDriver.WriteInt("500", 0);
|
melsecPLCTCPDriver.WriteInt("500", 0);
|
||||||
@ -902,6 +909,8 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
int YPos = 6715;
|
||||||
|
int ZPos = 18857;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 监听洗衣机544是否触发后面对射传感器 相机
|
/// 监听洗衣机544是否触发后面对射传感器 相机
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -953,7 +962,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
myLog("第一次采集图像", DateTime.Now);
|
myLog("第一次采集图像", DateTime.Now);
|
||||||
//移动模组 读三次测距的地址 看是否往前移动
|
//移动模组 读三次测距的地址 看是否往前移动
|
||||||
MoveToP(8974, 0, 0);
|
MoveToP(5815, YPos, ZPos);
|
||||||
// Thread.Sleep(2000);//删
|
// Thread.Sleep(2000);//删
|
||||||
|
|
||||||
|
|
||||||
@ -973,10 +982,10 @@ namespace HisenceYoloDetection
|
|||||||
double dismove = disreal - 876;
|
double dismove = disreal - 876;
|
||||||
if (dismove > 0 && dismove < 4000)
|
if (dismove > 0 && dismove < 4000)
|
||||||
{
|
{
|
||||||
MoveToP(8974, 0, (int)(dismove));
|
MoveToP(5815, YPos, ZPos + (int)(dismove));
|
||||||
}
|
}
|
||||||
Thread.Sleep(2000);//删
|
//Thread.Sleep(2000);//删
|
||||||
Thread.Sleep(500);
|
// Thread.Sleep(500);
|
||||||
Cam1.SnapshotCount = 0;
|
Cam1.SnapshotCount = 0;
|
||||||
Cam1.Snapshot();
|
Cam1.Snapshot();
|
||||||
IfCam2Triger = true;
|
IfCam2Triger = true;
|
||||||
@ -989,9 +998,9 @@ namespace HisenceYoloDetection
|
|||||||
//}
|
//}
|
||||||
//currentXP = 54964;
|
//currentXP = 54964;
|
||||||
//Thread.Sleep(2000);//删
|
//Thread.Sleep(2000);//删
|
||||||
MoveToP(54964, 0, (int)(dismove));
|
MoveToP(51043, YPos, ZPos + (int)(dismove));
|
||||||
Cam1.Snapshot();
|
Cam1.Snapshot();
|
||||||
MoveToP(8974, 0, 0);
|
MoveToP(5815, YPos, ZPos);
|
||||||
//if (xKNow != null)
|
//if (xKNow != null)
|
||||||
//{
|
//{
|
||||||
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
// MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);
|
||||||
@ -1084,7 +1093,7 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pictureBox1.Image = cameraMat.ToBitmap();
|
CamShow1.ImaMAt = cameraMat;
|
||||||
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
|
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1106,14 +1115,15 @@ namespace HisenceYoloDetection
|
|||||||
// Mat mat = Cv2.ImRead("F:\\海信洗衣机\\cam1\\2024517161641.jpg");
|
// Mat mat = Cv2.ImRead("F:\\海信洗衣机\\cam1\\2024517161641.jpg");
|
||||||
Cam2ImgShowBar = cameraMat;
|
Cam2ImgShowBar = cameraMat;
|
||||||
IfCam2Triger = true;
|
IfCam2Triger = true;
|
||||||
originMat2Show.Image = cameraMat.ToBitmap();
|
originMat2Show.BackgroundImage = cameraMat.ToBitmap();
|
||||||
|
//originMat2Show.Image = cameraMat.ToBitmap();
|
||||||
//pictureBox1.Image = cameraMat.ToBitmap();
|
//pictureBox1.Image = cameraMat.ToBitmap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pictureBox2.Image = cameraMat.ToBitmap();
|
CamShow2.ImaMAt = cameraMat;
|
||||||
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
|
cameraMat.ImWrite(fitImageFolder + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1.jpg");
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1139,18 +1149,33 @@ namespace HisenceYoloDetection
|
|||||||
//OCR识别
|
//OCR识别
|
||||||
MLRequest req = new MLRequest();
|
MLRequest req = new MLRequest();
|
||||||
req.currentMat = Cam2ImgShowBar;
|
req.currentMat = Cam2ImgShowBar;
|
||||||
// req.currentMat = Cv2.ImRead("D:\\Hisence\\类型\\Lp\\202453015229201.jpg");
|
// req.currentMat = Cv2.ImRead("D:\\Hisence\\类型\\Lp\\202453015229201.jpg");
|
||||||
MLResult mL = paddleOcrModelCountry.RunInferenceFixed(req);
|
MLResult mL = paddleOcrModelCountry.RunInferenceFixed(req);
|
||||||
//相机识别的字符串
|
//相机识别的字符串
|
||||||
string IOcrBAr = "";
|
string IOcrBAr = "";
|
||||||
for (int v = 0; v < Enumerable.Count<DetectionResultDetail>(mL.ResultDetails); v++)
|
for (int v = 0; v < Enumerable.Count<DetectionResultDetail>(mL.ResultDetails); v++)
|
||||||
{
|
{
|
||||||
string iv = mL.ResultDetails[v].LabelDisplay;
|
if (mL.ResultDetails.Count() > 0)
|
||||||
string result = Regex.Replace(iv, "[ \\[ \\] \\^ \\-_*×――(^)$%~!@#$…&%¥—+=<>《》!!???::?`·、。,;,.;/\"‘’“”-]", "");
|
{
|
||||||
|
if (mL.ResultDetails.Count() > 0)
|
||||||
|
{
|
||||||
|
string iv = mL.ResultDetails[0].LabelDisplay;
|
||||||
|
string result = Regex.Replace(iv, "[ \\[ \\] \\^ \\-_*×――(^)$%~!@#$…&%¥—+=<>《》!!???::?`·、。,;,.;/\"‘’“”-]", "");
|
||||||
|
|
||||||
|
IOcrBAr = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IOcrBAr += result;
|
|
||||||
}
|
}
|
||||||
//IOcrBAr = "LR1006G4SILVERWJ060480U0SW901N120105";
|
DateTime dt = DateTime.Now;
|
||||||
|
using (StreamWriter sw = new StreamWriter("D://Hisence//logsBar.log", true))
|
||||||
|
{
|
||||||
|
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
||||||
|
sw.WriteLine(filename + "\n");
|
||||||
|
sw.WriteLine(IOcrBAr + "\n");
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
|
IOcrBAr = "BatchW81XBModelWNHA62SASUASNVWJ060501V0WW81XB120024";
|
||||||
//根据条码数据库比对
|
//根据条码数据库比对
|
||||||
xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
xKNow = GetModeFromBar(IOcrBAr);//从数据库中查询到这个条码的四轴的值
|
||||||
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
List<XK_HisenceWord> xkWordList = ManagerModelHelper.GetModeWordFromBar(IOcrBAr);
|
||||||
@ -1165,7 +1190,7 @@ namespace HisenceYoloDetection
|
|||||||
myLog("未匹配成功" + IfChangeLanguage, DateTime.Now);
|
myLog("未匹配成功" + IfChangeLanguage, DateTime.Now);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( xKNow.Detect != "")
|
if (xKNow.Detect != "")
|
||||||
{
|
{
|
||||||
//此时运行的洗衣机是和之前一个语言模型
|
//此时运行的洗衣机是和之前一个语言模型
|
||||||
if (IfChangeLanguage == IOcrBAr)
|
if (IfChangeLanguage == IOcrBAr)
|
||||||
@ -1212,16 +1237,16 @@ namespace HisenceYoloDetection
|
|||||||
req.out_node_name = "output";
|
req.out_node_name = "output";
|
||||||
MLResult mL = simboObjectDetection.RunInferenceFixed(req);
|
MLResult mL = simboObjectDetection.RunInferenceFixed(req);
|
||||||
MLResult mLButton = simboObjectDetButton.RunInferenceFixed(req);
|
MLResult mLButton = simboObjectDetButton.RunInferenceFixed(req);
|
||||||
|
|
||||||
DateTime dt = DateTime.Now;
|
DateTime dt = DateTime.Now;
|
||||||
//将所有的块裁剪 识别字符对比字符串
|
//将所有的块裁剪 识别字符对比字符串
|
||||||
List<string> strMatListOne = new List<string>();
|
List<string> strMatListOne = new List<string>();
|
||||||
List<string> strMatFuzzyListOne = new List<string>();
|
List<string> strMatFuzzyListOne = new List<string>();
|
||||||
Mat mResultCut = req.currentMat.Clone();
|
Mat mResultCut = req.currentMat.Clone();
|
||||||
Mat mCut = new Mat();
|
Mat mCut = new Mat();
|
||||||
ManagerModelHelper.InsertSqlRunDataButton(false,ref mCut, ref mResultCut, mL, mLButton, ref xK_MatchDet, /*ref strMatListOne, ref strMatFuzzyListOne, */ref paddleOcrModel);
|
ManagerModelHelper.InsertSqlRunDataButton(false, ref mCut, ref mResultCut, mL, mLButton, ref xK_MatchDet, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||||||
|
|
||||||
if(mL.ResultMap!=null)
|
if (mL.ResultMap != null)
|
||||||
{
|
{
|
||||||
mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
|
mL.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "1result.jpg");
|
||||||
ResultMatShow.Image = mL.ResultMap;
|
ResultMatShow.Image = mL.ResultMap;
|
||||||
@ -1281,24 +1306,33 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
IfCam1TwoTriger = false;
|
IfCam1TwoTriger = false;
|
||||||
bBarTriger = false;
|
bBarTriger = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (MatchStr)
|
if (MatchStr)
|
||||||
{
|
{
|
||||||
OKDsums++;
|
OKDsums++;
|
||||||
myLog("匹配成功", DateTime.Now);
|
myLog("匹配成功", DateTime.Now);
|
||||||
//界面显示
|
//界面显示
|
||||||
InsertXK_HisenceWordMatchData(xK_MatchDet, true);
|
// InsertXK_HisenceWordMatchData(xK_MatchDet, true);
|
||||||
OKOrNGShow.Image = OKbitmap;
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
OKOrNGShow.Image = OKbitmap;
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NGDsums++;
|
NGDsums++;
|
||||||
myLog("匹配失败", DateTime.Now);
|
myLog("匹配失败", DateTime.Now);
|
||||||
//界面显示
|
//界面显示
|
||||||
InsertXK_HisenceWordMatchData(xK_MatchDet, false);
|
// InsertXK_HisenceWordMatchData(xK_MatchDet, false);
|
||||||
OKOrNGShow.Image = NGbitmap;
|
this.Invoke(new Action(() =>
|
||||||
|
{
|
||||||
|
OKOrNGShow.Image = NGbitmap;
|
||||||
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1557,13 +1591,13 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
private void InsertSqlBtn_Click(object sender, EventArgs e)
|
private void InsertSqlBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefeshData_Click(object sender, EventArgs e)
|
private void RefeshData_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
DataSet dataSet = SQLiteHelper.Query("select * from XK_HisenceDet");
|
||||||
dataGridView1.DataSource = dataSet.Tables[0];
|
//dataGridView1.DataSource = dataSet.Tables[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void panel8_Paint(object sender, PaintEventArgs e)
|
private void panel8_Paint(object sender, PaintEventArgs e)
|
||||||
@ -1839,7 +1873,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
private void InsertBtn_Click(object sender, EventArgs e)
|
private void InsertBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1856,7 +1890,7 @@ namespace HisenceYoloDetection
|
|||||||
if (WhiteBanCbx.CheckState == CheckState.Checked)//选中
|
if (WhiteBanCbx.CheckState == CheckState.Checked)//选中
|
||||||
{
|
{
|
||||||
whiteBan = true;
|
whiteBan = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (WhiteBanCbx.CheckState == CheckState.Unchecked)//没选中
|
else if (WhiteBanCbx.CheckState == CheckState.Unchecked)//没选中
|
||||||
{
|
{
|
||||||
@ -1906,7 +1940,7 @@ namespace HisenceYoloDetection
|
|||||||
int HmovetwoX = (int)Convert.ToInt64(movetwoX);
|
int HmovetwoX = (int)Convert.ToInt64(movetwoX);
|
||||||
int HmovetwoY = (int)Convert.ToInt64(movetwoY);
|
int HmovetwoY = (int)Convert.ToInt64(movetwoY);
|
||||||
int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
|
int HmovetwoZ = (int)Convert.ToInt64(movetwoZ);
|
||||||
InsertXK_Hisence(whiteBan,HmoveX, HmoveY, HmoveZ, HmovetwoX, HmovetwoY, HmovetwoZ);
|
InsertXK_Hisence(whiteBan, HmoveX, HmoveY, HmoveZ, HmovetwoX, HmovetwoY, HmovetwoZ);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1921,7 +1955,7 @@ namespace HisenceYoloDetection
|
|||||||
MessageBox.Show(es.Message);
|
MessageBox.Show(es.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void InsertXK_Hisence(bool ifwhiteBan,int MoveX, int MoveY, int MoveZ, int MoveTwoX, int MoveTwoY, int MoveTwoZ)
|
public void InsertXK_Hisence(bool ifwhiteBan, int MoveX, int MoveY, int MoveZ, int MoveTwoX, int MoveTwoY, int MoveTwoZ)
|
||||||
{
|
{
|
||||||
PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
|
PaddleOcrModel IpaddleOcrModel = new PaddleOcrModel();
|
||||||
IpaddleOcrModel.Load(ModelChangePath, "CPU");
|
IpaddleOcrModel.Load(ModelChangePath, "CPU");
|
||||||
@ -1983,7 +2017,7 @@ namespace HisenceYoloDetection
|
|||||||
List<string> strMatFuzzyListOne = new List<string>();
|
List<string> strMatFuzzyListOne = new List<string>();
|
||||||
Mat mResultCut = CamOneI.currentMat.Clone();
|
Mat mResultCut = CamOneI.currentMat.Clone();
|
||||||
Mat mCut = new Mat();
|
Mat mCut = new Mat();
|
||||||
ManagerModelHelper.InsertSqlRunDataButton(true,ref mCut, ref mResultCut, mL3, mLButton,ref xkWord, /*ref strMatListOne, ref strMatFuzzyListOne,*/ ref paddleOcrModel);
|
ManagerModelHelper.InsertSqlRunDataButton(true, ref mCut, ref mResultCut, mL3, mLButton, ref xkWord, ref strMatListOne, ref strMatFuzzyListOne, ref paddleOcrModel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2011,7 +2045,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
InsertXKHisenceWordData( xkWord);//往关键字表中插入一条数据
|
InsertXKHisenceWordData(xkWord);//往关键字表中插入一条数据
|
||||||
//文本区域
|
//文本区域
|
||||||
List<string> bingji = strMatListOne.Union(strMatListTwo).ToList();//并(全)集
|
List<string> bingji = strMatListOne.Union(strMatListTwo).ToList();//并(全)集
|
||||||
List<string> Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//并(全)集
|
List<string> Fuzzybingji = strMatFuzzyListOne.Union(strMatFuzzyListTwo).ToList();//并(全)集
|
||||||
@ -2107,7 +2141,7 @@ namespace HisenceYoloDetection
|
|||||||
new SQLiteParameter("@EightblockPath", DbType.String),
|
new SQLiteParameter("@EightblockPath", DbType.String),
|
||||||
new SQLiteParameter("@EightblockMainWord", DbType.String),
|
new SQLiteParameter("@EightblockMainWord", DbType.String),
|
||||||
new SQLiteParameter("@EightblockText", DbType.String)};
|
new SQLiteParameter("@EightblockText", DbType.String)};
|
||||||
|
|
||||||
parameters[0].Value = xkWord.OcrBar;
|
parameters[0].Value = xkWord.OcrBar;
|
||||||
parameters[1].Value = xkWord.OneblockPath;
|
parameters[1].Value = xkWord.OneblockPath;
|
||||||
parameters[2].Value = xkWord.OneblockMainWord;
|
parameters[2].Value = xkWord.OneblockMainWord;
|
||||||
@ -2149,7 +2183,7 @@ namespace HisenceYoloDetection
|
|||||||
MessageBox.Show("关键字XK_HisenceWord插入一条数据");
|
MessageBox.Show("关键字XK_HisenceWord插入一条数据");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void InsertXK_HisenceWordMatchData(XK_HisenceWord xkWord,bool ifMatch)
|
public void InsertXK_HisenceWordMatchData(XK_HisenceWord xkWord, bool ifMatch)
|
||||||
{
|
{
|
||||||
StringBuilder strSql = new StringBuilder();
|
StringBuilder strSql = new StringBuilder();
|
||||||
strSql.Append("insert into XK_HisenceWordMatch(");
|
strSql.Append("insert into XK_HisenceWordMatch(");
|
||||||
@ -2226,7 +2260,7 @@ namespace HisenceYoloDetection
|
|||||||
parameters[24].Value = xkWord.EightblockPath;
|
parameters[24].Value = xkWord.EightblockPath;
|
||||||
parameters[25].Value = xkWord.EightblockMainWord;
|
parameters[25].Value = xkWord.EightblockMainWord;
|
||||||
parameters[26].Value = xkWord.EightblockText;
|
parameters[26].Value = xkWord.EightblockText;
|
||||||
|
|
||||||
parameters[27].Value = DateTime.Now;
|
parameters[27].Value = DateTime.Now;
|
||||||
parameters[28].Value = ifMatch;
|
parameters[28].Value = ifMatch;
|
||||||
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
||||||
@ -2266,7 +2300,7 @@ namespace HisenceYoloDetection
|
|||||||
parameters[7].Value = xkWord.MoveTwoY;
|
parameters[7].Value = xkWord.MoveTwoY;
|
||||||
|
|
||||||
parameters[8].Value = xkWord.MoveTwoZ;
|
parameters[8].Value = xkWord.MoveTwoZ;
|
||||||
|
|
||||||
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
int iv = SQLiteHelper.ExecuteSql(strSql.ToString(), parameters);
|
||||||
if (iv == 1)
|
if (iv == 1)
|
||||||
{
|
{
|
||||||
@ -2373,13 +2407,23 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
private void bnGetParam2_Click_1(object sender, EventArgs e)
|
private void bnGetParam2_Click_1(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
tbExposure2.Text = Cam2.dvpGetExposure().ToString();
|
// tbExposure2.Text = Cam2.dvpGetExposure().ToString();
|
||||||
tbGain2.Text = Cam2.dvpGetAnalogGain().ToString();
|
//tbGain2.Text = Cam2.dvpGetAnalogGain().ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void panel2_Paint(object sender, PaintEventArgs e)
|
private void panel2_Paint(object sender, PaintEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bnSetParam_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void groupBox2_Enter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -35,7 +35,7 @@ namespace HisenceYoloDetection
|
|||||||
/// <param name="strMatList">返回的定位框的结果</param>
|
/// <param name="strMatList">返回的定位框的结果</param>
|
||||||
/// <param name="strMatRefList"></param>
|
/// <param name="strMatRefList"></param>
|
||||||
/// <param name="IOcrModel"></param>
|
/// <param name="IOcrModel"></param>
|
||||||
public static void InsertSqlRunDataButton(bool saveimage,ref Mat CutMat, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord xK_HisenceWord, /*ref List<string> strMatList, ref List<string> strMatRefList, */ref PaddleOcrModel IOcrModel)
|
public static void InsertSqlRunDataButton(bool saveimage,ref Mat CutMat, ref Mat currentMatC, MLResult cam1TwoML, MLResult cam1Button, ref XK_HisenceWord xK_HisenceWord, ref List<string> strMatList, ref List<string> strMatRefList, ref PaddleOcrModel IOcrModel)
|
||||||
{
|
{
|
||||||
#if true
|
#if true
|
||||||
//try
|
//try
|
||||||
@ -64,7 +64,7 @@ namespace HisenceYoloDetection
|
|||||||
|
|
||||||
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
|
string blockIndex = cam1TwoML.ResultDetails[i].LabelDisplay;
|
||||||
Rect area2 = new Rect();
|
Rect area2 = new Rect();
|
||||||
if (blockIndex == "2")//根据旋钮扩大范围
|
if (blockIndex == "2"|| blockIndex == "7")//根据旋钮扩大范围
|
||||||
{
|
{
|
||||||
areaBlack.X -= rectsx;
|
areaBlack.X -= rectsx;
|
||||||
areaBlack.Y -= rectsy;
|
areaBlack.Y -= rectsy;
|
||||||
@ -394,9 +394,26 @@ namespace HisenceYoloDetection
|
|||||||
//第二快 卷积匹配
|
//第二快 卷积匹配
|
||||||
string PathSql = XKSQL.TwoblockPath;
|
string PathSql = XKSQL.TwoblockPath;
|
||||||
//
|
//
|
||||||
|
|
||||||
Rect rectsql = CheckDiffSciHelper.strChangeRect(TwoRectstr);
|
Rect rectsql = CheckDiffSciHelper.strChangeRect(TwoRectstr);
|
||||||
Rect rectDet = CheckDiffSciHelper.strChangeRect(XKDet.TwoRect);
|
Rect rectDet = CheckDiffSciHelper.strChangeRect(XKDet.TwoRect);
|
||||||
bool twoif2 = CheckDiffSciHelper.CheckDiffSci(PathSql, detMat, rectsql, rectDet,(bool)XKSQL.TwoIFWhile, "D://");
|
bool twoif2 = CheckDiffSciHelper.CheckDiffSci(PathSql, detMat, rectsql, rectDet,(bool)XKSQL.TwoIFWhile, "D://Test");
|
||||||
|
DateTime dt = DateTime.Now;
|
||||||
|
using (StreamWriter sw = new StreamWriter("D://Hisence//logsMatch.log", true))
|
||||||
|
{
|
||||||
|
string filename = dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString();
|
||||||
|
sw.WriteLine(filename + "\n");
|
||||||
|
sw.WriteLine(oneBlockWordSql + " " + oneBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(twoBlockWordSql + " " + twoBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(threeBlockWordSql + " " + threeBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(fourBlockWordSql + " " + fourBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(fiveBlockWordSql + " " + fiveBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(sixBlockWordSql + " " + sixBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(sevenBlockWordSql + " " + sevenBlockWordDet + "\n");
|
||||||
|
sw.WriteLine(eightBlockWordSql + " " + eightBlockWordDet + "\n");
|
||||||
|
sw.WriteLine( " 卷积匹配 " + twoif2 + "\n");
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
//第三块区域一直都是false
|
//第三块区域一直都是false
|
||||||
if (OneIF && TwoIF && ThreeIF && FourIF && FiveIF && SixIF && SenvenIF && EightIF&& twoif2)
|
if (OneIF && TwoIF && ThreeIF && FourIF && FiveIF && SixIF && SenvenIF && EightIF&& twoif2)
|
||||||
{
|
{
|
||||||
@ -419,35 +436,48 @@ namespace HisenceYoloDetection
|
|||||||
}
|
}
|
||||||
public static bool isMatchStr(string SqlText, string DetText)
|
public static bool isMatchStr(string SqlText, string DetText)
|
||||||
{
|
{
|
||||||
if (SqlText.Contains("##") && DetText.Contains("##"))
|
|
||||||
{
|
|
||||||
// 计算Levenshtein距离
|
if ((SqlText == "" || SqlText == null) && (DetText == "" || DetText == null))
|
||||||
int distance = LevenshteinDistance(SqlText, DetText);
|
|
||||||
|
|
||||||
// 计算相似度(相似度等于1减去标准化的Levenshtein距离)
|
|
||||||
double similarity = 1 - ((double)distance / Math.Max(SqlText.Length, DetText.Length));
|
|
||||||
bool areEqual = false;
|
|
||||||
if (similarity<0.5)
|
|
||||||
{
|
|
||||||
areEqual = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
areEqual = true;
|
|
||||||
}
|
|
||||||
//string[] sArraysql = Regex.Split(SqlText, "##", RegexOptions.IgnoreCase);
|
|
||||||
//string[] sArraydet = Regex.Split(DetText, "##", RegexOptions.IgnoreCase);
|
|
||||||
//bool areEqual = sArraysql.OrderBy(x => x).SequenceEqual(sArraydet.OrderBy(x => x));
|
|
||||||
return areEqual;
|
|
||||||
|
|
||||||
}
|
|
||||||
else if ((SqlText == "" || SqlText == null) && (DetText == "" || DetText == null))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
if(SqlText!=null&& DetText!=null)
|
||||||
|
{
|
||||||
|
if (SqlText.Contains("##") && DetText.Contains("##"))
|
||||||
|
{
|
||||||
|
// 计算Levenshtein距离
|
||||||
|
int distance = LevenshteinDistance(SqlText, DetText);
|
||||||
|
|
||||||
|
// 计算相似度(相似度等于1减去标准化的Levenshtein距离)
|
||||||
|
double similarity = 1 - ((double)distance / Math.Max(SqlText.Length, DetText.Length));
|
||||||
|
bool areEqual = false;
|
||||||
|
if (similarity < 0.5)
|
||||||
|
{
|
||||||
|
areEqual = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
areEqual = true;
|
||||||
|
}
|
||||||
|
//string[] sArraysql = Regex.Split(SqlText, "##", RegexOptions.IgnoreCase);
|
||||||
|
//string[] sArraydet = Regex.Split(DetText, "##", RegexOptions.IgnoreCase);
|
||||||
|
//bool areEqual = sArraysql.OrderBy(x => x).SequenceEqual(sArraydet.OrderBy(x => x));
|
||||||
|
return areEqual;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算Levenshtein距离
|
// 计算Levenshtein距离
|
||||||
|
@ -267,8 +267,8 @@ namespace XKRS.Device.SimboVision.SimboHelper
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
originMat?.Dispose();
|
// originMat?.Dispose();
|
||||||
originMat = null;
|
// originMat = null;
|
||||||
|
|
||||||
|
|
||||||
// GC.Collect();
|
// GC.Collect();
|
||||||
|
BIN
HisenceYoloDetection/yyb.douyin.ico
Normal file
BIN
HisenceYoloDetection/yyb.douyin.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
52
XKRS.UI/Canvas.Designer.cs
generated
Normal file
52
XKRS.UI/Canvas.Designer.cs
generated
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
namespace XKRS.UI
|
||||||
|
{
|
||||||
|
partial class Canvas
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// Canvas
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Name = "Canvas";
|
||||||
|
this.Size = new System.Drawing.Size(190, 148);
|
||||||
|
this.SizeChanged += new System.EventHandler(this.Canvas_SizeChanged);
|
||||||
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Canvas_KeyDown);
|
||||||
|
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Canvas_KeyUp);
|
||||||
|
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseDown);
|
||||||
|
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseMove);
|
||||||
|
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseUp);
|
||||||
|
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.Canvas_MouseWheel);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
1238
XKRS.UI/Canvas.cs
Normal file
1238
XKRS.UI/Canvas.cs
Normal file
File diff suppressed because it is too large
Load Diff
60
XKRS.UI/Canvas.resx
Normal file
60
XKRS.UI/Canvas.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
32
XKRS.UI/ClickArea.cs
Normal file
32
XKRS.UI/ClickArea.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 点击的区域
|
||||||
|
/// </summary>
|
||||||
|
internal enum ClickArea
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 未知区域
|
||||||
|
/// </summary>
|
||||||
|
AREA_UNKNOW,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 图片区域
|
||||||
|
/// </summary>
|
||||||
|
AREA_IMG,
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 缺陷元素区域
|
||||||
|
/// </summary>
|
||||||
|
AREA_DEFECT,
|
||||||
|
}
|
||||||
|
}
|
434
XKRS.UI/Defect.cs
Normal file
434
XKRS.UI/Defect.cs
Normal file
@ -0,0 +1,434 @@
|
|||||||
|
using Microsoft.VisualBasic.ApplicationServices;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using XKRS.UI.Helper;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI
|
||||||
|
{
|
||||||
|
public class Defect
|
||||||
|
{
|
||||||
|
public string File { get; private set; }
|
||||||
|
public bool Selected { get; private set; }
|
||||||
|
private Rectangle _rectangle { get; }
|
||||||
|
public GraphicsPath Path { get; set; }
|
||||||
|
public Bitmap OriBitMap { get; set; }
|
||||||
|
public PointF _defectCenterPoint { get; }
|
||||||
|
|
||||||
|
private float _wholeDScale = 1f;
|
||||||
|
|
||||||
|
private float _xDScale = 1f;
|
||||||
|
|
||||||
|
private float _yDScale = 1f;
|
||||||
|
|
||||||
|
private float[] _lastSetScale = new float[3] { 1f, 1f, 1f };
|
||||||
|
|
||||||
|
private double _dRoute;
|
||||||
|
|
||||||
|
private double _totalDRoute;
|
||||||
|
|
||||||
|
private PointF _initialPosition;
|
||||||
|
|
||||||
|
private PointF _lastSetPosition;
|
||||||
|
|
||||||
|
private float _xDMove;
|
||||||
|
|
||||||
|
private float _yDMove;
|
||||||
|
|
||||||
|
private Brush[] _brushDColors = new Brush[5]
|
||||||
|
{ Brushes.Red, Brushes.Yellow, Brushes.Blue, Brushes.Green, Brushes.Black };
|
||||||
|
|
||||||
|
private int _selectedColorIndex = 0;
|
||||||
|
|
||||||
|
private Matrix _matrix;
|
||||||
|
|
||||||
|
private PointF _upperLeftPoint;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身上一次赋值的缩放值
|
||||||
|
/// </summary>
|
||||||
|
public float[] LastSetScale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _lastSetScale;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_lastSetScale = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的整体缩放比例
|
||||||
|
/// </summary>
|
||||||
|
public float WholeDScale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _wholeDScale;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_wholeDScale = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的横向缩放
|
||||||
|
/// </summary>
|
||||||
|
public float XDScale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _xDScale;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_xDScale = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的竖向缩放
|
||||||
|
/// </summary>
|
||||||
|
public float YDScale
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _yDScale;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_yDScale = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身旋转过程中的角度
|
||||||
|
/// </summary>
|
||||||
|
public double DRoute
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Math.Ceiling(_dRoute % 360);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_dRoute = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身旋转的总角度
|
||||||
|
/// </summary>
|
||||||
|
public double TotalDRoute
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_totalDRoute % 360 > 0)
|
||||||
|
{
|
||||||
|
return _totalDRoute % 360;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (_totalDRoute + 360) % 360;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_totalDRoute = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身开始加载时中心点在控件坐标系中的坐标
|
||||||
|
/// </summary
|
||||||
|
public PointF InitialPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _initialPosition;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_initialPosition = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上一次赋值的位移终点
|
||||||
|
/// </summary>
|
||||||
|
public PointF LastSetPosition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _lastSetPosition;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_lastSetPosition = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身在控件坐标系X轴方向上的位移
|
||||||
|
/// </summary>
|
||||||
|
public float XDMove
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (int)_xDMove;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_xDMove = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身在空间坐标系Y轴方向上的位移
|
||||||
|
/// </summary>
|
||||||
|
public float YDMove
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (int)_yDMove;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_yDMove = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的边框颜色
|
||||||
|
/// </summary>
|
||||||
|
public Brush[] BrushDColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _brushDColors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身在调整颜色控件中选择的边框颜色序列
|
||||||
|
/// </summary>
|
||||||
|
public int SelectedColorIndex
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _selectedColorIndex;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_selectedColorIndex = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的矩阵,该矩阵需要左乘背景图的矩阵才是最终看到的显示效果
|
||||||
|
/// </summary>
|
||||||
|
public Matrix PrivateMatrix
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _matrix;
|
||||||
|
}
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_matrix = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 每个缺陷自身的左上角顶点坐标
|
||||||
|
/// </summary>
|
||||||
|
public PointF UpperLeftPoint
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _upperLeftPoint;
|
||||||
|
}
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
_upperLeftPoint = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Defect(string file) : this(file, new Matrix())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Defect(string file, Matrix m)
|
||||||
|
{
|
||||||
|
File = file;
|
||||||
|
|
||||||
|
using (Stream s = System.IO.File.Open(file, FileMode.Open))
|
||||||
|
{
|
||||||
|
OriBitMap = (Bitmap)Image.FromStream(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrivateMatrix = m;
|
||||||
|
|
||||||
|
UpperLeftPoint = new PointF(0, 0);
|
||||||
|
_defectCenterPoint = new PointF(UpperLeftPoint.X + OriBitMap.Width / 2, UpperLeftPoint.Y + OriBitMap.Height / 2);
|
||||||
|
_rectangle = new Rectangle((int)UpperLeftPoint.X, (int)UpperLeftPoint.Y, OriBitMap.Width, OriBitMap.Height);
|
||||||
|
Path = new GraphicsPath();
|
||||||
|
Path.AddRectangle(_rectangle);
|
||||||
|
Path.CloseAllFigures();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Defect(string file, PointF[] points, Matrix m)
|
||||||
|
{
|
||||||
|
File = file;
|
||||||
|
|
||||||
|
using (Stream s = System.IO.File.Open(file, FileMode.Open))
|
||||||
|
{
|
||||||
|
Bitmap midBitmap = (Bitmap)Image.FromStream(s);
|
||||||
|
Path = new GraphicsPath();
|
||||||
|
Path.AddPolygon(points);
|
||||||
|
Path.CloseAllFigures();
|
||||||
|
OriBitMap = BitmapCrop(midBitmap, Path);
|
||||||
|
}
|
||||||
|
PrivateMatrix = m;
|
||||||
|
|
||||||
|
RectangleF rec = Path.GetBounds();
|
||||||
|
UpperLeftPoint = new PointF(rec.X, rec.Y);
|
||||||
|
_defectCenterPoint = new PointF(UpperLeftPoint.X + OriBitMap.Width / 2, UpperLeftPoint.Y + OriBitMap.Height / 2);
|
||||||
|
_rectangle = new Rectangle((int)rec.X, (int)rec.Y, OriBitMap.Width, OriBitMap.Height);
|
||||||
|
PrivateMatrix.Translate(-rec.X, -rec.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Defect(Rectangle rectangle, Matrix m)
|
||||||
|
{
|
||||||
|
|
||||||
|
Path = new GraphicsPath();
|
||||||
|
Path.AddRectangle(rectangle);
|
||||||
|
Path.CloseAllFigures();
|
||||||
|
OriBitMap = BitmapCropRect(Path);
|
||||||
|
PrivateMatrix = m;
|
||||||
|
|
||||||
|
RectangleF rec = Path.GetBounds();
|
||||||
|
UpperLeftPoint = new PointF(rec.X, rec.Y);
|
||||||
|
_defectCenterPoint = new PointF(UpperLeftPoint.X + OriBitMap.Width / 2, UpperLeftPoint.Y + OriBitMap.Height / 2);
|
||||||
|
_rectangle = new Rectangle((int)rec.X, (int)rec.Y, OriBitMap.Width, OriBitMap.Height);
|
||||||
|
PrivateMatrix.Translate(-rec.X, -rec.Y);
|
||||||
|
}
|
||||||
|
public Bitmap BitmapCropRect( GraphicsPath path)
|
||||||
|
{
|
||||||
|
RectangleF rec = path.GetBounds();
|
||||||
|
int left = (int)rec.Left;
|
||||||
|
int top = (int)rec.Top;
|
||||||
|
int width = (int)rec.Width;
|
||||||
|
int height = (int)rec.Height;
|
||||||
|
Bitmap imgCropped = new Bitmap(width, height);
|
||||||
|
//Bitmap img = (Bitmap)bitmap.Clone();
|
||||||
|
Region r = new Region(path);
|
||||||
|
for (int i = left; i < left + width; i++)
|
||||||
|
{
|
||||||
|
for (int j = top; j < top + height; j++)
|
||||||
|
{
|
||||||
|
if (!r.IsVisible(i, j))
|
||||||
|
{
|
||||||
|
imgCropped.SetPixel(i - left, j - top, Color.FromArgb(0, 255, 255, 255));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imgCropped.SetPixel(i - left, j - top, Color.FromArgb(0, 0, 255, 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return imgCropped;
|
||||||
|
}
|
||||||
|
public Bitmap BitmapCrop(Bitmap bitmap, GraphicsPath path)
|
||||||
|
{
|
||||||
|
RectangleF rec = path.GetBounds();
|
||||||
|
int left = (int)rec.Left;
|
||||||
|
int top = (int)rec.Top;
|
||||||
|
int width = (int)rec.Width;
|
||||||
|
int height = (int)rec.Height;
|
||||||
|
Bitmap imgCropped = new Bitmap(width, height);
|
||||||
|
Bitmap img = (Bitmap)bitmap.Clone();
|
||||||
|
Region r = new Region(path);
|
||||||
|
for (int i = left; i < left + width; i++)
|
||||||
|
{
|
||||||
|
for (int j = top; j < top + height; j++)
|
||||||
|
{
|
||||||
|
if (!r.IsVisible(i, j))
|
||||||
|
{
|
||||||
|
imgCropped.SetPixel(i - left, j - top, Color.FromArgb(0, 255, 255, 255));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imgCropped.SetPixel(i - left, j - top, img.GetPixel(i, j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return imgCropped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawPath(Graphics graphics)
|
||||||
|
{
|
||||||
|
graphics.DrawPath(new Pen(BrushDColor[SelectedColorIndex], 1f), Path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void Select()
|
||||||
|
{
|
||||||
|
Selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UnSelect()
|
||||||
|
{
|
||||||
|
Selected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool ContainPoint(Point p)
|
||||||
|
{
|
||||||
|
return _rectangle.Contains(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Prepend参数指先操作,Append参数指后操作
|
||||||
|
public void Move(float x, float y, MatrixOrder order = MatrixOrder.Prepend)
|
||||||
|
{
|
||||||
|
switch (order)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case MatrixOrder.Prepend:
|
||||||
|
//设定平移矩阵,order默认为predend,平移矩阵左乘_matrix
|
||||||
|
_matrix.Translate(x, y);
|
||||||
|
break;
|
||||||
|
case MatrixOrder.Append:
|
||||||
|
_matrix.Translate(x, y, MatrixOrder.Append);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Scale(float scaleX, float scaleY)
|
||||||
|
{
|
||||||
|
_matrix.Scale(scaleX, scaleY);
|
||||||
|
}
|
||||||
|
public void Rotate(float angle)
|
||||||
|
{
|
||||||
|
_matrix.Rotate(angle);
|
||||||
|
}
|
||||||
|
public void RotateAt(float angle, PointF point)
|
||||||
|
{
|
||||||
|
_matrix.RotateAt(angle, point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
XKRS.UI/Helper/PointHelper.cs
Normal file
56
XKRS.UI/Helper/PointHelper.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI.Helper
|
||||||
|
{
|
||||||
|
internal static class PointHelper
|
||||||
|
{
|
||||||
|
public static Point ToPoint(this PointF pf)
|
||||||
|
{
|
||||||
|
return new Point((int)pf.X, (int)pf.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将相对于控件的坐标转换为相对于图像的坐标
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p">控件中指定点的点位坐标,坐标原点为控件左上角</param>
|
||||||
|
/// <returns>该点以图像坐标系为基准的坐标值,坐标原点为图像左上角</returns>
|
||||||
|
public static PointF ToImageCoordinate(this Point p, Matrix m)
|
||||||
|
{
|
||||||
|
PointF pf = new PointF(p.X, p.Y);
|
||||||
|
return ToImageCoordinate(pf, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将相对于控件的坐标转换为相对于图像的坐标
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p">控件中指定点的点位坐标,坐标原点为控件左上角</param>
|
||||||
|
/// <returns>该点以图像坐标系为基准的坐标值,坐标原点为图像左上角</returns>
|
||||||
|
public static PointF ToImageCoordinate(this PointF p, Matrix m)
|
||||||
|
{
|
||||||
|
PointF[] ps = new PointF[] { p };
|
||||||
|
Matrix invertMatrix = m.Clone();
|
||||||
|
//想要从旧空间到新空间的逆变换,所以我们需要对这个矩阵求逆
|
||||||
|
invertMatrix.Invert();
|
||||||
|
invertMatrix.TransformPoints(ps);
|
||||||
|
return ps[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将相对于图像的坐标转换为相对于控件坐标系
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p">图像中指定点的点位坐标,坐标原点为图像左上角</param>
|
||||||
|
/// <returns>该点以空间坐标系为基准的坐标值,坐标原点为空间坐左上角</returns>
|
||||||
|
public static PointF ToControlCoordinate(this PointF p, Matrix m)
|
||||||
|
{
|
||||||
|
PointF[] ps = new PointF[] { p };
|
||||||
|
m.TransformPoints(ps);
|
||||||
|
return ps[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
12
XKRS.UI/Helper/RectangleHelper.cs
Normal file
12
XKRS.UI/Helper/RectangleHelper.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI.Helper
|
||||||
|
{
|
||||||
|
internal static class RectangleHelper
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
15
XKRS.UI/ILoadToCanvas.cs
Normal file
15
XKRS.UI/ILoadToCanvas.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI
|
||||||
|
{
|
||||||
|
public interface ILoadToCanvas
|
||||||
|
{
|
||||||
|
|
||||||
|
void OnLoadToCanvas(Canvas canvas);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
47
XKRS.UI/Polygon.cs
Normal file
47
XKRS.UI/Polygon.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XKRS.UI
|
||||||
|
{
|
||||||
|
public class Polygon
|
||||||
|
{
|
||||||
|
// public ShapesContent[]? shapes { get; set; }
|
||||||
|
|
||||||
|
public Color FillColor { get; set; }
|
||||||
|
public Color LineColor { get; set; }
|
||||||
|
|
||||||
|
private List<PointF> Points = new List<PointF>();
|
||||||
|
|
||||||
|
public Polygon()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Polygon(Color fillColor, Color lineColor, List<PointF> points)
|
||||||
|
{
|
||||||
|
FillColor = fillColor;
|
||||||
|
LineColor = lineColor;
|
||||||
|
Points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetPoints(List<PointF> pointsList)
|
||||||
|
{
|
||||||
|
this.Points = pointsList;
|
||||||
|
}
|
||||||
|
public void AddPoint(PointF p)
|
||||||
|
{
|
||||||
|
Points.Add(p);
|
||||||
|
}
|
||||||
|
public void RemovePoint(int index)
|
||||||
|
{
|
||||||
|
Points.RemoveAt(index);
|
||||||
|
}
|
||||||
|
public List<PointF> GetPoints()
|
||||||
|
{
|
||||||
|
return Points;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
XKRS.UI/XKRS.UI.csproj
Normal file
18
XKRS.UI/XKRS.UI.csproj
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<BaseOutputPath>.\bin\X64\Debug</BaseOutputPath>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="OpenCvSharp4" Version="4.5.3.20210817" />
|
||||||
|
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.5.3.20210817" />
|
||||||
|
<PackageReference Include="SunnyUI" Version="3.2.3.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
BIN
libs/XKRS.UI.dll
Normal file
BIN
libs/XKRS.UI.dll
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user