2012年12月9日 星期日

Kinect SDK+ Speech SDK + Google Street View

OS: Windows 7 x64
Tools: Visual Studio 2010, Kinect SDK1.5, Speech SDK 11
Hardware: ASUS A43S, XBOX 360 Kinect.
1. Kinect SDK GreenScreen-WPF
2. WindowLoaded
     Add
     2-1 remove AllFrameReady event
     this.sensor.AllFramesReady -= this.SensorAllFramesReady;
     2-2 Add timier 10 secs
            計時器.Interval = new TimeSpan(0, 0, 10); // 10 secs
            計時器.Tick += new EventHandler(計時器_Tick);
            計時器.Start();
     2-3 Add voice commands
            Choices CMDs = new Choices();
            for (int i = 0; i < 地點名稱陣列.Length; i++)
                CMDs.Add(地點名稱陣列[i]);
            ....
      2-4 Timer event: Enable sensor and disable voice command or vice verse
            if (EventOn)
            {
                EventOn = false;
                this.sensor.AllFramesReady -= this.SensorAllFramesReady;
                sre.RecognizeAsync(RecognizeMode.Multiple);
            }
            else
            {
                EventOn = true;
                this.sensor.AllFramesReady += this.SensorAllFramesReady;
                sre.RecognizeAsyncCancel();
            }
3.
4. 下載

2012年12月8日 星期六

Disable event trigger for a fixed period

OS : Windows 7 x64
Tool: Visual Studio 2010 ultimate SP1
WPF application
1. To make 2  window events as Load and MouseWheel, the former is used to set the fixed period timer while the latter is used to generate the simulate event.
2. The trigger of MouseWheel will sent now to the title of window.


private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            this.Title += " " + DateTime.Now.Millisecond.ToString();
            EventOn = false;
            this.MouseWheel -= new MouseWheelEventHandler(Window_MouseWheel);
            t1.Stop();
            t1.Start();
        }
        System.Windows.Threading.DispatcherTimer t1 = new System.Windows.Threading.DispatcherTimer();
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            t1.Interval = new TimeSpan(0, 0, 0, 0, 200); //200 miliseconds
            t1.Tick += new EventHandler(t1_Tick);
            t1.Start();
        }

        bool EventOn = true;
        void t1_Tick(object sender, EventArgs e)
        {
            //this.Title += DateTime.Now.ToString();
            if (EventOn)
            {
                EventOn = false;
                this.MouseWheel -= new MouseWheelEventHandler(Window_MouseWheel);
            }
            else
            {
                EventOn = true;
                this.MouseWheel += new MouseWheelEventHandler(Window_MouseWheel);
            }
        }
3. Example shows the period may not being exactly 200 ms.


2012年12月3日 星期一

Speech SDK 語音辨識範例

1. OS: Windows 7 x64
2. Tools: VS 2010
               Speech SDK x64 (Install Runtime, SDK and then TTS SR zh-TW)
3.

<Grid>
        <Ellipse Name="OO" Margin="0,0,0,0" Stroke="Red" StrokeThickness="20" Visibility="Hidden"/>
        <Grid Name="XX" Margin="0,0,0,0" Visibility="Hidden" >
            <Line Stroke="Blue" StrokeThickness="20" X1="0" Y1="0" X2="525" Y2="350"/>
            <Line Stroke="Blue" StrokeThickness="20" X1="0" Y1="350" X2="525" Y2="0"/>
        </Grid>
  </Grid>
4.

// 1. Add Ref Microsoft Speech Object Library v 11 Not in COM
// C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly\Microsoft.Speech.dll
using Microsoft.Speech.Recognition;

namespace WPFOX1
{
    /// <summary>
    /// MainWindow.xaml 的互動邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Create a new SpeechRecognitionEngine instance.
            SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("zh-TW"));
            // SpeechRecognitionEngine sre = new SpeechRecognitionEngine();

            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();
            colors.Add("對");
            colors.Add("是");
            colors.Add("圈");
            colors.Add("錯");
            colors.Add("差");
            colors.Add("不對");
           
            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);

            // Create the actual Grammar instance, and then load it into the speech recognizer.
            Grammar g = new Grammar(gb);
            sre.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
            sre.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sre_SpeechRecognitionRejected);
            sre.SetInputToDefaultAudioDevice();
            sre.RecognizeAsync(RecognizeMode.Multiple);
        }

        void sre_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
        {
            this.Title = e.ToString();
        }

        void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            //this.Title = e.ToString();
            switch (e.Result.Text)
            {
                case "對":
                case "是":
                case "圈":
                    OO.Visibility = System.Windows.Visibility.Visible;
                    XX.Visibility = System.Windows.Visibility.Hidden;
                    break;
                case "錯":
                case "差":
                case "不對":
                    OO.Visibility = System.Windows.Visibility.Hidden;
                    XX.Visibility = System.Windows.Visibility.Visible;
                    break;
                default:
                    OO.Visibility = System.Windows.Visibility.Hidden;
                    XX.Visibility = System.Windows.Visibility.Hidden;
                    break;
            }
        }
    }
5 結果




2012年11月23日 星期五

Expression Encoder SDK Ex1

1. OS and Tools : Windows 8 + Expression 4 + VS2012
2. Sample code @
    C:\Program Files (x86)\Microsoft Expression\Encoder 4\SDK\Samples\Live
3. This program send a video (file) streaming into localhost:8080
4. Copy Wildlife.wmv into the same directory as live.exe
5. live Wildlie.wmv nd open the IE with url as mms://localhost:8080/

2012年10月26日 星期五

FileTracker:error FTK1011

Ref: http://www.dotblogs.com.tw/ricochen/archive/2010/06/15/15889.aspx

1. Download 3DTools souce code.
2. System: Mac Pro: VM : Windows 7 x64
    Tools: VS 2010
3. Open demo project with FileTracker error.
4. Solve problem by changing compiler from .net framework 3.0 to 4.0 as described in ref.

2012年10月23日 星期二

xbox controller test 2 (C#)

0-1 Hardware : ASUS A43S
0-2 OS: Windows 7 (x64)
0-3 Tools: VS 2010 (x86)
       - 1. XBox Controller Driver
              http://www.microsoft.com/hardware/en-us/d/xbox-360-wireless-controller-for-windows
       - 2. SlimDX x86 Runtime
              http://slimdx.org/download.php
1. using SlimDX.DLL (Downloadable)
2. Employ controls.cs from the example of the previous program.
3. using Xbox360Controller;
4. In the class of forms,

       GamepadState controls;
        Timer t1 = new Timer();
        private void Form1_Load(object sender, EventArgs e)
        {
            controls = new GamepadState(0);
            t1.Interval = 100;
            t1.Tick += new EventHandler(t1_Tick);
            t1.Start();
        }

        int i = 0;
        void t1_Tick(object sender, EventArgs e)
        {
            controls.Update();
            //this.Text = controls.LeftStick.Position.X.ToString() + ","
            //    + controls.LeftStick.Position.Y.ToString();
            //this.Text += (i++).ToString();
            if (controls.LeftStick.Position.X > 0.5) button1.Location = new Point(button1.Location.X + 10, button1.Location.Y);
            if (controls.LeftStick.Position.X < -0.5) button1.Location = new Point(button1.Location.X - 10, button1.Location.Y);
            if (controls.LeftStick.Position.Y > 0.5) button1.Location = new Point(button1.Location.X, button1.Location.Y-10);
            if (controls.LeftStick.Position.Y < -0.5) button1.Location = new Point(button1.Location.X, button1.Location.Y+10);
        }
5. All of the switches in the xbox controller can be read by a timer base event method();
6. Examples

XBOX360Controller Test

ref : http://visualcsharp.webs.com/projectdownloads.htm

1. Hardware: ASUS A43S, Microsoft wireless xbox controller
2. OS: Windows 8 (x64)
3. Tools: VS 2010(x86)

Download SlimDX (.NET4.0, x86) ** Notes x64 won't work.
http://slimdx.org/download.php