VideoCamera获得支持的分辨率 [英] VideoCamera get supported resolutions

查看:597
本文介绍了VideoCamera获得支持的分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将DirectShow库(DirectShowLib-2005.dll)与C#一起使用以捕获摄像机图像.在定义捕获对象的大小时,我具有以下参数:

I'm using DirectShow library (DirectShowLib-2005.dll) with C# to capture a video camera image. When I'm definig the capture object's size, I have these parameters:

const int VIDEOWIDTH = 640; // Depends on video device caps
const int VIDEOHEIGHT = 480; // Depends on video device caps
const int VIDEOBITSPERPIXEL = 24; // BitsPerPixel values determined by device

capture = new Capture(0, VIDEOWIDTH, VIDEOHEIGHT, VIDEOBITSPERPIXEL, pictureBox1);

我正在使用此循环获取设备名称.我能以某种方式读取每个摄像头的所有可能分辨率吗?

I'm using this loop for getting the names of devices. Can I somehow read every possible resolutions for each cam?

DsDevice[] capDevices;
capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
if (capDevices.Length == 0)
{
  //Could not found camera
}
else
{
  for (var i = 0; i < capDevices.Length; i++)
  {
    myCamerName = capDevices[i].Name.ToString();
  }
} 

推荐答案

视频源可能很灵活,可以支持您请求的任何分辨率(例如,在特定范围内),因此列出分辨率并不是过滤操作必不可少的.有两种方法可以获取视频源建议的分辨率,该分辨率表明支持以下视频:

The video source might be flexible to support any resolution you request (e.g. within certain bounds), so listing resolutions is not something indispensable for the filter operation. There are two methods to obtain resolutions suggested by the video source, resolutions it advertises support of:

    在过滤器的输出(捕获)引脚上使用IAMStreamConfig.GetStreamCaps方法
  1. .这就是MSDN建议开发人员实施的方式:

  1. using IAMStreamConfig.GetStreamCaps method on the output (capture) pin of the filter. This is how MSDN suggests that developers implement it: Exposing Capture and Compression Formats and you can query the capabilities respectively. Note that an enumerated capability obtained this way might be not a specific resolution, but a range of supported resolutions for specific pixel format instead.

另一种方法是使用IPin.EnumMediaTypes并列出可用的媒体类型(和分辨率).

Another method is to use IPin.EnumMediaTypes and list available media types (and resolutions).

另请参阅:

  • Windows: how to get cameras supported resolutions?
  • How to list up of the supported resolutions by a USB camera?
  • Enumerating supported Video Capture output sizes

这篇关于VideoCamera获得支持的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆