C3032
2026-01-07 a0c982ba8abdbd7569a6cae07812127a757fd410
更新相机实例化和UI线程处理逻辑

- 取消对 `LBCamera` 的注释,使其可实例化。
- 修改 `2DCameraForm.cs` 中的锁定逻辑,确保在 UI 线程上安全更新 `onlinePictureBox.Image`。
- 优化 `LBCamera.cs` 中的回调处理代码,提升可读性。
已修改3个文件
53 ■■■■ 文件已修改
LB_SmartVision/VisionForm.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Cameras/2DCameraForm.cs 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
LB_SmartVision/VisionForm.cs
@@ -688,7 +688,7 @@
                        }
                    case CameraBrand.LBCamera:
                        {
                            //camera = new LBCamera();
                            camera = new LBCamera();
                            break;
                        }
                    default:
LB_VisionProcesses/Cameras/2DCameraForm.cs
@@ -390,21 +390,20 @@
            if (e.Bitmap == null)
                return;
            lock (e.Bitmap)
            {
                if (this.InvokeRequired) // 检查是否需要在UI线程上调用
                lock (e.Bitmap)
                {
                    this.Invoke(new Action(() =>
                    if (this.InvokeRequired) // 检查是否需要在UI线程上调用
                    {
                        this.Invoke(new Action(() =>
                        {
                            onlinePictureBox.Image = e.Bitmap;
                        })); // 递归调用自身,但这次在UI线程上
                    }
                    else
                    {
                        onlinePictureBox.Image = e.Bitmap;
                    })); // 递归调用自身,但这次在UI线程上
                    }
                }
                else
                {
                    onlinePictureBox.Image = e.Bitmap;
                }
            }
            total.iImageCount++;
            try
            {
LB_VisionProcesses/Cameras/LBCameras/LBCamera.cs
@@ -266,27 +266,27 @@
        private void OnLineReceived(IntPtr pInstance, IntPtr buffer, int points)
        {
            // 实时回调处理:累积行数据
            if (!isGrabbing) return;
                // 实时回调处理:累积行数据
                if (!isGrabbing) return;
            int lineSize = points * Marshal.SizeOf(typeof(LBPointZA));
            byte[] lineData = new byte[lineSize];
            Marshal.Copy(buffer, lineData, 0, lineSize);
                int lineSize = points * Marshal.SizeOf(typeof(LBPointZA));
                byte[] lineData = new byte[lineSize];
                Marshal.Copy(buffer, lineData, 0, lineSize);
            lock (_bufferLock)
            {
                _lineDataBuffer.Add(lineData);
                _currentLineCount++;
            }
                lock (_bufferLock)
                {
                    _lineDataBuffer.Add(lineData);
                    _currentLineCount++;
                }
        }
        private void OnAcquisitionCompleted(IntPtr pInstance, int nOption)
        {
            // nOption: 0=一批数据结束, 1=全部完成, 2=点云就绪
            if (nOption == 1 || nOption == 0)
            {
                GenerateIntensityMap();
            }
                // nOption: 0=一批数据结束, 1=全部完成, 2=点云就绪
                if (nOption == 1 || nOption == 0)
                {
                    GenerateIntensityMap();
                }
        }
        private void GenerateIntensityMap()