This commit is contained in:
@@ -58,10 +58,6 @@ namespace BasicDemo
|
||||
private string _videoSavePath = @"D:\CameraRecordings\"; // 修改为你的保存路径
|
||||
private double _frameRate = 30.0; // 默认帧率
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 构造函数
|
||||
public AutoCameraForm(GetRunStatusDelegate getRunStatusCallback, ReturnToPreviousFormDelegate returnCallback = null, string videoSavePath = null)
|
||||
{
|
||||
@@ -96,8 +92,6 @@ namespace BasicDemo
|
||||
this.Load += (s, e) => InitializeCameras();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化UI界面
|
||||
/// </summary>
|
||||
@@ -516,8 +510,6 @@ namespace BasicDemo
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检查相机是否有效
|
||||
/// </summary>
|
||||
@@ -566,9 +558,6 @@ namespace BasicDemo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private bool PrepareForGrabbing(int cameraIndex)
|
||||
{
|
||||
try
|
||||
@@ -637,8 +626,6 @@ namespace BasicDemo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为单色像素格式
|
||||
/// </summary>
|
||||
@@ -657,97 +644,6 @@ namespace BasicDemo
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 采集线程处理函数 - 简化版本
|
||||
///// </summary>
|
||||
//private void GrabThreadProc(int cameraIndex)
|
||||
//{
|
||||
// MyCamera camera = cameras[cameraIndex];
|
||||
// MyCamera.MV_FRAME_OUT frameOut = new MyCamera.MV_FRAME_OUT();
|
||||
// MyCamera.MV_PIXEL_CONVERT_PARAM convertParam = new MyCamera.MV_PIXEL_CONVERT_PARAM();
|
||||
// MyCamera.MV_DISPLAY_FRAME_INFO displayInfo = new MyCamera.MV_DISPLAY_FRAME_INFO();
|
||||
|
||||
// // 帧率控制变量(新增)
|
||||
// int framesWritten = 0;
|
||||
// DateTime lastWriteTime = DateTime.Now;
|
||||
// while (grabbingFlags[cameraIndex])
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// // 获取图像缓冲区
|
||||
// int ret = camera.MV_CC_GetImageBuffer_NET(ref frameOut, 1000);
|
||||
// if (ret == MyCamera.MV_OK)
|
||||
// {
|
||||
// lock (locks[cameraIndex])
|
||||
// {
|
||||
// // 更新帧信息
|
||||
// frameInfos[cameraIndex] = frameOut.stFrameInfo;
|
||||
|
||||
// // 像素格式转换
|
||||
// convertParam.nWidth = frameOut.stFrameInfo.nWidth;
|
||||
// convertParam.nHeight = frameOut.stFrameInfo.nHeight;
|
||||
// convertParam.enSrcPixelType = frameOut.stFrameInfo.enPixelType;
|
||||
// convertParam.pSrcData = frameOut.pBufAddr;
|
||||
// convertParam.nSrcDataLen = frameOut.stFrameInfo.nFrameLen;
|
||||
// convertParam.pDstBuffer = displayBufs[cameraIndex];
|
||||
// convertParam.nDstBufferSize = displayBufSizes[cameraIndex];
|
||||
|
||||
// if (displayBitmaps[cameraIndex].PixelFormat == PixelFormat.Format8bppIndexed)
|
||||
// {
|
||||
// convertParam.enDstPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_Mono8;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// convertParam.enDstPixelType = MyCamera.MvGvspPixelType.PixelType_Gvsp_BGR8_Packed;
|
||||
// }
|
||||
|
||||
// camera.MV_CC_ConvertPixelType_NET(ref convertParam);
|
||||
|
||||
// // 简单方案:直接更新现有的Bitmap,不创建新实例
|
||||
// BitmapData bitmapData = displayBitmaps[cameraIndex].LockBits(
|
||||
// new Rectangle(0, 0, (int)frameOut.stFrameInfo.nWidth, (int)frameOut.stFrameInfo.nHeight),
|
||||
// ImageLockMode.ReadWrite, displayBitmaps[cameraIndex].PixelFormat);
|
||||
|
||||
// CopyMemory(bitmapData.Scan0, convertParam.pDstBuffer,
|
||||
// (uint)(bitmapData.Stride * displayBitmaps[cameraIndex].Height));
|
||||
|
||||
// displayBitmaps[cameraIndex].UnlockBits(bitmapData);
|
||||
// }
|
||||
|
||||
// // 使用SDK显示 - 这是最稳定的方式
|
||||
// displayInfo.hWnd = pictureBoxes[cameraIndex].Handle;
|
||||
// displayInfo.pData = frameOut.pBufAddr;
|
||||
// displayInfo.nDataLen = frameOut.stFrameInfo.nFrameLen;
|
||||
// displayInfo.nWidth = frameOut.stFrameInfo.nWidth;
|
||||
// displayInfo.nHeight = frameOut.stFrameInfo.nHeight;
|
||||
// displayInfo.enPixelType = frameOut.stFrameInfo.enPixelType;
|
||||
|
||||
// // 在UI线程中调用显示
|
||||
// if (this.InvokeRequired)
|
||||
// {
|
||||
// this.Invoke(new Action(() =>
|
||||
// {
|
||||
// camera.MV_CC_DisplayOneFrame_NET(ref displayInfo);
|
||||
// }));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// camera.MV_CC_DisplayOneFrame_NET(ref displayInfo);
|
||||
// }
|
||||
|
||||
// // 释放图像缓冲区
|
||||
// camera.MV_CC_FreeImageBuffer_NET(ref frameOut);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"相机{cameraIndex + 1}采集异常: {ex.Message}");
|
||||
// // 继续循环,不退出
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 采集线程处理函数 - 添加视频录制(修改)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user