使用EmguCV,我们使用以下网络摄像头捕获图像:
Capture cap = new Capture(0);
Image < Bgr, byte > nextFrame = cap.QueryFrame();
...
...
Run Code Online (Sandbox Code Playgroud)
但是我不知道如何从我的Kinect中捕获图像,我已经尝试了kinectCapture课程,但它不适用于我.谢谢
小智 11
基本上,您需要从ColorStream捕获和Image并转换为EmguCV Image类:
你有一个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<Bgr,Byte> frameActualKinect = bmap.ToOpenCVImage<Bgr, Byte>();
Run Code Online (Sandbox Code Playgroud)
调整
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));
Run Code Online (Sandbox Code Playgroud)
PD(辅助方法):
public static Image<TColor, TDepth> ToOpenCVImage<TColor, TDepth>(this Bitmap bitmap)
where TColor : struct, IColor
where TDepth : new()
{
return new Image<TColor, TDepth>(bitmap);
}
Run Code Online (Sandbox Code Playgroud)