Using Kinect with Emgu CV

Using EmguCV to capture images from a webcam, we use:

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

But I do not know how to record images from my Kinect, I tried the kinectCapture class, but it did not work with me. thanks

+4
source share
2 answers

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

Convert to EmguCV image from Windows BitMap (Kinect ColorStream):

You have a Windows Bitmap variable where the Kinect Frame is stored.

 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 a discovery:

Change of size

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

PD (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); } 
+11
source

When using EmguCV, you usually use a different library to access Kinect. For example, Kinect for Windows SDK or OpenNI . Then, after accessing the camera using the OpenNI or SDK, you can edit the image that you project onto the screen using the EmguCV tools. Here are some links on how to use EmguCV with OpenNI and SDK

Hope this helps!

+2
source

All Articles