本文介绍了面对截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿那里!
Hey there!
有没有人知道如何捕获面部并制作快照并将其保存到位图???
Does anyone have any idea how to capture the face and make its snapshot and save it to bitmap???
我已经阅读了关于制作屏幕截图的文章,但我仍然不知道如何保存特定区域作为图像数据...
I already read the article about making screenshots, but I still have no idea how to save a specific area as image data...
如果有人可以帮助我,我会很感激。
I would appreciate that if someone could help me.
推荐答案
Open CV调用Emgu有一个包装器
There is a wrapper for the Open CV call Emgu
这些库包含3引用(Emgu.CV,Emgu.CV.UI,Emgu.Util)
these library is contains 3 references (Emgu.CV, Emgu.CV.UI, Emgu.Util)
你可以使用这些库轻松工作
you can work and get the face easily with these libraries
下载
并运行以下代码样本
using (HaarCascade face = new HaarCascade(faceFileName))
{
var frame = _kinectSensor.ColorStream.OpenNextFrame(100);
var image = frame.ToOpenCVImage<Rgb, Byte>();
using (Image<Gray, Byte> gray = image.Convert<Gray, Byte>()) //Convert it to Grayscale
{
gray._EqualizeHist();
MCvAvgComp[] facesDetected = face.Detect(
gray,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new System.Drawing.Size(20, 20));
foreach (MCvAvgComp f in facesDetected)
{
var rect = new System.Drawing.Rectangle(f.rect.X - f.rect.Width / 2
, f.rect.Y - f.rect.Height / 2
, f.rect.Width * 2
, f.rect.Height * 2);
image.Draw(f.rect, new Rgb(System.Drawing.Color.Blue), 2);
}
Dispatcher.BeginInvoke(new Action(() => { yourImage.Source = image.ToBitmapSource(); }));
}
}
这篇关于面对截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!