Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
605 views
in Technique[技术] by (71.8m points)

c# - Using Kinect with Emgu CV

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

Capture cap = new Capture(0);

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

...

...

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

Conversion to EmguCV Image from Windows BitMap (Kinect ColorStream):

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 (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);
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...