secile / UsbCamera

C# source code for using usb camera and web camera in WinForms/WPF. With only single CSharp source code. No external library required.
MIT License
179 stars 55 forks source link

一些针对wpf的升级 #6

Closed yangjieshao closed 3 years ago

yangjieshao commented 3 years ago
  1. 增加是否连接摄像头成功判断的函数
  2. 增加获取帧画面byte[]的函数(camera.GetBitmapBuffer) 用于更快的更新wpf的WriteableBitmap
  3. 根据needOldData配置获取过的帧画面下次获取是否返回(可用于判断是否断开连接)
  4. camera.GetBitmap 改为 可能返回 <null>
yangjieshao commented 3 years ago

PropertyChanged.Fody.nupkg WriteableBitmapHelper.cs ScreenBrushViewModel.cs can use like this

<Border
       Width="256"
       Height="256"
       Background="{Binding ScreenBrush.Brush}"
       CornerRadius="128" />
 private void OpenUsbCamera()
        {
            var deviceInfos = UsbCamera.FindDeviceInfos();
            if (deviceInfos.Count > 0)
            {
                ViewModel.ScreenBrush.CameraInfo =new CameraInfoViewModel
                {
                    Name = deviceInfos[0].Name,
                    Id = deviceInfos[0].DevicePath,
                    CameraIndex = 0
                };
            }
        }
yangjieshao commented 3 years ago

.