在此之前成为一个重复的主题,请不要因为How to set video resolution?上的答案没用而且不起作用我的问题和代码不同。
我在网站上四处寻找,但没有任何帮助。
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Imaging;
using System.Net;
using System.Drawing.Imaging;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private FilterInfoCollection VCD;
private VideoCaptureDevice FV;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
VCD = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo VCD in VCD)
{
comboBox1.Items.Add(VCD.Name);
}
comboBox1.SelectedIndex = 0;
FV = new VideoCaptureDevice();
/*THE CODE WHICH DOESNT WORK
for (int i = 0; i < FV.VideoCapabilities.Length; i++)
{
string resolution = "Resolution Number " + Convert.ToString(i);
string resolution_size = FV.VideoCapabilities[i].FrameSize.ToString();
comboBox2.Items.Add(resolution_size); //add resolution options in this combobox
}*/
}
private void button1_Click(object sender, EventArgs e)
{
//START / STOP CAMERA CODE
}
private void FV_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap video = (Bitmap)eventArgs.Frame.Clone();
pictureBox1.Image = video;
}
void videoSource_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
private void button2_Click(object sender, EventArgs e)
{
//TAKE PHOTO
pictureBox1.Image.Save("Photos\\capture1.jpg", ImageFormat.Jpeg);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
我试图添加设置来更改分辨率,因为默认值只有480p。