如何设置视频分辨率

本文关键字:视频 分辨率 设置 何设置 | 更新日期: 2023-09-27 18:35:53

我正在使用aForge,我正在尝试设置来自USB网络摄像头的视频馈送的分辨率,以便它适合pictureBox。我的目标是 800x600 的分辨率,但我得到的默认分辨率约为 640x480。当我尝试设置分辨率时,我收到"无法修改只读字段的成员"的消息。有aForge经验的人有任何想法/解决方案吗?

如何设置视频分辨率

确切地说:desiredFrameSize属性已过时。您必须使用 VideoResolution 属性;例如,使用分辨率编号 0:

yourvideoSource.VideoResolution = yourvideoSource.VideoCapabilities[0];

数组的编号表示不同的分辨率。

使用以下命令确定可用分辨率和尺寸的数量:

yourvideoSource.VideoCapabilities.Length;
for (int i = 0; i < yourvideoSource.VideoCapabilities.Length; i++ ){
    string resolution= "Resolution Number "+Convert.Tostring(i);
    string resolution_size = yourvideoSource.VideoCapabilities[i].FrameSize.ToString();
}

如何设置

yourvideoSource.DesiredFrameSize = new Size(800, 600);
您必须

根据VideoCaptureDevice的功能更改索引

const int IDX = 0; // change this
_videoSource = new VideoCaptureDevice(CurrentDevice.MonikerString)
{
    VideoResolution = new VideoCaptureDevice(CurrentDevice.MonikerString).VideoCapabilities[IDX]
};

之前的提示对我没有帮助,所以我花了一些时间来弄清楚