使用EmguCV从网络摄像头中捕获图像的方法如下:
Capture cap = new Capture(0);
Image < Bgr, byte > nextFrame = cap.QueryFrame();
...
...
但是我不知道如何从我的Kinect中捕获图像,我尝试过kinectCapture
类,但它对我没有用。
基本上,您需要从ColorStream捕获图像并将其转换为EmguCV Image类:
您有一个Windows Bitmap变量,其中保存了Kinect帧。
Bitmap bmap = new Bitmap(weightFrame,HeightFrame,System.Drawing.Imaging.PixelFormat.Format32bppRgb);
...
//Here is the code where you capture the image in the ColorFrameReady....
...
Image<Bgr,Byte> frameActualKinect = bmap.ToOpenCVImage<Bgr, Byte>();
调整大小
currentFrame = frameActualKinect.Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
//Convert it to Grayscale
gray = currentFrame.Convert<Gray, Byte>();
//Face Detector
MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,new System.Drawing.Size(20, 20));
P.D(辅助方法):
public static Image<TColor, TDepth> ToOpenCVImage<TColor, TDepth>(this Bitmap bitmap)
where TColor : struct, IColor
where TDepth : new()
{
return new Image<TColor, TDepth>(bitmap);
}