Skip to content

Instantly share code, notes, and snippets.

@eklimcz-zz
Created November 21, 2012 16:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eklimcz-zz/4126015 to your computer and use it in GitHub Desktop.
Save eklimcz-zz/4126015 to your computer and use it in GitHub Desktop.
Kinect Depth Frame to OpenCV Image
Image<Bgr, Byte> openCVImg = new Image<Bgr, byte>(depthBmp.ToBitmap());
Image<Gray, byte> gray_image = openCVImg.Convert<Gray, byte>();
using (MemStorage stor = new MemStorage())
{
Contour<System.Drawing.Point> contours = gray_image.FindContours(
Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE,
Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_EXTERNAL,
stor);
for (int i = 0; contours != null; contours = contours.HNext)
{
i++;
if ((contours.Area > Math.Pow(sliderMinSize.Value, 2)) && (contours.Area < Math.Pow(sliderMaxSize.Value, 2)))
{
MCvBox2D box = contours.GetMinAreaRect();
blobCount++;
openCVImg.Draw(box, new Bgr(System.Drawing.Color.Red), 2);
blobCount++;
}
}
}
this.outImg.Source = ImageHelpers.ToBitmapSource(openCVImg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment