0

Kinect Panorama Demo

Anonymous 5 years ago 0
This discussion was imported from CodePlex

rakelmasuta wrote at 2014-03-13 00:35:

Hi..I already download the latest Helix3dToolkit and source code. I found the example of kinect integration. And in example i found panorama demo.
But, i can't found the source of integration between kinect and panorama demo.
Can you help me, please.

objo wrote at 2014-04-29 10:56:

Sorry, there is no panorama demo for Kinect.

rakelmasuta wrote at 2014-05-19 18:02:

I test to separate it for panorama demo only and add some feature like button instead.
here's the code :
~ mainwindow.xaml
<Window x:Class="PanoramaDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf" Title="TA Rakel" 
        xmlns:k="http://schemas.microsoft.com/kinect/2013"
        Height="480" Width="640">
        
    <Grid>
        
        <ht:HelixViewport3D x:Name="view1" ShowViewCube="False" ShowCameraTarget="False" CameraMode="FixedPosition" RotationSensitivity="0.6">
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <AmbientLight Color="White"/>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ht:PanoramaCube3D Source="Models\Opera\"/>
        </ht:HelixViewport3D>
        <k:KinectSensorChooserUI HorizontalAlignment="Center" VerticalAlignment="Top" Name="sensorChooserUi" />
        <k:KinectUserViewer VerticalAlignment="Top" HorizontalAlignment="Center" k:KinectRegion.KinectRegion="{Binding ElementName=kinectRegion}" Height="100" UserColoringMode="Manual" />
        <k:KinectRegion Name="kinectRegion">
            <Grid>
                <k:KinectTileButton Label="Press me!" Click="ButtonOnClick" VerticalAlignment="Top" Margin="28,0,0,0" HorizontalAlignment="Left"></k:KinectTileButton>
                <k:KinectCircleButton Label="Circle" HorizontalAlignment="Right" Height="200" VerticalAlignment="Top" Click="ButtonOnClick" >Hi</k:KinectCircleButton>
                <k:KinectScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" VerticalAlignment="Bottom">
                    <StackPanel Orientation="Horizontal" Name="scrollContent" />
                </k:KinectScrollViewer>
            </Grid>
        </k:KinectRegion>
    </Grid>
</Window>
~ mainwindow.xaml.cs
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MainWindow.xaml.cs" company="Helix 3D Toolkit">
//   http://helixtoolkit.codeplex.com, license: MIT
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
using Microsoft.Kinect.Toolkit;
using Microsoft.Kinect.Toolkit.Controls;
using Microsoft.Kinect.Toolkit.Interaction;

namespace PanoramaDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private KinectSensorChooser sensorChooser;

        public MainWindow()
        {
            InitializeComponent();
            Loaded += OnLoaded; /// kinect Loaded
            var camera = view1.Camera as PerspectiveCamera;
            camera.Position = new Point3D(0, 0, 0);
            camera.LookDirection = new Vector3D(0, 1, 0);
            camera.UpDirection = new Vector3D(0, 0, 1);
            camera.FieldOfView = 120;
           


        }
        /// <summary>
        /// Deteksi Status kinect
        /// </summary>

        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {

            this.sensorChooser = new KinectSensorChooser();
            this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
            this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
            this.sensorChooser.Start();
        }


        private void SensorChooserOnKinectChanged(object sender, KinectChangedEventArgs args)
        {
            bool error = false;
            if (args.OldSensor != null)
            {
                try
                {
                    args.OldSensor.DepthStream.Range = DepthRange.Default;
                    args.OldSensor.SkeletonStream.EnableTrackingInNearRange = false;
                    args.OldSensor.DepthStream.Disable();
                    args.OldSensor.SkeletonStream.Disable();
                }
                catch (InvalidOperationException)
                {
                    // KinectSensor might enter an invalid state while enabling/disabling streams or stream features.
                    // E.g.: sensor might be abruptly unplugged.
                    error = true;
                }
            }

            if (args.NewSensor != null)
            {
                try
                {
                    args.NewSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
                    args.NewSensor.SkeletonStream.Enable();


                }
                catch (InvalidOperationException)
                {
                    error = true;
                    // KinectSensor might enter an invalid state while enabling/disabling streams or stream features.
                    // E.g.: sensor might be abruptly unplugged.
                }
            }

            if (!error)
                kinectRegion.KinectSensor = args.NewSensor;
        }




        /// <summary>
        /// Untuk event on click button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
               
        private void ButtonOnClick(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Well done!");
        }
    }
}
How to control rotation of panorama image and make zoom for it by kinect region?

objo wrote at 2014-05-19 21:45:

this is interesting. I don't know much about the Kinect API, what gestures are you using to control the view?
Please fork and create a pull request to get your code merged into the Kinect examples.

rakelmasuta wrote at 2014-05-20 00:47:

i am thinking about camera manipulation. do you know how to do that?