首页 > 解决方案 > 无法在 C# PictureBox 中显示 8MP 相机帧

问题描述

我有 C# 应用程序,它从 USB 相机下载帧并将它们显示在图片框中。适用于 ELP 5MP USB 相机。但是对于 SPINEL 8MP USB 相机,PictureBox 仍然是黑色的。

我正在使用 Windows 10 Pro 笔记本电脑和 Visual Studio 2017 C#,以及用于 USB 相机帧捕获的 Accord VideoCaptureDevice ( http://accord-framework.net/docs/html/T_Accord_Video_DirectShow_VideoCaptureDevice.htm )

尖晶石 8MP 相机的帧“newby”参数为:

H: 720
HR: 96
PHYS DIM: 1280 X 720
PixelFormat: 32bppArgb
VerRes: 96
W: 1280
1280 x 720

来自 ELP 5MP 相机的帧“newby”参数为:

h: 480
hr: 96
phys dim: 640 x 480
PixelFormat: 32bppArgb
Size: 640 X 480
VERTRES: 96
W: 640

开始从相机下载帧位图的 C# 代码:

var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
videoSource = new VideoCaptureDevice( videoDevices[0].MonikerString, pixelFormat_for_ExhaustiveTemplateMatching);
videoSource.NewFrame += new NewFrameEventHandler( EVENT_camera_frame );
videoSource.Start();

C#帧事件代码:

private static void EVENT_camera_frame(object sender, NewFrameEventArgs camera_frame_event)
{

Bitmap newby = new Bitmap(     camera_frame_event);

PictureBox_live_camera.Image = newby;
PictureBox_live_camera.BackgroundImage = newby;

       . . .  processing and Bitmap disposal . . .
}

标签: c#.netimageimage-processingbitmap

解决方案


推荐阅读