嘿,我正在尝试在我的网络摄像头上找到将我的视频源更改为“复合”的设置。似乎如果我拔下 USB 然后重新插入并启动代码,它只是一个空白屏幕。但是一旦我更改了视频源(在另一个程序中)然后返回并再次运行我的代码,它就会显示出来。
所以我需要一些能让我改变它的东西,以便在我自己的应用程序中发生同样的事情,而不必启动另一个具有该功能的程序来设置网络摄像头。
当我拔出 USB 电缆然后将其重新插入并运行源代码时,应用程序的图片框是黑色的。
我用来更改视频源的“其他程序”(似乎可以显示图像):
在我使用那个“其他程序”之后,我回到源代码并运行它,这就是我得到的:
我在这里使用名为 dot Net Webcam Library 的 C# 代码:在此处输入链接描述
我在源代码中注意到它列出了不同类型的视频设置(在下面的 AXExtend.cs 中找到):
public enum PhysicalConnectorType
{
Video_Tuner = 1,
Video_Composite,
Video_SVideo,
Video_RGB,
Video_YRYBY,
Video_SerialDigital,
Video_ParallelDigital,
Video_SCSI,
Video_AUX,
Video_1394,
Video_USB,
Video_VideoDecoder,
Video_VideoEncoder,
Video_SCART,
Video_Black,
Audio_Tuner = 0x1000,
Audio_Line,
Audio_Mic,
Audio_AESDigital,
Audio_SPDIFDigital,
Audio_SCSI,
Audio_AUX,
Audio_1394,
Audio_USB,
Audio_AudioDecoder,
}
但我不确定如何在这里的代码中调用它:
Device selectedDevice = device as Device;
imageCapture.Device = selectedDevice as Device;
imageCapture.PerformAutoScale();
imageCapture.Refresh();
imageCapture.Start();
所以我猜我可能需要“Video_Composite”来做到这一点?
任何帮助都会很棒!!!谢谢!
大卫
代码更新
foreach (Device device in Device.FindDevices())
{
if (device.ToString() == "BackupCamera")
{
Device selectedDevice = device as Device;
IGraphBuilder graphBuilder = new FilterGraph() as IGraphBuilder;
DsDevice device1 = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice)[1]; // <<--- Your Device
Guid baseFilterIdentifier = typeof(IBaseFilter).GUID;
object videoSourceObject;
device1.Mon.BindToObject(null, null, ref baseFilterIdentifier, out videoSourceObject);
IBaseFilter videoSourceBaseFilter = videoSourceObject as IBaseFilter;
graphBuilder.AddFilter(videoSourceBaseFilter, "Source");
ICaptureGraphBuilder2 captureGraphBuilder = new CaptureGraphBuilder2() as ICaptureGraphBuilder2;
captureGraphBuilder.SetFiltergraph(graphBuilder);
object crossbarObject;
captureGraphBuilder.FindInterface(FindDirection.UpstreamOnly, null, videoSourceBaseFilter, typeof(IAMCrossbar).GUID, out crossbarObject);
IAMCrossbar crossbar = crossbarObject as IAMCrossbar;
int inputPinCount, outputPinCount;
crossbar.get_PinCounts(out inputPinCount, out outputPinCount); // <<-- In/Out Pins
// Pin Selection: Physical Input 2 (e.g. Composite) to Capture Pin 0
crossbar.Route(0, 2);
imageCapture.Device = selectedDevice as Device;
imageCapture.PerformAutoScale();
imageCapture.Refresh();
imageCapture.Start();
}
}