Skip to content

Instantly share code, notes, and snippets.

@FabienArcellier
Created December 8, 2013 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FabienArcellier/7862999 to your computer and use it in GitHub Desktop.
Save FabienArcellier/7862999 to your computer and use it in GitHub Desktop.
Helloworld avec Intel Perceptual Computing SDK 2013. Cet exemple est compatible avec une simple webcam.
namespace HelloWorldSDK
{
using System;
using System.Drawing;
using System.Threading;
class Program
{
static void Main(string[] args)
{
// Chargement de l environnement
PXCMSession session;
pxcmStatus sts = PXCMSession.CreateInstance(out session);
if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR)
{
throw new TypeLoadException("Fail to instanciate PXCM Session");
}
// Chargement du flux d une webcam
using (var pp = new UtilMPipeline())
{
// Si vous avez acces a la camerea creative, vous pouvez utiliser cette ligne.
// pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH, 320, 240);
pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_RGB32, 640, 480);
pp.Init();
while (!pp.AcquireFrame(true))
{
Thread.Sleep(50);
}
PXCMImage.ImageData idata;
PXCMImage image = pp.QueryImage(PXCMImage.ImageType.IMAGE_TYPE_COLOR);
pxcmStatus status = image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.ColorFormat.COLOR_FORMAT_RGB32, out idata);
if (status > pxcmStatus.PXCM_STATUS_NO_ERROR)
throw new ApplicationException("Fail to acquire a picture");
// On tag Hello World
Bitmap bitmap = idata.ToBitmap(640, 480);
using (var graphic = Graphics.FromImage(bitmap))
{
using (Font arialFont = new Font("Arial", 36))
{
graphic.DrawString("Hello World", arialFont, Brushes.Blue, new PointF(200,100));
}
}
// Sauvegarde de l image
Console.WriteLine("Nom de la capture ?");
string filePath = Console.In.ReadLine();
bitmap.Save(String.Concat(filePath, ".bmp"));
image.ReleaseAccess(ref idata);
pp.ReleaseFrame();
}
session.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment