将Kinect与Emgu CV一起使用 [英] Using Kinect with Emgu CV

查看:115
本文介绍了将Kinect与Emgu CV一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过EmguCV,我们可以使用以下方法从网络摄像头捕获图像:

With EmguCV, to capture an image from a web-cam we use :

Capture cap = new Capture(0);

Image < Bgr, byte > nextFrame = cap.QueryFrame();

...

...

但是我不知道如何从Kinect捕获图像,我尝试了kinectCapture类,但是它不适用于我. 谢谢

But I don't know how to capture images from my Kinect, I have tried kinectCapture class but it didn't work with me. Thanks

推荐答案

基本上,您需要从ColorStream中捕获图像并转换为EmguCV Image类:

Basically , you need to capture and Image from the ColorStream and convert to a EmguCV Image class :

您有一个Windows位图变量,其中包含Kinect框架.

You have a Windows Bitmap variable, where holds 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<Bgr,Byte> frameActualKinect = bmap.ToOpenCVImage<Bgr, Byte>();

进行检测:

调整大小

Make the detection:

Resize

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(辅助方法):

P.D (The helper method) :

public static Image<TColor, TDepth> ToOpenCVImage<TColor, TDepth>(this Bitmap bitmap)
        where TColor : struct, IColor
        where TDepth : new()
    {
        return new Image<TColor, TDepth>(bitmap);
    }

这篇关于将Kinect与Emgu CV一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆