小转盘基本都能出列

This commit is contained in:
2025-03-10 17:18:45 +08:00
parent 0314f4d403
commit e7736217db
17 changed files with 6712 additions and 299 deletions

View File

@ -57,7 +57,7 @@ namespace DH.Devices.Camera
throw new Exception($"Create device failed:{nRet:x8}");
}
nRet = DVPCamera.dvpSetTargetFormat(m_handle, dvpStreamFormat);
nRet = DVPCamera.dvpSetTargetFormat(m_handle, (dvpStreamFormat)dvpStreamFormat);
if (dvpStatus.DVP_STATUS_OK != nRet)
{
throw new Exception($"Set image format failed:{nRet:x8}");
@ -308,6 +308,8 @@ namespace DH.Devices.Camera
public int ImageCallbackFunc(uint handle, dvpStreamEvent _event, IntPtr pContext, ref dvpFrame refFrame, IntPtr pBuffer)
{
Mat cvImage = new Mat();
try
{
@ -316,8 +318,7 @@ namespace DH.Devices.Camera
int nWidth = refFrame.iWidth;
int nHeight = refFrame.iHeight;
Mat cvImage = new Mat();
// 根据图像格式创建Mat
switch (refFrame.format)
{
@ -337,7 +338,8 @@ namespace DH.Devices.Camera
default:
throw new NotSupportedException($"Unsupported format: {refFrame.format}");
}
OnHImageOutput?.Invoke(DateTime.Now, this, cvImage);
Mat smat = cvImage.Clone();
OnHImageOutput?.Invoke(DateTime.Now, this, smat);
@ -348,6 +350,10 @@ namespace DH.Devices.Camera
catch (Exception ex)
{
}
finally
{
cvImage?.Dispose();
}
return 0;
}