Search code examples
c#wpfvisual-studiokinectkinect-sdk

Custom image in MainWindow not showing after Kinect starts


I'm following this simple example for attaching images to body parts: http://channel9.msdn.com/Series/KinectQuickstart/Skeletal-Tracking-Fundamentals

The problem is my image doesn't display. Ellipses and all other components I place in MainWindow display correctly but image is invisible.

This is MainWindow:

enter image description here

So, ellipses display well when I start Kinect but there is no image. This is generated XAML code:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WpfViewers="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers" x:Class="KinectSetupDev.MainWindow"
    Title="MainWindow" Height="480" Width="640" Closing="Window_Closing_1" Loaded="Window_Loaded_1">
<Grid>
    <Image x:Name="image1" HorizontalAlignment="Left" Height="356" VerticalAlignment="Top" Width="502"/>
    <Ellipse x:Name="rightEllipse" Fill="BlueViolet" HorizontalAlignment="Left" Height="45" Margin="122,41,0,0" Stroke="Black" VerticalAlignment="Top" Width="54"/>
    <Ellipse x:Name="leftEllipse" Fill="Cornsilk" HorizontalAlignment="Left" Height="42" Margin="30,61,0,0" Stroke="Black" VerticalAlignment="Top" Width="52"/>
    <Image x:Name="headImage" Source="smile.png" HorizontalAlignment="Left" Height="52" Margin="43,145,0,0" VerticalAlignment="Top" Width="57"/>
</Grid>

Is this some kind of a bug? In all tutorials image is just placed on MainWindow and normally displayed on screen. I have the latest SDK (v1.7). Any ideas?


Solution

  • I managed to solve the problem. Really small mistake ... If the image is not added directly in Visual Studio, it wont be recognized when Kinect starts. I added it only to project directory but not in Visual Studio. So, VS recognizes that image is there but when it starts it can't find it in project files. Because of that it's showing only in Visual Studio.

    I created directory Images in VS under my project and put image directly there and now it's working and image is normally displayed when application starts.

    <Image x:Name="Images/headImage" Source="smile.png" HorizontalAlignment="Left" Height="52" Margin="43,145,0,0" VerticalAlignment="Top" Width="57"/>