使用Kinect和Emgu CV
使用EmguCV,我们使用以下网络摄像头捕获图像:
Capture cap = new Capture(0); Image nextFrame = cap.QueryFrame(); ... ...
但是我不知道如何从我的Kinect中捕获图像,我已经尝试过kinectCapture
类,但它不适用于我。 谢谢
基本上,您需要从ColorStream捕获和Image并转换为EmguCV Image类:
从Windows BitMap(Kinect ColorStream)转换为EmguCV图像:
你有一个Windows Bitmap变量,其中包含Kinect Frame。
Bitmap bmap = new Bitmap(weightFrame,HeightFrame,System.Drawing.Imaging.PixelFormat.Format32bppRgb); ... //Here is the code where you capture the image in the ColorFrameReady.... ... Image frameActualKinect = bmap.ToOpenCVImage();
进行检测:
调整
currentFrame = frameActualKinect.Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //Convert it to Grayscale gray = currentFrame.Convert(); //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));
PD(辅助方法):
public static Image ToOpenCVImage(this Bitmap bitmap) where TColor : struct, IColor where TDepth : new() { return new Image(bitmap); }
使用EmguCV时,通常使用另一个库来访问Kinect。 例如, Kinect For Windows SDK或OpenNI 。 然后在使用OpenNI或SDK访问摄像机后,您可以使用EmguCV的工具编辑在屏幕上投影的图像。 以下是如何将EmguCV与OpenNI和SDK一起使用的一些链接
- https://groups.google.com/forum/#!topic/openni-dev/I0InsNgIIz4
- http://www.geek-press.com/?p=23(SDK的 beta 2)
- Emgu CV和官方微软Kinect SDK?
希望这可以帮助!