Click here to Skip to main content
15,886,783 members
Articles / Desktop Programming / WPF

Kinect Reception

Rate me:
Please Sign up or sign in to vote.
4.94/5 (34 votes)
12 Jan 2012Ms-PL5 min read 68.3K   2K   80  
TV Screen in the Reception, When nothing happens (no one is in the reception) we can display videos on the screen but when someone enters the frame show him the Kinect Image, and if the user is doing something funny, capture his image and save it.
// Written by Shai Raiten: http://blogs.microsoft.co.il/blogs/shair/

using System;
using System.Collections;
using System.IO;
using KinectReception.Enums;

namespace KinectReception.Managers
{
    public static class VideoManager
    {
        /// <summary>
        /// Define the type of video you want to play
        /// If you ask for out video and there isn't one return null - Stop Video and
        ///         start showing Kinect Image
        /// If you ask for in video and there isn't one then return random video.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
public static Uri GetVideo(VideoType type)
{
    if (string.IsNullOrEmpty(Properties.Settings.Default.VideosLibraryFolder) ||
        !Directory.Exists(Properties.Settings.Default.VideosLibraryFolder))
        return null;
    else
    {
        string value = null;
        switch (type)
        {
            case VideoType.In:
                value = Properties.Settings.Default.VideosLibraryInFile;
                return string.IsNullOrEmpty(value) || !File.Exists(value) ?
                    CollectRandomMovie() : new Uri(value);
            case VideoType.Out:
                value = Properties.Settings.Default.VideosLibraryOutFile;
                return string.IsNullOrEmpty(value) || !File.Exists(value) ?
                    null : new Uri(value);
            default:
                return CollectRandomMovie();
        }
    }
}

private static Uri CollectRandomMovie()
{
    var movies = new ArrayList();

    foreach (var filter in Properties.Settings.Default.VideoFilter)
        movies.AddRange(Directory.GetFiles(Properties.Settings.Default.VideosLibraryFolder,
            filter));

    if (movies.Count == 0) return null;

    var rnd = new Random();
    return new Uri(movies[rnd.Next(movies.Count)].ToString());
}
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Architect Sela
Israel Israel
Shai Raiten is VS ALM MVP, currently working for Sela Group as a ALM senior consultant and trainer specializes in Microsoft technologies especially Team System and .NET technology. He is currently consulting in various enterprises in Israel, planning and analysis Load and performance problems using Team System, building Team System customizations and adjusts ALM processes for enterprises. Shai is known as one of the top Team System experts in Israel. He conducts lectures and workshops for developers\QA and enterprises who want to specialize in Team System.

My Blog: http://blogs.microsoft.co.il/blogs/shair/

Comments and Discussions