从C#.net中的网络摄像头拍照 [英] To take a photo from webcam in C#.net
本文介绍了从C#.net中的网络摄像头拍照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从事人脸检测项目。我有一个问题。我想从摄像头拍照并存储那张照片。我想要的地方。所以任何人都有一个C#的小代码按钮。当我按下这个按钮。然后摄像头会拍照。
谢谢in advance
Me working on face detection project.i have a problem. that i wanna take photo from webcam.and store that picture.where i want.so anyone have a small code in C# for button.when i press this button.then webcam will take a photo.
thanks in Advance
推荐答案
参见这里 [ ^ ]。
在button_click函数下编写此代码我希望这对你有用
private void button1_Click(object sender,EventArgs e)
{
if(pictureBox1.Image!= null)
{< br $>
//首先保存
位图varBmp =新位图(pictureBox1.Image);
位图newBitmap =新位图(varBmp);
varBmp.Save(@C: \a.png,ImageFormat.Png); //提供保存图像的路径以及图像名称
//现在处理以释放内存
varBmp.Dispose();
varBmp = null;
}
else
{MessageBox.Show(null exception); }
}
Write this code under button_click function I hope this will work for you
private void button1_Click(object sender, EventArgs e)
{
if (pictureBox1.Image != null)
{
//Save First
Bitmap varBmp = new Bitmap(pictureBox1.Image);
Bitmap newBitmap = new Bitmap(varBmp);
varBmp.Save(@"C:\a.png", ImageFormat.Png); //Give path to save image along with image name
//Now Dispose to free the memory
varBmp.Dispose();
varBmp = null;
}
else
{ MessageBox.Show("null exception"); }
}
这篇关于从C#.net中的网络摄像头拍照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文