图像采集需要调用摄像头就行拍照操作,网上查了一下资料,需要引用以下3个dll。

看一下运行界面

界面都比较low,主要是功能实现。
private void Camera_Load(object sender, EventArgs e)
{
this.btnSave.Enabled = false;
try
{
borderSize = GetBorderSize(this);
captionHeight = GetCaptionHeight(this);
//InitStudent("", "", "");
this.comboBox_SizeMode.Text = "填充(保持比例)";
FilterInfoCollection infos = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if ((infos != null) && (infos.Count > 0))
{
}
else
{
MessageBox.Show("没有视频设备");
}
this.LoadVedio();
this.splitContainer1.Panel2MinSize = 280;
this.splitContainer1.SplitterDistance = this.splitContainer1.Width - this.splitContainer1.Panel2MinSize + 1;
mf = new BorderForm();
mf.Show(this);
//mf.Left = (this.Left + this.splitContainer1.Panel1.Width - mf.Width) / 2;
//mf.Top = (this.Top + this.splitContainer1.Panel1.Height - mf.Height) / 2;
//marLeft = mf.Left - this.Left;
//marTop = mf.Top - this.Top;
Rectangle rtPic = this.pictureBox_Camera.RectangleToScreen(this.pictureBox_Camera.ClientRectangle);
Rectangle rtMF = this.mf.RectangleToScreen(this.mf.ClientRectangle);
if (rtPic == null || rtMF == null || rtPic.Width == 0 || rtMF.Width == 0)
{
return;
}
mf.Left = ((rtMF.Width + rtMF.Left) + (rtPic.Width + rtPic.Left)) / 2;
mf.Top = ((rtMF.Height + rtMF.Top) + (rtPic.Height + rtPic.Top)) / 2;
mf.SizeChanged += new EventHandler(mf_SizeChanged);
mf.LocationChanged += new EventHandler(mf_LocationChanged);
pictureBox_Camera_SizeChanged(sender, e);
//启动连拍
//this.ShootOneTime = 0;
this.timer1.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
//加载摄像头设备
private void LoadVedio()
{
FilterInfoCollection infos = new FilterInfoCollection(FilterCategory.VideoInputDevice);
if ((infos != null) && (infos.Count > 0))
{
int index = 0;
foreach (FilterInfo info in infos)
{
this.cmbCaptureDevice.Items.Add(new DeviceInfo(info.Name, info.MonikerString, index, FilterCategory.VideoInputDevice));
index++;
}
this.cmbCaptureDevice.SelectedIndex = 0;
}
}
/// <summary>
/// 拍照
/// </summary>
private void Shoot()
{
try
{
if (this.pictureBox_Camera.Image != null && (int)this.numericUpDown1.Value > 0 && (int)this.numericUpDown2.Value > 0)
{
Bitmap resultImage = new Bitmap((int)this.numericUpDown1.Value, (int)this.numericUpDown2.Value);
Graphics g = Graphics.FromImage(resultImage);
g.CopyFromScreen(new Point(this.mf.Location.X + 1, this.mf.Location.Y + 1), new Point(6, 6 + (is










