0

我使用 Expression.Encoder 编写了一些带有 Logitech 网络摄像头的 C# 代码接口。该代码很容易设置,并且在我的机器和测试人员的机器上运行良好。不幸的是,在现场,相机的预览屏幕显示黑屏。我已经确认相机在 Logitech 的应用程序和 MS 的 Expression 应用程序中都显示了一个提要。已安装 Windows Media Player 和 DirectX 11。问题似乎在于有人不工作的预览窗口创建。

// create the camera feed with just a video
currentJob = new LiveJob();
currentDeviceSource = currentJob.AddDeviceSource(currentVideoDevice, null);

System.Drawing.Size size = new System.Drawing.Size(250, 275);
currentDeviceSource.PickBestVideoFormat(size, (long)15);

SourceProperties sp = currentDeviceSource.SourcePropertiesSnapshot();
pnlCameraPreview.Size = new System.Drawing.Size(sp.Size.Width, sp.Size.Height);

currentJob.OutputFormat.VideoProfile.Size = new System.Drawing.Size(sp.Size.Width, sp.Size.Height);

// attach to the preview panel
currentDeviceSource.PreviewWindow = new PreviewWindow(new HandleRef(pnlCameraPreview, hwndPreviewPanel));
currentJob.ActivateSource(currentDeviceSource);

有问题的面板(pnlCameraPreview)是一个在 wpf 内部托管的 Windows 窗体面板。任何关于为什么这不起作用的想法将不胜感激!

4

1 回答 1

0

我们在生产中使用这种方法。它一直有效,但是当没有安装本机视频卡驱动程序时,可以在新盒子上重现问题。也许问题的根源在于在面板上绘制视频。顺便说一句,虽然观察到与发布的代码类似的问题,但 Skype 和 Encoder 的预览可以正常显示网络摄像头图片。

预览面板开始显示图片,并且在安装了所有适配器的驱动程序后代码开始正常工作。

于 2014-04-21T19:35:51.547 回答