Hello!

A couple of days ago I wrote a post about Vitruvius, and after this I get a couple of questions about this, so I’ll decide to write a couple of posts to describe how to use Vitruvius.

First of all, download the latest version of Vitruvius and build the solution (important: it has references to the Kinect dlls with a fixed path, you will have to fix them).

Once the solution is built, follow these steps.

1. Create a Wpf app project

2 Add external references to the Kinect Dll and also to

-%\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\Assemblies\Microsoft.Kinect.Toolkit.dll

-%\Program Files\Microsoft SDKs\Kinect\Developer Toolkit v1.8.0\Assemblies\Microsoft.Kinect.Toolkit.BackgroundRemoval.dll

4. Add a reference to [LightBuzz.Vitruvius] and [LightBuzz.Vitruvius.WPF].

5. Change the compilation of the project to x86

6. Change the MainWindow.xaml file

   1: <Window x:Class="WpfVit01.MainWindow"

   2:         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   3:         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   4:         Title="El Bruno - Vituvius Camera Feed"

   5:         Height="480"

   6:         Width="640">

   7:     <Grid>

   8:         <Image Name="ImageCamera" />

   9:     </Grid>

  10: </Window>

And then the same code CS

   1: using System.Windows;

   2: using LightBuzz.Vitruvius;

   3: using LightBuzz.Vitruvius.WPF;

   4: using Microsoft.Kinect;

   5:  

   6: namespace WpfVit01

   7: {

   8:     public partial class MainWindow : Window

   9:     {

  10:         public MainWindow()

  11:         {

  12:             InitializeComponent();

  13:             Loaded += MainWindow_Loaded;

  14:         }

  15:  

  16:         void MainWindow_Loaded(object sender, RoutedEventArgs e)

  17:         {

  18:             var sensor = SensorExtensions.Default();

  19:             if (sensor == null) return;

  20:             sensor.EnableAllStreams();

  21:             sensor.ColorFrameReady += Sensor_ColorFrameReady;

  22:             sensor.Start();

  23:         }

  24:         void Sensor_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)

  25:         {

  26:             using (var frame = e.OpenColorImageFrame())

  27:             {

  28:                 if (frame == null) return;

  29:                 ImageCamera.Source = frame.ToBitmap();

  30:             }

  31:         }

  32:  

  33:     }

  34: }

7 Run and ready!

image

With about 30 lines we have running our Kinect as a camera.

Saludos @ Valencia

El Bruno

image image image Google

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading