Microsoft Surface 2 as Image Source for EmguCV

Microsoft’s new Surface (i.e., the Samsung SUR40 device) features PixelSense which offers an image similar to that of a camera-based interactive surface (some example captures). The Surface driver already does quite a bit of processing (e.g., finger and orientation recognition or tag detection). Still, there are many more possible applications using the raw image data. To facilitate this, I put together some code that accesses the Surface’s raw image and prepares it to be used with Emgu CV (a C# OpenCV wrapper).

Output window showing Surface raw image with hand
The Surface's raw image ready to be processed with Emgu CV

The example application simply opens up an Emgu CV ImageViewer and updates the image whenever it becomes available. From here on, filters etc. can easily be applied.

ImageViewer viewer = new ImageViewer();
SurfaceCapture surfaceCapture = new SurfaceCapture();
surfaceCapture.Image += (s, e) =>
  viewer.Image = e.Image;

Source code: EmguCvSurface (updated [18.02.12] VisualStudio project)

14 thoughts on “Microsoft Surface 2 as Image Source for EmguCV

  1. As far as I understand, you want to set your project to be built for x86 to use the EmguCV 32-bit libraries, then it should also work under a 64-bit Windows installation.

  2. No, i want to use 64-bit Emgu
    right now i’ve some problems while combining Surface.Core processing and EmguCV

    but i’m trying to substitute msdnaa stuff with yours.
    i usually get stuck when i save my bitmap image (raw-image) into emgu image.
    But i think that is just cause i’m noob. i’ll figuring out 😉
    (and sorry for my not-so-understandable english)

    thanks 😉

  3. Ok,

    your stuff work for me just if are used for a Windows Form Application.
    I’m developing an application for the Surface, and with surface Emgu code the application be very slow.

    however, thanks again


  4. Yea, I haven’t tested it with WPF and didn’t do any performance evaluation. Anyway, good luck with your project – let me know how it goes :)!

  5. Hey,

    resolved the problem, i’ve used 1 row of your code (of course modified for my project):

    Image imageFrame = new Image(normalizedMetrics.Width, normalizedMetrics.Height) { Bytes = normalizedImage };

    and everything work very well 😀 i had some kind of lag when saving on bitmap before creating emgu image, and your simple code was really helpful

    thanks again


  6. Hello,

    I can’t get it to work on our SUR40. I have never used EmguCV before and I am really confused. sorry and any help would be greatly appreciated!

Comments are closed.