<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4995941213040074756</id><updated>2024-09-06T01:06:17.585+09:00</updated><category term="KINECT"/><category term="C#"/><category term="VB"/><category term="Edison"/><category term="Intel"/><category term="RaspberryPi2"/><category term="SQLServer"/><category term="音声認識"/><category term="Galileo"/><category term="IoT"/><category term="Node.js"/><category term="OpenCV"/><category term="SpeechPlatform"/><category term="V2"/><category term="WPF"/><category term="Azure"/><category term="Debian"/><category term="HVC"/><category term="LXC"/><category term="LeapMotion"/><category term="LocalDB"/><category term="TechCrunchHackathon"/><category term="Ubuntu"/><category term="UnixBench"/><category term="VBA"/><category term="VNC"/><category term="Windows"/><category term="Windows10IoTCore"/><category term="WindowsIoT"/><category term="gracenote"/><category term="ubilinux"/><category term="デスクトップ"/><category term="プライベートクラウド"/><category term="音声合成"/><title type='text'>雑多な日記</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-5662280204040410893</id><published>2018-01-15T11:54:00.000+09:00</published><updated>2018-01-15T11:55:24.012+09:00</updated><title type='text'>「独習　C#　新版」レビュー</title><content type='html'>先月中旬（2017/12/15）に久々にC#の解説書が発売になりました。&lt;br /&gt;
山田祥寛 著「独習C#　新版」です。前書「独習C#　第３版」の発売から7年ぶりに新版が出版されました。C#のバージョンも4.0から7.1までと最新の言語仕様ついてまで解説されています。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoKIlW4zqFH5poV58o0NuAQ44UTtkA_nURRgid7k8iOI0TsBU5hgyW5MXmB4dscPwsKE0HjK1Es4zqPh5jqE8Sb8wFKMfl30mVgBwcYH7Y7GXjaP8JVmTH61KJcQ-I6X9W5r9nnUSsSp_/s1600/L.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;179&quot; data-original-width=&quot;140&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoKIlW4zqFH5poV58o0NuAQ44UTtkA_nURRgid7k8iOI0TsBU5hgyW5MXmB4dscPwsKE0HjK1Es4zqPh5jqE8Sb8wFKMfl30mVgBwcYH7Y7GXjaP8JVmTH61KJcQ-I6X9W5r9nnUSsSp_/s1600/L.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
数々のC#本は発売されていますが、言語仕様についての解説がされている本はあまり多くはないと思います。&lt;br /&gt;
&lt;br /&gt;
第1章から第4章&lt;br /&gt;
　C#についての基本的な説明です。変数や制御構文などプログラミング言語の使用についての解説です。他の言語の経験があればそれほど難しい内容ではないと思います。&lt;br /&gt;
&lt;br /&gt;
第5章、第6章&lt;br /&gt;
　標準ライブラリ、コレクションといったC#（あるいは.Net）独自機能についての解説になります。かならずしもC#だけというわけではないですが、この章をよめば.net　frameworkが提供している便利な機能を利用するのに参考になるでしょう。&lt;br /&gt;
&lt;br /&gt;
第7章から第9章&lt;br /&gt;
　C#におけるオブジェクト指向プログラミンについての解説がされています。結構ボリュームがあって一度読んだだけでは理解できないかもしれません。しかし、丁寧な説明がされているので何度か読み直せばしだいに理解できると思います。&lt;br /&gt;
&lt;br /&gt;
第10章&lt;br /&gt;
　ラムダ式、LINQといった使いこなせるとコーディングの効率を上げることができる機能についての解説がされています。&lt;br /&gt;
&lt;br /&gt;
第11章&lt;br /&gt;
　マルチスレッド処理、ダイナミック型、イベントなどWindowsアプリケーションを作成するときによく使う機能についての解説がされています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
すでに他の言語の経験がある人は前半は軽く読み飛ばしても大丈夫だと思います。第5章以降はC#独自の機能も入ってくるのでじっくり腰を落ち着けて読み進めるのがいいでしょう。サンプルプログラムも基本短い（たぶん一番長くても見開き2ページ分まで）ものが多いので解説を読みながら、プログラムの確認をすることができます。また図表もたくさんあるので大量の解説文とにらめっこしながら読み進めるということもありません。一度で内容を理解できなくても繰り返し、読み進めれば理解を深めることができるのではないでしょうか。&lt;br /&gt;
&lt;br /&gt;
　この本ではWPF/UWPといったGUIアプリケーションの解説はほとんどありません。基本的にサンプルプログラムはコンソールアプリケーションです。よってWindows用アプリケーションを作成したい場合には他の入門書を参考にする必要があります。&lt;br /&gt;
　C#の言語仕様についてより詳しく勉強したい人にお勧めします。また、現在MSでは大量のサンプルプログラムをGitHub上で公開しています。それらのサンプルプログラムを読む際に本書を手元に置いておくと、プログラムの内容についてより理解ができるのではないでしょうか。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/5662280204040410893/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2018/01/c.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5662280204040410893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5662280204040410893'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2018/01/c.html' title='「独習　C#　新版」レビュー'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoKIlW4zqFH5poV58o0NuAQ44UTtkA_nURRgid7k8iOI0TsBU5hgyW5MXmB4dscPwsKE0HjK1Es4zqPh5jqE8Sb8wFKMfl30mVgBwcYH7Y7GXjaP8JVmTH61KJcQ-I6X9W5r9nnUSsSp_/s72-c/L.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-4877426435149615599</id><published>2016-01-13T12:43:00.000+09:00</published><updated>2016-01-13T12:47:04.952+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RaspberryPi2"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows10IoTCore"/><title type='text'>Windows10 IoT Core アップデート　履歴</title><content type='html'>しばらくこちらへの投稿はしていなかったのですが、Windows10 IoT Coreに関してメモ的な内容はこちらにも書いていこうかと思っています。&lt;br /&gt;
&lt;br /&gt;
ちょうど先日（2016年1月11日付）アップデートの&lt;a href=&quot;https://blogs.msdn.microsoft.com/iot/2016/01/11/announcing-the-windows-10-iot-core-update/&quot;&gt;告知&lt;/a&gt;がありました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
これを機会にIoTCoreのリリース履歴を簡単にまとめてみたいと思います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2015年4月29日　Preview版限定リリース&lt;br /&gt;
&lt;br /&gt;
2015年5月12日　修正リリース&lt;br /&gt;
&lt;br /&gt;
2015年6月24日　最終候補版リリース&lt;br /&gt;
&lt;br /&gt;
2015年7月29日　正式版リリース(Build10240）&lt;br /&gt;
&lt;br /&gt;
2015年9月25日　Septemberリリース（Build10531）　&lt;br /&gt;
&lt;br /&gt;
2015年10月15日　Octoberリリース（Build10556）　シリアルポートが使えるようになった。&lt;br /&gt;
&lt;br /&gt;
2015年12月4日 Decemberリリース（Build10586）　国内のWifiアダプターが利用できるようになった。DragonBoard410cに対応&lt;br /&gt;
&lt;br /&gt;
2016年1月11日　Januaryリリース（Build10586.63）&amp;lt;--現在はここ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
正式版リリースからほぼ1か月～1か月半でアップデートがありますね。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/4877426435149615599/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2016/01/windows10-iot-core.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4877426435149615599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4877426435149615599'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2016/01/windows10-iot-core.html' title='Windows10 IoT Core アップデート　履歴'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-5357102206784378174</id><published>2015-04-05T01:57:00.001+09:00</published><updated>2015-04-05T01:57:04.163+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LXC"/><category scheme="http://www.blogger.com/atom/ns#" term="RaspberryPi2"/><category scheme="http://www.blogger.com/atom/ns#" term="Ubuntu"/><title type='text'>RaspBerryPi2でプライベートクラウドに挑戦（２）－－－LXCのインストール</title><content type='html'>RasPi2でクラウド環境を構築していくわけですが、どのOSSで構築するのか検討した結果CloudStackにしました。また、仮想化環境についてはRasPi2の性能も考えてLXCでやってみることにします。&lt;br /&gt;
&lt;br /&gt;
まず、CloudStackをインストールする前に仮想化環境のチェックのためLXCをインストールしてみました。&lt;br /&gt;
&lt;br /&gt;
OSはUbuntuに変更しています。OSイメージは&lt;a href=&quot;http://www.raspberrypi.org/forums/viewtopic.php?f=56&amp;amp;t=98997&quot;&gt;こちら&lt;/a&gt;から入手しました。&lt;br /&gt;
&lt;br /&gt;
LXCのインストールは特別なことはなく、「sudo apt-get install lxc」でインストールできます。&lt;br /&gt;
&lt;br /&gt;
Raspbianでも同じようにインストールできるのですが、仮想環境をスタートするときに「/cgroupがない」といって怒られるので、前もって&lt;br /&gt;
&lt;br /&gt;
「sudo mkdir /cgroup」&lt;br /&gt;
「sudo mount -t cgroup cgroup /cgroup」&lt;br /&gt;
&lt;br /&gt;
を実行してください。&lt;br /&gt;
&lt;br /&gt;
さて、UbuntuでのLXCですが、なぜか「lxc-list」コマンドがありません。「lxc-ls」コマンドは使えるので困ることはあまりないのですけども。Raspbianでは両方のコマンドが使えます。&lt;br /&gt;
&lt;br /&gt;
テンプレートについてはUbuntuの方が多くあるようです。&lt;br /&gt;
&lt;br /&gt;
現時点では以下のようになっています。&lt;br /&gt;
---------------------------------------------------------------------------&lt;br /&gt;
linaro@raspberry:/usr/share/lxc/templates$ ls -al&lt;br /&gt;
total 352&lt;br /&gt;
drwxr-xr-x 2 root root &amp;nbsp;4096 Apr &amp;nbsp;4 08:52 .&lt;br /&gt;
drwxr-xr-x 6 root root &amp;nbsp;4096 Apr &amp;nbsp;4 08:52 ..&lt;br /&gt;
-rwxr-xr-x 1 root root 10789 Oct 10 04:54 lxc-alpine&lt;br /&gt;
-rwxr-xr-x 1 root root 13625 Oct 10 04:54 lxc-altlinux&lt;br /&gt;
-rwxr-xr-x 1 root root 10786 Oct 10 04:54 lxc-archlinux&lt;br /&gt;
-rwxr-xr-x 1 root root &amp;nbsp;9446 Oct 10 04:54 lxc-busybox&lt;br /&gt;
-rwxr-xr-x 1 root root 29293 Oct 10 04:54 lxc-centos&lt;br /&gt;
-rwxr-xr-x 1 root root 10150 Oct 10 04:54 lxc-cirros&lt;br /&gt;
-rwxr-xr-x 1 root root 14576 Oct 10 04:54 lxc-debian&lt;br /&gt;
-rwxr-xr-x 1 root root 17427 Oct 10 04:54 lxc-download&lt;br /&gt;
-rwxr-xr-x 1 root root 47561 Oct 10 04:54 lxc-fedora&lt;br /&gt;
-rwxr-xr-x 1 root root 27808 Oct 10 04:54 lxc-gentoo&lt;br /&gt;
-rwxr-xr-x 1 root root 13961 Oct 10 04:54 lxc-openmandriva&lt;br /&gt;
-rwxr-xr-x 1 root root 13869 Oct 10 04:54 lxc-opensuse&lt;br /&gt;
-rwxr-xr-x 1 root root 40371 Oct 10 04:54 lxc-oracle&lt;br /&gt;
-rwxr-xr-x 1 root root 11837 Oct 10 04:54 lxc-plamo&lt;br /&gt;
-rwxr-xr-x 1 root root &amp;nbsp;6851 Oct 10 04:54 lxc-sshd&lt;br /&gt;
-rwxr-xr-x 1 root root 25489 Oct 10 04:54 lxc-ubuntu&lt;br /&gt;
-rwxr-xr-x 1 root root 12401 Oct 10 04:54 lxc-ubuntu-cloud&lt;br /&gt;
---------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
初回仮想環境を作成するときは約10分ほどかかります。2回目以降はキャッシュからコピーするので数十秒で作成できるようになります。&lt;br /&gt;
&lt;br /&gt;
操作に関しては&lt;a href=&quot;http://www.server-world.info/query?os=Ubuntu_14.04&amp;amp;p=lxc&quot;&gt;こちら&lt;/a&gt;のサイトを参考にさせていただきました。&lt;br /&gt;
http://www.server-world.info/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/5357102206784378174/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2015/04/raspberrypi2lxc.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5357102206784378174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5357102206784378174'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2015/04/raspberrypi2lxc.html' title='RaspBerryPi2でプライベートクラウドに挑戦（２）－－－LXCのインストール'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-2669051229591568904</id><published>2015-04-02T13:47:00.001+09:00</published><updated>2015-04-02T13:47:08.695+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="RaspberryPi2"/><category scheme="http://www.blogger.com/atom/ns#" term="UnixBench"/><category scheme="http://www.blogger.com/atom/ns#" term="プライベートクラウド"/><title type='text'>RaspBerryPi2でプライベートクラウドに挑戦（１）</title><content type='html'>RaspberryPi2（以下RasPi2)が発売されて、すぐに購入してみました。なんとなく今は3台手元にあります。&lt;br /&gt;特に使い道もなくしばらく箱に入った状態だったのですが、どうせ複数台あるならクラスター作ったりHPCっぽくしてみたりできないかなと色々調べてみるとOpenStackやCloudStackなどでプライベートクラウドを作ることができそうなので、挑戦してみることにしました。&lt;br /&gt;
&lt;br /&gt;
クラウドといえば使ったことがあるのはMicrosoftAzureだけなので、OSSのクラウド環境については勉強しつつやっていくことになります。&lt;br /&gt;
&lt;br /&gt;
最初はRasPi2がどれくらいの性能（RasPiB+より6倍速いらしい）があるのか気になったので、ベンチマークを行ってみました。&lt;br /&gt;
&lt;br /&gt;
ベンチマークの対象はRasPi2,Edison,MicrosoftAzure VM Basic A0～A3です。&lt;br /&gt;
RasPi2には最新のRaspbianをインストールしました。Edisonは標準Linuxをインストールしています。&lt;br /&gt;AzureについてはDebianのイメージが標準で用意されていないので、デプロイ王子こと廣瀬一海氏が作成したDebianイメージを利用させていただきました。&lt;br /&gt;
&lt;br /&gt;
ベンチマークにはUnixBenchの最新版を使っています。&lt;br /&gt;
&lt;br /&gt;
各マシンはOSをインストール後必要なアップデートを行ったのみの状態です。&lt;br /&gt;
マシンごとのアーキテクチャが全く違うので、DhrystoneとWhetstoneおよびSystem Benchmarks Index Scoreのみ比較しています。&lt;br /&gt;
&lt;br /&gt;
以下は表とグラフです。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8xk0EgQOp_PydeMRTeyt4_venDt0_dwWK0o4HTr09JnwQ2jjEeHb_o5ofsT3DuByk364UNEeZMv8CDl2_EvR_EGqxQGmLGCSZfGvUi86zyGehQnWR84HV7I2396ldJ-9xx-zkENR7fNiO/s1600/table.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8xk0EgQOp_PydeMRTeyt4_venDt0_dwWK0o4HTr09JnwQ2jjEeHb_o5ofsT3DuByk364UNEeZMv8CDl2_EvR_EGqxQGmLGCSZfGvUi86zyGehQnWR84HV7I2396ldJ-9xx-zkENR7fNiO/s1600/table.jpg&quot; height=&quot;126&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggH-Vpz1JuWRRtHp_g8gxc3kn2Ivo3JRyP5tQ30WSuYJbn-fONYzFgkrd5_CpsZ-UBpE6bOt_SV_1CreE1IEh5AxyewzL2jsetSJwDKoG_fvb2Nc451s7ySUawPy9UaPzWfV-nsMy75OwM/s1600/dhry.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggH-Vpz1JuWRRtHp_g8gxc3kn2Ivo3JRyP5tQ30WSuYJbn-fONYzFgkrd5_CpsZ-UBpE6bOt_SV_1CreE1IEh5AxyewzL2jsetSJwDKoG_fvb2Nc451s7ySUawPy9UaPzWfV-nsMy75OwM/s1600/dhry.jpg&quot; height=&quot;255&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgXddbRsU2R0HpsSb2MVEPn1xIqZXbUw4crT9C19s26lcVUpWxTsS2keePwlQ42qDw57wm405yLwUkr0uZV2i_wnabRKy_xPwnzt0ueXFE-sG7fRqoCORPcsJvA0cDOCbJwvHE5yypbel9/s1600/whet.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgXddbRsU2R0HpsSb2MVEPn1xIqZXbUw4crT9C19s26lcVUpWxTsS2keePwlQ42qDw57wm405yLwUkr0uZV2i_wnabRKy_xPwnzt0ueXFE-sG7fRqoCORPcsJvA0cDOCbJwvHE5yypbel9/s1600/whet.jpg&quot; height=&quot;259&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4qJXNt-2Ov7IePyijfpJMRrbe8f7TAhbjlxwd600w0QBDdgX6AflMhuEee7rxtIbzFqceXS99znv_6-WE0l1wbqPQc8l8xro-ScuhGBtUpw9kNvSE5XWAH0MFI3uZizwneeF_fBLcRNuq/s1600/index.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4qJXNt-2Ov7IePyijfpJMRrbe8f7TAhbjlxwd600w0QBDdgX6AflMhuEee7rxtIbzFqceXS99znv_6-WE0l1wbqPQc8l8xro-ScuhGBtUpw9kNvSE5XWAH0MFI3uZizwneeF_fBLcRNuq/s1600/index.jpg&quot; height=&quot;254&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
グラフを見るとRasPi2はAzureA0とほぼ同じくらいの性能になるようです。&lt;br /&gt;簡易なWebサーバぐらいなら余裕でインターネットに公開できそうです。&lt;/div&gt;
&lt;br /&gt;
今日はここまでとします。&lt;br /&gt;次回はプライベートクラウドを構築するのに必要なOSSについて書いてみたいと思います。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/2669051229591568904/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2015/04/raspberrypi2.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2669051229591568904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2669051229591568904'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2015/04/raspberrypi2.html' title='RaspBerryPi2でプライベートクラウドに挑戦（１）'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8xk0EgQOp_PydeMRTeyt4_venDt0_dwWK0o4HTr09JnwQ2jjEeHb_o5ofsT3DuByk364UNEeZMv8CDl2_EvR_EGqxQGmLGCSZfGvUi86zyGehQnWR84HV7I2396ldJ-9xx-zkENR7fNiO/s72-c/table.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-6489959457284880332</id><published>2015-02-15T17:54:00.000+09:00</published><updated>2015-02-15T17:56:13.733+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Galileo"/><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="WindowsIoT"/><title type='text'>Galileo Gen2 + WindowsIoT + node.js</title><content type='html'>RaspberryPi2でWindowsIoTが対応するみたいなのでRspberryPi2をほしいのですが、いまだに手に入れられません・・・&lt;br /&gt;
&lt;br /&gt;
さて、1月27日にWindowsIoTのアップデートがあって、node.js（Win32アプリが色々動く）を動作させる方法が公開されたのでやってみました。&lt;br /&gt;
&lt;br /&gt;
手順は&lt;a href=&quot;http://ms-iot.github.io/content/NodeJS.htm&quot; target=&quot;_blank&quot;&gt;こちら&lt;/a&gt;で公開されています。&lt;br /&gt;
&lt;br /&gt;
実際にやってみました。&lt;br /&gt;
&lt;br /&gt;
１．最新版のWindows imageを用意します。最新のイメージは2014/11/21の日付です。それとapply-bootmedis.cmd（2015/2/5）もダウンロードしておきます。microSDにイメージを展開して起動するのを確認しましょう。起動メディアの作成方法は&lt;a href=&quot;http://www.syuheiuda.com/?p=3136&quot; target=&quot;_blank&quot;&gt;こちら&lt;/a&gt;が参考になります。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
２．Windowsが起動したら、適当なところにフォルダを作成します。「C:\node」と作成しました。Telnetでもいいですが、GalileoWatcherで右クリックして「Open Network Share」を選ぶとすぐにCドライブにアクセスできるのでそちらから作成するのが色々楽です。&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8EdTdqFtAEM-hTBRQYkpHznPVDJD_xBJKYZyNbCCA4ywc7-lW-Sr4v9YPA55PqIGvQyxg5O_kNkoyji9eDQPF01v32UiaNPelwvzuooS0G1CJkvAP43QXdTIRoPIj8oECFEYmgMonO50p/s1600/watcher.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8EdTdqFtAEM-hTBRQYkpHznPVDJD_xBJKYZyNbCCA4ywc7-lW-Sr4v9YPA55PqIGvQyxg5O_kNkoyji9eDQPF01v32UiaNPelwvzuooS0G1CJkvAP43QXdTIRoPIj8oECFEYmgMonO50p/s1600/watcher.png&quot; height=&quot;197&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
３．&lt;a href=&quot;http://nodejs.org/download/&quot;&gt;nodejs.org&lt;/a&gt;からWindows32bit版のnode.exeをダウンロードして、先ほど作成したフォルダへコピーしておきます。&lt;br /&gt;
&lt;br /&gt;
４．最新のnpm zipファイルを&lt;a href=&quot;http://nodejs.org/dist/npm/&quot;&gt;こちら&lt;/a&gt;からダウンロードして、展開してから中身をnode.exeと同じフォルダにコピーします。（ダウンロードできる最新のnpmのバージョンは1.49でした、しかし実際には2.6以上のバージョンに上がっているのでインストール後「npm update」しておきましょう。問題なければ最新版にアップデートできます。）&lt;br /&gt;
&lt;br /&gt;
５．Win32アプリを動作させるのに必要な「User32.dll」をビルドします。予めVisualStudio Express　2013 for WindowsDesktop等を用意してください。&lt;a href=&quot;https://github.com/ms-iot/forwarders&quot;&gt;こちら&lt;/a&gt;からファイル一式をダウンロードして展開後ビルドしましょう。出来上がった「User32.dll」をnode.exeと同じフォルダにコピーします。&lt;br /&gt;
&lt;br /&gt;
６．telnetでGalileoにアクセスして、C:\nodeフォルダに移動します。次にコマンドライン上で&lt;br /&gt;
　　「mkdir %systemroot%\system32\config\systemprofile\AppData\Roaming\npm」&lt;br /&gt;
　　「setx path &quot;%path%;c:\node&quot; /M」&lt;br /&gt;
　　「shutdown /r /t 0」&lt;br /&gt;
&lt;br /&gt;
７．再起動後node.jsが使えるようになっています。&lt;br /&gt;
&lt;br /&gt;
８．「npm update」でnpmを最新版にしておきましょう。&lt;br /&gt;
&lt;br /&gt;
これ以降は通常のWindowsでnode.jsを使う場合と同じです。&lt;br /&gt;
expressをインストールして動作することも確認できました。&lt;br /&gt;
&lt;br /&gt;
Node.js Sampleページではインストール後にLチカの動作させていますね。（自分はまだ試していません）&lt;br /&gt;
&lt;br /&gt;
node.jsが動作するようになって色々サーバーを動かすことが可能になりますね。</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/6489959457284880332/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2015/02/galileo-gen2-windowsiot-nodejs.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/6489959457284880332'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/6489959457284880332'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2015/02/galileo-gen2-windowsiot-nodejs.html' title='Galileo Gen2 + WindowsIoT + node.js'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8EdTdqFtAEM-hTBRQYkpHznPVDJD_xBJKYZyNbCCA4ywc7-lW-Sr4v9YPA55PqIGvQyxg5O_kNkoyji9eDQPF01v32UiaNPelwvzuooS0G1CJkvAP43QXdTIRoPIj8oECFEYmgMonO50p/s72-c/watcher.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-4921748235437327012</id><published>2014-11-06T10:22:00.000+09:00</published><updated>2014-11-06T10:22:37.008+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Edison"/><category scheme="http://www.blogger.com/atom/ns#" term="ubilinux"/><category scheme="http://www.blogger.com/atom/ns#" term="VNC"/><category scheme="http://www.blogger.com/atom/ns#" term="デスクトップ"/><title type='text'>Edisonでデスクトップ表示（VNC接続）</title><content type='html'>先日、EdisonでDebian（ubilinux）が動いたとツイートしたら今までにないくらいリツイートされて驚きました。&lt;br /&gt;
&lt;br /&gt;
さて、EdisonはすでにLinuxボード化になっているのですが、やはりデスクトップ表示もしてみたいということでやってみました。もちろんEdisonにはモニター出力がありませんので、リモートデスクトップでやってみることにしました。&lt;br /&gt;
&lt;br /&gt;
こちらの&lt;a href=&quot;http://wiki.tokor.org/index.php?plugin=related&amp;amp;page=Intel%A4%CEGalileo%A4%CBVNC%C0%DC%C2%B3%A4%B9%A4%EB%A1%A1-%A1%A1Galileo&quot;&gt;IntelのGalileoにVNC接続する&lt;/a&gt;を参考にさせていただきました。&lt;br /&gt;
&lt;br /&gt;
構成としてはX Window環境＋Xvfb（仮想ディスプレイ）＋VNCサーバーです。&lt;br /&gt;
&lt;br /&gt;
X Window環境（デスクトップ）としてLXDEにしてみました。&lt;br /&gt;
&lt;br /&gt;
コマンドラインからデスクトップ環境を「apt-get install lxde」でインストールできます。&lt;br /&gt;
&lt;br /&gt;
続いて仮想ディスプレイ「Xvfb」も「apt-get install xvfb」でインストールします。&lt;br /&gt;
&lt;br /&gt;
VNCサーバーとしてx11vncを「apt-get install x11vnc」でインストールします。&lt;br /&gt;
&lt;br /&gt;
以上でインストールは完了しました。&lt;br /&gt;
&lt;br /&gt;
次に実行方法ですが、&lt;br /&gt;
&lt;br /&gt;
最初に仮想ディスプレイを立ち上げます。&lt;br /&gt;
コマンドラインで&lt;br /&gt;
「export DISPLAY=:1」&lt;br /&gt;
「Xvfb :1 -screen 0 1024x768x24 &amp;amp;」&lt;br /&gt;
&lt;br /&gt;
続いて、Windowマネージャーを起動します。LXDEにはOpenBoxが含まれているので&lt;br /&gt;
「openbox &amp;amp;」&lt;br /&gt;
&lt;br /&gt;
次にVNCサーバーを起動します。&lt;br /&gt;
「x11vnc -display :1 -bg -nopw -listen 0.0.0.0 -xkb」&lt;br /&gt;
&lt;br /&gt;
途中フォントがないとか色々表示されますがそのままでも大丈夫でした。&lt;br /&gt;
これでEdison上でデスクトップ環境が動くようになりました。&lt;br /&gt;
&lt;br /&gt;
あとはホストPCからVNCクライアントで接続すればデスクトップが表示されます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfL33dQ9m-lVBumtZ5qcLuHgzGDQ9FdV9Nns7-YtxRGb-QjMS-anpsZ5hmFyvMDD-u34M9R1vpreO7_5-aEiIQ0DNzxl1tIh5ohjmunTVfC5kJNiFkaxl0F-0SpgGwsA4bAZMfLYg5byBC/s1600/menu.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfL33dQ9m-lVBumtZ5qcLuHgzGDQ9FdV9Nns7-YtxRGb-QjMS-anpsZ5hmFyvMDD-u34M9R1vpreO7_5-aEiIQ0DNzxl1tIh5ohjmunTVfC5kJNiFkaxl0F-0SpgGwsA4bAZMfLYg5byBC/s1600/menu.PNG&quot; height=&quot;256&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
最初は真っ黒ですが、右クリックするとメニューが表示されます。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZAczQpeK_jGmGiKnQvfBjrCDQSjYsCq6mD27iukUGmnA8KEFARMsj51tXsIo_e4Ghd7ZfWOYzYjkxkRQTVoSuMJxeb5ZNtmgHj556n9XJcDjeACkwr_Tta4KDHY-fmf2nrhVDGe0g5Ebq/s1600/%E3%83%96%E3%83%A9%E3%82%A6%E3%82%B6%E3%83%BC.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZAczQpeK_jGmGiKnQvfBjrCDQSjYsCq6mD27iukUGmnA8KEFARMsj51tXsIo_e4Ghd7ZfWOYzYjkxkRQTVoSuMJxeb5ZNtmgHj556n9XJcDjeACkwr_Tta4KDHY-fmf2nrhVDGe0g5Ebq/s1600/%E3%83%96%E3%83%A9%E3%82%A6%E3%82%B6%E3%83%BC.PNG&quot; height=&quot;256&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
ブラウザーを立ち上げてみました。&lt;br /&gt;
&lt;br /&gt;
とりあえずEdisonでデスクトップ環境が使えることを確認できました。&lt;br /&gt;自動起動などの設定はあまり詳しくないので試していません。&lt;br /&gt;
&lt;br /&gt;
標準のYocto Linuxでも同じ手順（LXDEが動くかどうかはわかりませんが）でできると思います。（もう一度Yocto Linuxに戻してもいいのですが、eMMCの書き換え寿命が気になるのであまりやりたくないのです。Edisonモジュールだけ追加で購入しようかな）&lt;br /&gt;
&lt;br /&gt;
次はWebカメラを接続してブラウザに表示できるか試してみたいと思います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/4921748235437327012/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edisonvnc.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4921748235437327012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4921748235437327012'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edisonvnc.html' title='Edisonでデスクトップ表示（VNC接続）'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfL33dQ9m-lVBumtZ5qcLuHgzGDQ9FdV9Nns7-YtxRGb-QjMS-anpsZ5hmFyvMDD-u34M9R1vpreO7_5-aEiIQ0DNzxl1tIh5ohjmunTVfC5kJNiFkaxl0F-0SpgGwsA4bAZMfLYg5byBC/s72-c/menu.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-3191521909569351371</id><published>2014-11-02T23:12:00.002+09:00</published><updated>2014-11-05T05:46:16.154+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Debian"/><category scheme="http://www.blogger.com/atom/ns#" term="Edison"/><title type='text'>Debian(ubilinux) on Edison</title><content type='html'>Edisonの公式LinuxイメージはYocto　Linuxになります。ベースは&amp;nbsp;Ångstrom Linuxでしょうか。&lt;br /&gt;
公式イメージでは比較的コンパクトな構成になっているので、意外と使いにくい（エディタはViとか、パッケージ管理システムはopkgとか）と思います。&lt;br /&gt;
&lt;br /&gt;
既にDebian（Wheezy）ベースのイメージが公開されています。&lt;br /&gt;
&lt;br /&gt;
実際にインストールしてみました。&lt;br /&gt;
環境はWindowsからのインストールです。&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
準備&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
&lt;a href=&quot;http://www.emutexlabs.com/ubilinux&quot; target=&quot;_blank&quot;&gt;ubilinux&lt;/a&gt;のサイトからイメージファイルをダウンロードします。&lt;br /&gt;
（Galileo用もあるみたいです。後日試してみようかと思います。）&lt;br /&gt;
ダウンロードしたファイルはgz形式なので7zip等で展開しましょう。&lt;br /&gt;
次にファームウェア更新用のプログラム（dfu-util.exe）をダウンロードします。&lt;br /&gt;
ダウンロードしたファイルをイメージファイルを展開したフォルダへ移動しておきます。&lt;br /&gt;
&lt;br /&gt;
こちらの&lt;a href=&quot;https://community.spark.io/t/latest-2014-dfu-util-for-windows-compiled/5264&quot; target=&quot;_blank&quot;&gt;サイト&lt;/a&gt;からダウンロードしてください。&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
更新の実行&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
EdisonをUSBケーブルでPCに接続しておきます。（途中経過を見るのに２本とも接続してもいいでしょう）&lt;br /&gt;
&lt;br /&gt;
コマンドプロンプトを管理者権限で起動します。&lt;br /&gt;
&lt;br /&gt;
イメージファイルを展開したフォルダへ移動します。&lt;br /&gt;
&lt;br /&gt;
「flashall.bat」を実行します。&lt;br /&gt;
&lt;br /&gt;
リブートするように指示が表示されるので、一旦Edisonの電源を切ってからもう一度入れなおします。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ZGbj1M7YWZu9omlzTL-tGee-9oe8dFHhsm1vjXWAOZ7LqKyAn9_YNAOnLuzzaxpyHH9kLk9_h3uRozfrbt5lmYtO04umbUpPSC4EQSnYL-eZLwEOknHnil0jbN8qRZOi5GMDjJFvBHia/s1600/cmd.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ZGbj1M7YWZu9omlzTL-tGee-9oe8dFHhsm1vjXWAOZ7LqKyAn9_YNAOnLuzzaxpyHH9kLk9_h3uRozfrbt5lmYtO04umbUpPSC4EQSnYL-eZLwEOknHnil0jbN8qRZOi5GMDjJFvBHia/s1600/cmd.PNG&quot; height=&quot;233&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
しばらくするとフラッシュメモリの書き換えが始まります。このときシリアルコンソールを開いておくと作業の経過を見ることができます。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyEIecvB8UychBvFaS_TFhDGmvSYigYWa8o5kDNwCkH4Oz7yKI6n4yZu_yyU6j7qe_f76CAm5LFC7BS4IPuZio8OonznMjLgr8OBv-ZcwsJbkS02kyY4KWh6zOWEsrp1wtLpurh3rG2fgk/s1600/cmd2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyEIecvB8UychBvFaS_TFhDGmvSYigYWa8o5kDNwCkH4Oz7yKI6n4yZu_yyU6j7qe_f76CAm5LFC7BS4IPuZio8OonznMjLgr8OBv-ZcwsJbkS02kyY4KWh6zOWEsrp1wtLpurh3rG2fgk/s1600/cmd2.PNG&quot; height=&quot;232&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
書き換えが終わるとしばらくして自動的にリブートします。&lt;br /&gt;
&lt;br /&gt;
起動するとログインプロンプトが表示されるので、ユーザー「root」、パスワード「edison」でログインします。&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
ネットワークの設定&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
イメージを書き込んだ直後はWifiの設定が完了していないので、Wifiで接続できるようにします。&lt;br /&gt;
&lt;br /&gt;
「/etc/network/interfaces」ファイルを以下のように編集します。&lt;br /&gt;
&lt;br /&gt;
10行目　「#auto wlan0」-&amp;gt;「auto wlan0」&lt;br /&gt;
13行目　「wpa-ssid Emutex」-&amp;gt;「wpa-ssid &lt;i&gt;&lt;b&gt;自分のアクセスポイントのSSID&lt;/b&gt;&lt;/i&gt;」&lt;br /&gt;
14行目　「wpa-psk passphrase」-&amp;gt;「wpa-psk &lt;i&gt;&lt;b&gt;自分のアクセスポイントの共有キー&lt;/b&gt;&lt;/i&gt;」&lt;br /&gt;
&lt;br /&gt;
保存してから念のためにリブートします。&lt;br /&gt;
&lt;br /&gt;
再起動時にDHCPサーバーが見つかればネットワークの設定は完了です。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
あとは apt-get update &amp;amp; apt-get upgrade を実行してシステムの更新や、rootパスワードの変更などをしておきましょう。&lt;br /&gt;
&lt;br /&gt;
ここまでくれば、あとはDebianが動くLinuxマシンと一緒です。サーバーにするもよし、GPIOも利用できるのでセンサーを付けてみるもよし（ただしArduinoIDEで動くかどうかは試していません。）&lt;br /&gt;
&lt;br /&gt;
純正Linuxと同じくpythonやNode.jsはインストール済みなのですぐにサーバーとして使うことはできそうです。&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
その他&lt;br /&gt;
-----------------------------------------------------------------------&lt;br /&gt;
現在わかっている問題点（？）として、標準LinuxではホストPC上にディスクがマウントされるのがドライバーが読み込めなくてマウントされなくなります。今のところ特に不都合はなさそうなのですが・・・・&lt;br /&gt;
&lt;br /&gt;
もし、標準Linuxに戻したい場合には公式サイトから最新の「Edison Yocto complete image」をダウンロードして展開しておきます。展開したフォルダに「dfu-util.exe」をコピーしてから管理者コマンドプロンプトで「flashall.bat」を実行すれば元に戻すことができます。手順は一緒になります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
以上　EdisonにDebianをインストールする手順でした。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/3191521909569351371/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edison-on-debian.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/3191521909569351371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/3191521909569351371'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edison-on-debian.html' title='Debian(ubilinux) on Edison'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5ZGbj1M7YWZu9omlzTL-tGee-9oe8dFHhsm1vjXWAOZ7LqKyAn9_YNAOnLuzzaxpyHH9kLk9_h3uRozfrbt5lmYtO04umbUpPSC4EQSnYL-eZLwEOknHnil0jbN8qRZOi5GMDjJFvBHia/s72-c/cmd.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-911941858219595312</id><published>2014-11-02T18:23:00.000+09:00</published><updated>2014-11-03T10:58:49.656+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Edison"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel"/><title type='text'>Edisonの初期設定メモ</title><content type='html'>Edisonの初期設定については、すでにいろいろなサイトで説明されています。&lt;br /&gt;
参考にさせていただいたサイトのリストです。　基本的にWindowsでのセットアップです。&lt;br /&gt;
&lt;br /&gt;
・&lt;a href=&quot;http://nonnoise.github.io/Edison/index.html&quot; target=&quot;_blank&quot;&gt;Edison開発方法&lt;/a&gt;　&lt;br /&gt;
　　初期設定の方法やBrakeoutボードのピンアサイン表など参考になります。&lt;br /&gt;
&lt;br /&gt;
・&lt;a href=&quot;https://communities.intel.com/docs/DOC-23242&quot; target=&quot;_blank&quot;&gt;Edison - Software Downloads&lt;/a&gt;　&lt;br /&gt;
　　Intel Edisonの公式ダウンロードページです。&lt;br /&gt;
　　初期設定に必要なソフトウェアはここからダウンロードしましょう。&lt;br /&gt;
&lt;br /&gt;
・&lt;a href=&quot;http://kei-sakaki.jp/2014/10/26/intel-edison-firmware-update-wired/&quot; target=&quot;_blank&quot;&gt;KEI SAKAKI&#39;s PAGE.&lt;/a&gt;&lt;br /&gt;
　　ファームウェアの更新について説明が掲載されています。&lt;br /&gt;
&lt;br /&gt;
・&lt;a href=&quot;http://trac.switch-science.com/wiki/IntelEdison&quot; target=&quot;_blank&quot;&gt;switch-science　Edison wiki&lt;/a&gt;&lt;br /&gt;
　　スイッチサイエンスさんのEdisonWikiページです。ここでEdison購入しました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
あとはターミナルソフトとマイクロUSBケーブルを２本用意すれば初期設定は問題なくできると思います。&lt;br /&gt;
&lt;br /&gt;
メモ：&lt;br /&gt;
個人的にちょっとはまったのがここ・・・&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5lv6Fg5vTnO1Q4snAdAlcEop51Ztfh5bbeCUvwzVkeisqS5y1-VJmFZyYgVPOjwS1rNNdNlhXiXJvZxakuoi8KSIZeWONcLhRGu66Jywz4v9K-7kIbpCNYQwCrP96cqO_chi8C6VsmQQP/s1600/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5lv6Fg5vTnO1Q4snAdAlcEop51Ztfh5bbeCUvwzVkeisqS5y1-VJmFZyYgVPOjwS1rNNdNlhXiXJvZxakuoi8KSIZeWONcLhRGu66Jywz4v9K-7kIbpCNYQwCrP96cqO_chi8C6VsmQQP/s1600/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.PNG&quot; height=&quot;231&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
COMポートが２つ出ていますが、シリアル接続は「USB Serial Port」を選択します。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
はじめ「Intel Edison Virtual Com Port」で接続しようとして何も表示されずに焦りました。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/911941858219595312/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edison.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/911941858219595312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/911941858219595312'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/edison.html' title='Edisonの初期設定メモ'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5lv6Fg5vTnO1Q4snAdAlcEop51Ztfh5bbeCUvwzVkeisqS5y1-VJmFZyYgVPOjwS1rNNdNlhXiXJvZxakuoi8KSIZeWONcLhRGu66Jywz4v9K-7kIbpCNYQwCrP96cqO_chi8C6VsmQQP/s72-c/%E3%82%AD%E3%83%A3%E3%83%97%E3%83%81%E3%83%A3.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-5244755438903688361</id><published>2014-11-02T17:31:00.000+09:00</published><updated>2014-11-02T17:31:46.327+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Edison"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel"/><category scheme="http://www.blogger.com/atom/ns#" term="IoT"/><title type='text'>Intel Edison </title><content type='html'>Galileoに続いてEdisonを購入しました。&lt;br /&gt;
&lt;br /&gt;
購入したのは「Intel Edison Breakout Board Kit」です。&lt;br /&gt;
これはEdisonメインモジュール+拡張ボードの組み合わせです。&lt;br /&gt;
これ以外に「Intel Edison Kit for Arduino」もありますが、Galileoと大体同じようなものですね。&lt;br /&gt;
&lt;br /&gt;
実際開発環境もArduinoIDEなどはGalileoと共通のようですが、BreakoutBoardの場合はGPIOなどはピンソケットなどをボード上にはんだ付け等行わないと使えません。&lt;br /&gt;
&lt;br /&gt;
なのでLinuxサーバ的な使い方を色々試したいと思います。（そのうちGPIOなども使ってみるかもしれませんが）&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvfXJRWUtv-snOokjT_N6O0BhFaZQ48BoV1VFA2epkk1WY8BW3tAC6svlbQ_jkGgVuhsrUKHablrpQgMxaq2fPxCB8ycHvPZz2J61jw20hU3fpHkBfZU5TiYKiY8xiiRSUxJGcyqIu5ldD/s1600/IMGP4958.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvfXJRWUtv-snOokjT_N6O0BhFaZQ48BoV1VFA2epkk1WY8BW3tAC6svlbQ_jkGgVuhsrUKHablrpQgMxaq2fPxCB8ycHvPZz2J61jw20hU3fpHkBfZU5TiYKiY8xiiRSUxJGcyqIu5ldD/s1600/IMGP4958.jpg&quot; height=&quot;213&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
箱の大きさはGalileoと比べて随分と小さいです。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKIUut4gni706-o_1LnTEnJt5IbFZdyFjApF_KgYjyGXh8n56KWgAIOFjuAfvNiC1mODUUqZjUJEsP-Aay6l2RK0q8FGB2JkDQzz4QQpWzlOVAaNN70BJ9fy4tCfODGNFQdW6jh5hDJBA4/s1600/IMGP4959.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKIUut4gni706-o_1LnTEnJt5IbFZdyFjApF_KgYjyGXh8n56KWgAIOFjuAfvNiC1mODUUqZjUJEsP-Aay6l2RK0q8FGB2JkDQzz4QQpWzlOVAaNN70BJ9fy4tCfODGNFQdW6jh5hDJBA4/s1600/IMGP4959.jpg&quot; height=&quot;213&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
GalileoGen2と並べてみました。左側がメインモジュール、右側がBreakoutボードです。</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/5244755438903688361/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/intel-edison.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5244755438903688361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5244755438903688361'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/11/intel-edison.html' title='Intel Edison '/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvfXJRWUtv-snOokjT_N6O0BhFaZQ48BoV1VFA2epkk1WY8BW3tAC6svlbQ_jkGgVuhsrUKHablrpQgMxaq2fPxCB8ycHvPZz2J61jw20hU3fpHkBfZU5TiYKiY8xiiRSUxJGcyqIu5ldD/s72-c/IMGP4958.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-8736986070951046860</id><published>2014-08-22T07:16:00.000+09:00</published><updated>2014-08-22T07:16:22.851+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Galileo"/><category scheme="http://www.blogger.com/atom/ns#" term="Intel"/><category scheme="http://www.blogger.com/atom/ns#" term="IoT"/><category scheme="http://www.blogger.com/atom/ns#" term="Windows"/><title type='text'>Intel Galileo Gen2 on Windows</title><content type='html'>今日はKINECTからちょっと離れてCPUボードの話題です。&lt;br /&gt;
&lt;br /&gt;
ここ数年で1万円くらいまでで手に入るCPUボードは飛躍的に増えてきました。まぁ、増えたのはARM搭載のボードがほとんどのような気もしますけど。&lt;br /&gt;
&lt;br /&gt;
実際今手元にあるのはRasberryPi,mbedボード,Arduinoなどなど。&lt;br /&gt;
&lt;br /&gt;
そして今回はIntel Galileo Gen2を購入してみました。&lt;br /&gt;
&lt;br /&gt;
大きな違いはCPUがx86 Pentium互換ということです。（詳しい仕様は&lt;a href=&quot;http://ark.intel.com/ja/products/83137/Intel-Galileo-Gen-2-Board&quot; target=&quot;_blank&quot;&gt;こちら&lt;/a&gt;）&lt;br /&gt;
標準ではLinux+Arduinoが動作（この場合Linux上でArduinoをエミュレートしている？）します。&lt;br /&gt;
&lt;br /&gt;
で、x86CPUでメモリもそこそこ搭載（DDR3-256MB)ならWindowsも動くかもと考えたどうかは知りませんが、MicrosoftではGalileo用Windowsの提供を開始しました。（ただし、現在はまだβ？正式版ではありません）&lt;br /&gt;
&lt;br /&gt;
Galileo用Windowsを手に入れるには&lt;a href=&quot;http://dev.windows.com/en-us/featured/Windows-Developer-Program-for-IoT&quot; target=&quot;_blank&quot;&gt;このサイト&lt;/a&gt;にレジストすると手に入れることができます。&lt;br /&gt;
&lt;br /&gt;
実際のインストールは&lt;a href=&quot;http://www.syuheiuda.com/?p=3175&quot; target=&quot;_blank&quot;&gt;こちらのサイト&lt;/a&gt;を参考にさせていただきました。&lt;br /&gt;
&lt;br /&gt;
特に問題もなく無事インストールできました。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYnnN7brskhAwMMuCGbYmGUfWd8q4QcU21P_-5KnNNZM7P310qoZIzvL6_wHHrkiUJZ8_NHMKVyXNi1zmlWDDcomU7F-h492lX7Ch8gLdW7_usIJwkHuHoyUGbAtqMEzJDcR3dorfelGvv/s1600/telnet.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYnnN7brskhAwMMuCGbYmGUfWd8q4QcU21P_-5KnNNZM7P310qoZIzvL6_wHHrkiUJZ8_NHMKVyXNi1zmlWDDcomU7F-h492lX7Ch8gLdW7_usIJwkHuHoyUGbAtqMEzJDcR3dorfelGvv/s1600/telnet.PNG&quot; height=&quot;234&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Galileo Watcherで右クリックしてコンテキストメニュー内の「Open Network Share」を選択するとGalileoのCドライブを開くことができます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIitBmtIumqpZNZDdHb44cS6XEIJFMsjmhJcQJOZYLYJHxxP8WBBbj_1ThtzxvRKfxv6pFtcs_p4RgoIgDEGVB2CFywhdyC0pEDiKk6jJrNn8btt-hAIg58_-9f-TL5yHFP3aW1XsvuO08/s1600/watcher.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIitBmtIumqpZNZDdHb44cS6XEIJFMsjmhJcQJOZYLYJHxxP8WBBbj_1ThtzxvRKfxv6pFtcs_p4RgoIgDEGVB2CFywhdyC0pEDiKk6jJrNn8btt-hAIg58_-9f-TL5yHFP3aW1XsvuO08/s1600/watcher.PNG&quot; height=&quot;192&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNBq1EMFUVF5ww0uCfrkPOwHm-GEecfipbaTj_3oHIp1IQaWX1dNjvfGuOklrufqCipwP0D3we156vf3YBzt4FL4nOlizISEOfxiJILq0YonMdMBlTlwBtx2dmR5U6SQk5GyatcPxY1vtF/s1600/share.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNBq1EMFUVF5ww0uCfrkPOwHm-GEecfipbaTj_3oHIp1IQaWX1dNjvfGuOklrufqCipwP0D3we156vf3YBzt4FL4nOlizISEOfxiJILq0YonMdMBlTlwBtx2dmR5U6SQk5GyatcPxY1vtF/s1600/share.PNG&quot; height=&quot;240&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
もちろんPCからファイルの作成やコピーなども可能です。&lt;br /&gt;
たぶんEXE単体のコマンドラインプログラムなら普通に動きそうです。&lt;br /&gt;
&lt;br /&gt;
System32フォルダ内をざっと見た感じでは基本的なコマンドラインプログラムは一通りありました。&lt;br /&gt;
&lt;br /&gt;
まだ開発版なので空っぽのフォルダなんかもありますが、これから色々できそうな感じです。&lt;br /&gt;
USBデバイスとかつながるのかな？Webカメラでもつないでみようかと思います。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/8736986070951046860/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/08/intel-galileo-gen2-on-windows.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/8736986070951046860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/8736986070951046860'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/08/intel-galileo-gen2-on-windows.html' title='Intel Galileo Gen2 on Windows'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYnnN7brskhAwMMuCGbYmGUfWd8q4QcU21P_-5KnNNZM7P310qoZIzvL6_wHHrkiUJZ8_NHMKVyXNi1zmlWDDcomU7F-h492lX7Ch8gLdW7_usIJwkHuHoyUGbAtqMEzJDcR3dorfelGvv/s72-c/telnet.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-1454713994874942854</id><published>2014-07-23T06:56:00.002+09:00</published><updated>2014-07-23T07:05:11.221+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="KINECT"/><category scheme="http://www.blogger.com/atom/ns#" term="SpeechPlatform"/><category scheme="http://www.blogger.com/atom/ns#" term="V2"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="音声認識"/><title type='text'>KINECT V2 　音声シャッター（SDK2.0β,C#）</title><content type='html'>FaceBookのグループでスナップショットを撮るときクリックするのが大変という話があったので、音声認識でスナップショットをとれるようにしてみました。&lt;br /&gt;
SDK2.0βのColorBasics-WPFサンプルに音声認識部分を追加しています。&lt;br /&gt;
&lt;br /&gt;
今回もKinectAudioStream.csをプロジェクトに追加しています。&lt;br /&gt;
&lt;br /&gt;
変更はnamespaceとMainWindow.xaml.csだけです。&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml.cs&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;//------------------------------------------------------------------------------
// &amp;lt;copyright file=&quot;MainWindow.xaml.cs&quot; company=&quot;Microsoft&quot;&amp;gt;
// &amp;nbsp; &amp;nbsp; Copyright (c) Microsoft Corporation. &amp;nbsp;All rights reserved.
// &amp;lt;/copyright&amp;gt;
//------------------------------------------------------------------------------
namespace Microsoft.Samples.Kinect.ColorBasics.speech
{
&amp;nbsp; &amp;nbsp; using System;
&amp;nbsp; &amp;nbsp; using System.Collections.Generic;
&amp;nbsp; &amp;nbsp; using System.ComponentModel;
&amp;nbsp; &amp;nbsp; using System.Diagnostics;
&amp;nbsp; &amp;nbsp; using System.Globalization;
&amp;nbsp; &amp;nbsp; using System.IO;
&amp;nbsp; &amp;nbsp; using System.Windows;
&amp;nbsp; &amp;nbsp; using System.Windows.Media;
&amp;nbsp; &amp;nbsp; using System.Windows.Media.Imaging;
&amp;nbsp; &amp;nbsp; using Microsoft.Kinect;
&amp;nbsp; &amp;nbsp; using Microsoft.Speech.AudioFormat;
&amp;nbsp; &amp;nbsp; using Microsoft.Speech.Recognition;

&amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; /// Interaction logic for MainWindow
&amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; public partial class MainWindow : Window, INotifyPropertyChanged
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Size of the RGB pixel in the bitmap
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private readonly uint bytesPerPixel = 0;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Active Kinect sensor
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private KinectSensor kinectSensor = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Reader for color frames
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private ColorFrameReader colorFrameReader = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Bitmap to display
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private WriteableBitmap colorBitmap = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Intermediate storage for receiving frame data from the sensor
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private byte[] colorPixels = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Current status text to display
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private string statusText = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// 音声ストリーム
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KinectAudioStream convertStream = null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// 音声認識エンジン
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SpeechRecognitionEngine engine=null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// 日本語音声認識エンジンのID
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const string engin_id = &quot;SR_MS_ja-JP_Kinect_11.0&quot;;


&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Initializes a new instance of the MainWindow class.
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public MainWindow()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // get the kinectSensor object
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.kinectSensor = KinectSensor.GetDefault();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // open the reader for the color frames
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorFrameReader = this.kinectSensor.ColorFrameSource.OpenReader();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // wire handler for frame arrival
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create the colorFrameDescription from the ColorFrameSource using Bgra format
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // rgba is 4 bytes per pixel
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.bytesPerPixel = colorFrameDescription.BytesPerPixel;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // allocate space to put the pixels to be rendered
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorPixels = new byte[colorFrameDescription.Width * colorFrameDescription.Height * this.bytesPerPixel];

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create the bitmap to display
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set IsAvailableChanged event notifier
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // open the sensor
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.kinectSensor.Open();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set the status text
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : Properties.Resources.NoSensorStatusText;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // use the window object as the view model in this simple example
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.DataContext = this;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initialize the components (controls) of the window
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.InitializeComponent();


&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ////////////////////////////////////////////////////////////
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声認識関連
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ////////////////////////////////////////////////////////////

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声入力設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IReadOnlyList&amp;lt;AudioBeam&amp;gt; audioBeamList = kinectSensor.AudioSource.AudioBeams;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Stream audioStream = audioBeamList[0].OpenInputStream();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //audioStreamのビット変換
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; convertStream = new KinectAudioStream(audioStream);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声認識エンジン設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine = new SpeechRecognitionEngine(engin_id);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識するワード
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var word = new Choices();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;チーズ&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;キャプチャ&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;シャッター&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマービルダー
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var gb = new GrammarBuilder();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //言語設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gb.Culture = engine.RecognizerInfo.Culture;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマービルダーに単語を登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gb.Append(word);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマー作成
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var g = new Grammar(gb);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンにグラマーを登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.LoadGrammar(g);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //イベントの登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SpeechRecognized += engine_SpeechRecognized;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SpeechRecognitionRejected += engine_SpeechRecognitionRejected;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //オーディオストリームの変換をアクティブにする
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; convertStream.SpeechActive = true;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンに入力設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SetInputToAudioStream(convertStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //非同期で連続認識の開始
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.RecognizeAsync(RecognizeMode.Multiple);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void engine_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new NotImplementedException();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void engine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識信頼度の閾値
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //（認識信頼度　-1&amp;lt;0&amp;lt;1 -1が低信頼度　0が標準　1が高信頼度　数字が大きいほど認識率が厳しくなる）
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const double ConfidenceThreshold = 0.6;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (e.Result.Confidence &amp;gt;= ConfidenceThreshold)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識した単語を表示
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.colorBitmap != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create a png bitmap encoder which knows how to save a .png file
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BitmapEncoder encoder = new PngBitmapEncoder();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create frame from the writable bitmap and add to encoder
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder.Frames.Add(BitmapFrame.Create(this.colorBitmap));

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string time = System.DateTime.Now.ToString(&quot;hh&#39;-&#39;mm&#39;-&#39;ss&quot;, CultureInfo.CurrentUICulture.DateTimeFormat);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string path = Path.Combine(myPhotos, &quot;KinectScreenshot-Color-&quot; + time + &quot;.png&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // write the new file to disk
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // FileStream is IDisposable
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (FileStream fs = new FileStream(path, FileMode.Create))
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder.Save(fs);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (IOException)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// INotifyPropertyChangedPropertyChanged event to allow window controls to bind to changeable data
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public event PropertyChangedEventHandler PropertyChanged;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Gets the bitmap to display
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public ImageSource ImageSource
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this.colorBitmap;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Gets or sets the current status text to display
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public string StatusText
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; get
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this.statusText;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.statusText != value)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.statusText = value;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // notify any bound elements that the text has changed
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.PropertyChanged != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.PropertyChanged(this, new PropertyChangedEventArgs(&quot;StatusText&quot;));
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Execute shutdown tasks
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;object sending the event&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;event arguments&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void MainWindow_Closing(object sender, CancelEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.colorFrameReader != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ColorFrameReder is IDisposable
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorFrameReader.Dispose();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorFrameReader = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.kinectSensor != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.kinectSensor.Close();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.kinectSensor = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Handles the user clicking on the screenshot button
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;object sending the event&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;event arguments&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void ScreenshotButton_Click(object sender, RoutedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.colorBitmap != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create a png bitmap encoder which knows how to save a .png file
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BitmapEncoder encoder = new PngBitmapEncoder();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // create frame from the writable bitmap and add to encoder
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder.Frames.Add(BitmapFrame.Create(this.colorBitmap));

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string time = System.DateTime.Now.ToString(&quot;hh&#39;-&#39;mm&#39;-&#39;ss&quot;, CultureInfo.CurrentUICulture.DateTimeFormat);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; string path = Path.Combine(myPhotos, &quot;KinectScreenshot-Color-&quot; + time + &quot;.png&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // write the new file to disk
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // FileStream is IDisposable
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (FileStream fs = new FileStream(path, FileMode.Create))
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; encoder.Save(fs);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (IOException)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Handles the color frame data arriving from the sensor
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;object sending the event&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;event arguments&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Reader_ColorFrameArrived(object sender, ColorFrameArrivedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bool colorFrameProcessed = false;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // ColorFrame is IDisposable
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (ColorFrame colorFrame = e.FrameReference.AcquireFrame())
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrame != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FrameDescription colorFrameDescription = colorFrame.FrameDescription;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // verify data and write the new color frame data to the display bitmap
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ((colorFrameDescription.Width == this.colorBitmap.PixelWidth) &amp;amp;&amp;amp; (colorFrameDescription.Height == this.colorBitmap.PixelHeight))
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrame.RawColorImageFormat == ColorImageFormat.Bgra)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorFrame.CopyRawFrameDataToArray(this.colorPixels);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorFrame.CopyConvertedFrameDataToArray(this.colorPixels, ColorImageFormat.Bgra);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorFrameProcessed = true;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // we got a frame, render
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrameProcessed)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.RenderColorPixels();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Renders color pixels into the writeableBitmap.
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void RenderColorPixels()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorBitmap.WritePixels(
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorPixels,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.colorBitmap.PixelWidth * (int)this.bytesPerPixel,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// Handles the event which the sensor becomes unavailable (E.g. paused, closed, unplugged).
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;object sending the event&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;event arguments&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Sensor_IsAvailableChanged(object sender, IsAvailableChangedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // on failure, set the status text
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; : Properties.Resources.SensorNotAvailableStatusText;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
}
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
説明：&lt;br /&gt;
　前回の音声認識サンプルとほぼ同じです。スナップショットを撮るルーチンもClickイベント部分と同じです。&lt;br /&gt;
　慣れてくれば簡単にイベント部分を音声認識イベントに変更できそうです。&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/1454713994874942854/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/07/blog-post.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/1454713994874942854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/1454713994874942854'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/07/blog-post.html' title='KINECT V2 　音声シャッター（SDK2.0β,C#）'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-1119947102761709675</id><published>2014-07-20T01:18:00.003+09:00</published><updated>2014-07-20T02:00:14.468+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="KINECT"/><category scheme="http://www.blogger.com/atom/ns#" term="SpeechPlatform"/><category scheme="http://www.blogger.com/atom/ns#" term="V2"/><category scheme="http://www.blogger.com/atom/ns#" term="音声認識"/><title type='text'>KINECT V2で音声認識（SDK2.0β　C#）</title><content type='html'>7月15日からKINECT for Windows V2が発売されました。SDK2.0もパブリックベータ版が同時に公開されています。&lt;br /&gt;
&lt;br /&gt;
今回はハードが大幅に変更になっているのでSDKも色々変わっています。&lt;br /&gt;
&lt;br /&gt;
ColorやDepthの解説はぼちぼちブログやIT系メディアで紹介されていますが、音声認識関連はなかなか出てこないです。&lt;br /&gt;
&lt;br /&gt;
取り急ぎSDKのSpeechサンプルを参考にして簡単なプログラムを作ってみました。&lt;br /&gt;
&lt;br /&gt;
開発環境は&lt;br /&gt;
&lt;br /&gt;
Windows8.1Pro 64bit&lt;br /&gt;
Visual Studio Pro 2012&lt;br /&gt;
&lt;br /&gt;
です。&lt;br /&gt;
&lt;br /&gt;
その他 KINECT　SDK2.0　及び　SpeechPlatform SDK 11.0,LanguagePack_jaJPもインストールしてください。&lt;br /&gt;
&lt;br /&gt;
サンプルプログラムはC#+WPFで作成しています。&lt;br /&gt;
&lt;br /&gt;
最初にプロジェクトを新しく作成してから、SDK2.0βのSpeech Basicｓ-WPFプロジェクトよりKinectAudioStream.csファイルをインポートして、namespaceを変更してください。&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
MainWindow.xaml&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;Window x:Class=&quot;speech_jp.MainWindow&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot; Loaded=&quot;Window_Loaded&quot; Closing=&quot;Window_Closing&quot;&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Grid&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox x:Name=&quot;tb1&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;30&quot; Margin=&quot;10,82,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;497&quot; FontSize=&quot;20&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox x:Name=&quot;tb2&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;30&quot; Margin=&quot;10,153,0,0&quot; TextWrapping=&quot;Wrap&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;497&quot; FontSize=&quot;20&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;認識した単語&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,52,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;107&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;信頼度&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,123,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;74&quot;/&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
説明：&lt;br /&gt;
　テキストボックスを２つ配置しています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml.cs&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using Microsoft.Kinect;
using Microsoft.Speech.AudioFormat;
using Microsoft.Speech.Recognition;

namespace speech_jp
{
&amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; /// MainWindow.xaml の相互作用ロジック
&amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; public partial class MainWindow : Window
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECT
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KinectSensor kinect=null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //AudioStream
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; KinectAudioStream convertStream=null;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声認識エンジン
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SpeechRecognitionEngine engine;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //日本語音声認識エンジンのID
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const string engin_id = &quot;SR_MS_ja-JP_Kinect_11.0&quot;;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //英語音声認識エンジンのID
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //const string engin_id = &quot;SR_MS_en-US_Kinect_11.0&quot;;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public MainWindow()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Window_Loaded(object sender, RoutedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTの準備
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect = KinectSensor.GetDefault();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (kinect == null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw new Exception(&quot;KINECTを開けません。&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTの使用開始
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Open();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声入力設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IReadOnlyList&amp;lt;AudioBeam&amp;gt; audioBeamList = kinect.AudioSource.AudioBeams;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Stream audioStream = audioBeamList[0].OpenInputStream();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //audioStreamのビット変換
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; convertStream = new KinectAudioStream(audioStream);


&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MessageBox.Show(ex.Message);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Close();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声認識エンジン設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine = new SpeechRecognitionEngine(engin_id);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識するワード
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var word = new Choices();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;ハンバーグ&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;ラーメン&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;焼肉&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;すし&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;スパゲッティ&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;卵焼き&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;ぎゅう丼&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;うどん&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; word.Add(&quot;からあげ&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマービルダー
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var gb = new GrammarBuilder();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //言語設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gb.Culture = engine.RecognizerInfo.Culture;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマービルダーに単語を登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gb.Append(word);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グラマー作成
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var g = new Grammar(gb);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンにグラマーを登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.LoadGrammar(g);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //イベントの登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SpeechRecognized += engine_SpeechRecognized;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SpeechRecognitionRejected += engine_SpeechRecognitionRejected;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //オーディオストリームの変換をアクティブにする
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; convertStream.SpeechActive = true;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンに入力設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.SetInputToAudioStream(convertStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //非同期で連続認識の開始
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; engine.RecognizeAsync(RecognizeMode.Multiple);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void engine_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb1.Text = &quot;認識できません。&quot;;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb2.Text = &quot;&quot;;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void engine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識信頼度の閾値
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //（認識信頼度　-1&amp;lt;0&amp;lt;1 -1が低信頼度　0が標準　1が高信頼度　数字が大きいほど認識率が厳しくなる）
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const double ConfidenceThreshold = 0.6;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (e.Result.Confidence &amp;gt;= ConfidenceThreshold)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識した単語を表示
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb1.Text = e.Result.Text;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tb2.Text = e.Result.Confidence.ToString();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //終了処理
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (kinect != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Close();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
}

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
説明：&lt;br /&gt;
　大きく変わったのはマイクで録音した時のオーディオフォーマットが変更になっているところです。V1の時はPCM 16bitだったのがV2ではPCM　32bit floatになっています。音声認識エンジンへの入力フォーマットはPCM 16bitの必要があるので32bitfloat-&amp;gt;16bitへの変換が必要になります。&lt;br /&gt;
　今回はSDKのサンプルプログラムから変換用クラスをそのままインポートして利用しています。&lt;br /&gt;
　また、音声ストリームの指定方法が少し変更になっていますね。AudioBeam配列から選択するように変わりました。&lt;br /&gt;
　音声認識部分についてはSpeechPlatformのバージョンは以前と変わっていないので特に変更はありません。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
入力音声を配列で取得できるということは複数人の音声を識別できそうです。&lt;br /&gt;
現在はまだそこまで調べていないので何とも言えないのですが。できるならイントロクイズとかに使えるかもしれないですね。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/1119947102761709675/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/07/kinect-v2sdk20c.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/1119947102761709675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/1119947102761709675'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/07/kinect-v2sdk20c.html' title='KINECT V2で音声認識（SDK2.0β　C#）'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-4312206506277304368</id><published>2014-04-24T12:56:00.000+09:00</published><updated>2014-04-24T12:56:44.130+09:00</updated><title type='text'>TechCrunchHackathon　Osakaに参加してきました。画像センシングコンポ（HVC）について</title><content type='html'>4月12-13日にかけて開催されたTechCrunchHackathon　Osakaに参加してきました。&lt;br /&gt;
その時に作成したプロダクトに使ったオムロン製　画像センシングコンポ(HVC)について使用した感想を述べたいと思います。&lt;br /&gt;
&lt;br /&gt;
まず、ボードについては&lt;a href=&quot;http://www.omron.co.jp/ecb/products/mobile/okao_hvc.html&quot; target=&quot;_blank&quot;&gt;ここ&lt;/a&gt;を参照してください。&lt;br /&gt;
オムロンの組み込み向けライブラリOKAO Visionをプロセッサに組み込んでカメラモジュールと合わせて搭載したボード（以下HVC）です。&lt;br /&gt;
カメラで取り込んだ映像を解析し、結果を出力します。このボードひとつで顔検出、人体検出、性別推定、年齢推定、視線推定、、目つむり推定、顔向き推定、表情推定、手（のひら）検出、顔認証の各データが取得できます。&lt;br /&gt;
&lt;br /&gt;
ボードとの入出力はUART3.3Vのシリアル通信になります。&lt;br /&gt;
評価ボードにはUSB変換基板も付属しているのでPCとの接続は簡単にできます。（変換基板からUSB経由で５V電源を供給しています。）&lt;br /&gt;
別で５V電源を供給できればマイコンボードとの接続も簡単かと思います。&lt;br /&gt;
&lt;br /&gt;
今回はチームメイトがMicroUSB変換ケーブルを持っていたので、Nexus7と接続を試してみましたが問題なく接続できました。USBHost機能を持ったAndroid端末も接続できるようです。&lt;br /&gt;
&lt;br /&gt;
さて、実際に使用するときにはプログラムからシリアル通信でコマンドコードを送ることになります。&lt;br /&gt;
コマンドコードと受信データはバイトデータなので、それらに対応した開発言語ならどれを使っても開発できます。&lt;br /&gt;
サンプルはWindowsデスクトップアプリでした。ハッカソン参加者で使っていた言語はC#、python、JAVA（Android）といったところでしょうか。&lt;br /&gt;
&lt;br /&gt;
センシングの性能としてはボードから1.5～2mくらいまでが解析できる距離（顔認識系）のようです。これはカメラモジュールの性能にもよる可能性があるので、モジュールを交換できるならもう少し距離が延びるかもしれません。&lt;br /&gt;
&lt;br /&gt;
一人分の顔認識にかかる時間は約1秒未満くらいでしょうか、瞬時とはいかないようです。&lt;br /&gt;
ボードからは認識時に使った画像データも取得できます。サンプルプログラムではリアルタイムで画像表示して解析データを出力できていたので、もう少し時間があれば色々試せたのかもしれません。&lt;br /&gt;
&lt;br /&gt;
今回使う機会がなかったのは顔認証機能でしたが、マニュアルをちらっと読んでみただけなのですが、認証用の画像データ（もしかすると特徴点データ?）はボード上のフラッシュメモリーに登録するようになっているようです。&lt;br /&gt;
&lt;br /&gt;
センシング機能をボード上ですべて行っているので非力な端末と接続しても、十分な処理速度を保てるのではないでしょうか。&lt;br /&gt;
&lt;br /&gt;
いくつか希望を述べるとすると&lt;br /&gt;
&lt;br /&gt;
１．10種類のアルゴリズムすべてではなくて、機能別バージョンがあってもいいかなと思います。&lt;br /&gt;
人体検出＋顔検出、顔検出＋顔認識（推定系）、全部ありバージョンなどなど・・・顔認証ありバージョンとなしバージョンでもいいかも。　用途として顔認証はなくてもいい場合も十分あると思います。&lt;br /&gt;
&lt;br /&gt;
２．ぜひ企業向けだけではなく個人向けにも販売してほしいです。今回は幸運にも評価ボードを貸していただけたのでよかったのですが、結構興味を持っている個人もいると思います。開発キット7万円はちょっと高いかな・・・・少しでも安くなればいいのですが。&lt;br /&gt;
&lt;br /&gt;
以上簡単ですが、HVCを使ってみた感想でした。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/4312206506277304368/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/04/techcrunchhackathonosakahvc.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4312206506277304368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4312206506277304368'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/04/techcrunchhackathonosakahvc.html' title='TechCrunchHackathon　Osakaに参加してきました。画像センシングコンポ（HVC）について'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-4097992689082847500</id><published>2014-04-16T13:00:00.002+09:00</published><updated>2014-04-16T13:15:16.336+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gracenote"/><category scheme="http://www.blogger.com/atom/ns#" term="HVC"/><category scheme="http://www.blogger.com/atom/ns#" term="TechCrunchHackathon"/><title type='text'>TechCrunchHackathon　Osakaに参加してきました。</title><content type='html'>先週末の土曜日から日曜日にかけて大阪のグランフロントにある大阪イノベーションハブで行われたTechCrunch Hackathon Osakaに参加してきました。&lt;br /&gt;
&lt;br /&gt;
ハードウェア系のハッカソンということで2日間で提供されるハードウェアやWebAPIを利用して、IoTになるプロダクトを作っていきます。&lt;br /&gt;
&lt;br /&gt;
今回結成したチーム（当初6人でしたが、1人途中で用事のため抜けたので最終的に5人）ではセンサーカメラ（オムロン　&lt;a href=&quot;http://www.omron.co.jp/ecb/products/mobile/okao_hvc.html&quot; target=&quot;_blank&quot;&gt;HVC&lt;/a&gt;）と音楽API（&lt;a href=&quot;https://developer.gracenote.com/?language=ja&quot; target=&quot;_blank&quot;&gt;Gracenote&lt;/a&gt;）で何かできないかなということで色々アイデアを考えていました。&lt;br /&gt;
&lt;br /&gt;
最終的には「独居老人を見守ることができるミュージックプレイヤー」を作るということになりました。&lt;br /&gt;
&lt;br /&gt;
全体の構成イメージは下図のようになります。&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUf1xJy7ea8KDyADrPey5e95D23gEMbXjys32sH-E1raLgpQxLIfokfYGk48AMGfxaaFr1oGwuQvdnlV7ZMfNd5oInzRUufegd_ii8bibRPOKAnuXz82WZSKVL80bc9oMoUrHeZEG_B_JR/s1600/mimamori.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUf1xJy7ea8KDyADrPey5e95D23gEMbXjys32sH-E1raLgpQxLIfokfYGk48AMGfxaaFr1oGwuQvdnlV7ZMfNd5oInzRUufegd_ii8bibRPOKAnuXz82WZSKVL80bc9oMoUrHeZEG_B_JR/s1600/mimamori.png&quot; height=&quot;112&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
動作内容としては&lt;br /&gt;
&lt;br /&gt;
１．HVCカメラで対象者を認識し、顔の表情や年齢のパラメーターをサーバーに送信。&lt;br /&gt;
２．サーバーで受信したパラメーターを元に年代、ムードなどのクエリを生成してGracenote APIからプレイリスト、ジャケット画像、音源URL等のデータを取得。&lt;br /&gt;
３．サーバー上でGracenoteAPIから取得したデータを基にプレイヤー用HTMLを生成して、プレイヤーへ送信。&lt;br /&gt;
４．プレイヤーは受信したHTMLを表示。&lt;br /&gt;
５．動作中は特定のトリガー（今回はあらかじめ決めていたモーション）で緊急事態を認識してモバイルサービスにアラートを送信。&lt;br /&gt;
６．モバイルサービスから緊急受信用のアプリへアラートを送信。&lt;br /&gt;
&lt;br /&gt;
このような構成になりました。&lt;br /&gt;
&lt;br /&gt;
HVCとAndroidタブレットの接続（UART）は当初PocketDuinoを使う必要があるかなと思っていたのですが、HVCに付属の変換基板でそのまま接続することができました。USBホスト機能のある機種はコネクターを合わせるとそのまま接続できます。&lt;br /&gt;
ただし、Androidの場合はそのままではシリアル通信ができないのでライブラリとしてPocketDuinoと一緒に公開されている&lt;a href=&quot;http://www.physicaloid.com/&quot; target=&quot;_blank&quot;&gt;Physicaloid Library&lt;/a&gt;を使っています。&lt;br /&gt;
HVCを使ったチームのうちAndroidと接続していたのは我々のチームだけのようでした。&lt;br /&gt;
&lt;br /&gt;
次にセンサーから得られた情報を如何にしてGracenoteAPIのクエリにするのかを検討しました。最終的には15種類（年代3種類、感情5種類）のパターンで検索しています。&lt;br /&gt;
&lt;br /&gt;
APIから得られたプレイリストを基にジャケット画像と音源URL（今回はyoutube）を検索してからプレイヤー向けのHTMLを生成してプレイヤーに返すようにしています。&lt;br /&gt;
&lt;br /&gt;
緊急時のアラートについてはプレイヤーが特定の条件を検知した場合にAzureモバイルサービスにアラートを送信してiPhoneアプリで通知を受け取り表示およびアラート音がなるようにしました。&lt;br /&gt;
&lt;br /&gt;
デモのときにアラートがならなかったのが残念です。（多分ネットワークが重く通知が届かなかったのが原因だと思います。）&lt;br /&gt;
&lt;br /&gt;
今回なんとか2日間で動作するプロダクトを作れたのもチームが偶然にも、それぞれ得意分野が違っていて上手くできたのだと思います。一部Android担当された方にタスクが集まってしまった感じではありましけれども。&lt;br /&gt;
&lt;br /&gt;
今回作ったプロダクトをこのままで終わるのはもったいないと思うので何らかの形で続けられたらと、チームメンバーとも話をしています。&lt;br /&gt;
&lt;br /&gt;
後ほど他のチームのプロダクトについても感想を書いてみたいと思います。</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/4097992689082847500/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/04/techcrunchhackathonosaka.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4097992689082847500'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4097992689082847500'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/04/techcrunchhackathonosaka.html' title='TechCrunchHackathon　Osakaに参加してきました。'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUf1xJy7ea8KDyADrPey5e95D23gEMbXjys32sH-E1raLgpQxLIfokfYGk48AMGfxaaFr1oGwuQvdnlV7ZMfNd5oInzRUufegd_ii8bibRPOKAnuXz82WZSKVL80bc9oMoUrHeZEG_B_JR/s72-c/mimamori.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-570410434753884996</id><published>2014-02-05T21:11:00.000+09:00</published><updated>2014-02-06T13:31:17.173+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SQLServer"/><title type='text'>SQLServerで地図データ（緯度経度）を検索</title><content type='html'>先日FaceBookでDB上の地図座標を検索したいという話題がでていたので、SQLServerでやり方を調べてみました。&lt;br /&gt;
実現したいのは「現在地の座標から500m（任意の範囲）内の登録地点を検索する」となります。&lt;br /&gt;
&lt;br /&gt;
SQLServer2008から空間データ用にgeometry型とgeography型がサポートされるようになりました。&lt;br /&gt;
geometry型は平面上の座標データ（一般的なxyグラフ）を扱います。&lt;br /&gt;
geography型は楕円体上の座標データを扱うので緯度経度データはこちらを利用することになると思います。&lt;br /&gt;
&lt;br /&gt;
まずはサンプルテーブルを作成します。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;CREATE TABLE T_TEST
(
&amp;nbsp;id int IDENTITY(1,1) NOT NULL,
&amp;nbsp;name nvarchar(50) ,
&amp;nbsp;address nvarchar(50) ,
&amp;nbsp;geo geography
)
&lt;/pre&gt;
&lt;br /&gt;
次にサンプルデータを挿入します。今回は弊社近辺の銀行の所在地にしてみました。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;INSERT INTO T_TEST(name,address,geo)
&amp;nbsp; &amp;nbsp; &amp;nbsp;VALUES(&#39;りそな銀行明石支店&#39;,
&#39;明石市本町1丁目2-26&#39;,
geography::STGeomFromText(&#39;POINT(134.991151 34.647505)&#39;,4326))
INSERT INTO T_TEST(name,address,geo)
&amp;nbsp; &amp;nbsp; &amp;nbsp;VALUES(&#39;みずほ銀行明石支店&#39;,
&#39;明石市大明石町1丁目5-1&#39;,
geography::STGeomFromText(&#39;POINT(134.993259 34.64798)&#39;,4326))
INSERT INTO T_TEST(name,address,geo)
&amp;nbsp; &amp;nbsp; &amp;nbsp;VALUES(&#39;三井住友銀行明石支店&#39;,
&#39;明石市大明石町1丁目5-4&#39;,
geography::STGeomFromText(&#39;POINT(134.993299 34.647755)&#39;,4326))
INSERT INTO T_TEST(name,address,geo)
&amp;nbsp; &amp;nbsp; &amp;nbsp;VALUES(&#39;東京三菱UFJ銀行明石支店&#39;,
&#39;明石市本町1丁目1-34&#39;,
geography::STGeomFromText(&#39;POINT(134.993251 34.647223)&#39;,4326))
INSERT INTO T_TEST(name,address,geo)
&amp;nbsp; &amp;nbsp; &amp;nbsp;VALUES(&#39;百十四銀行明石支店&#39;,
&#39;明石市本町2丁目1-26&#39;,
geography::STGeomFromText(&#39;POINT(134.989622 34.647607)&#39;,4326))
&lt;/pre&gt;
&lt;br /&gt;
geography型へのデータの挿入は「geography::STGeomFromText(&#39;POINT([経度] [緯度])&#39;,4326)」となります。（「経度」と「緯度」の間は半角スペースです。間違えるとエラーになります。）&lt;br /&gt;
&lt;br /&gt;
------------------------------------------&lt;br /&gt;
追記&lt;br /&gt;
------------------------------------------&lt;br /&gt;
geography型へのデータの挿入は「geography::POINT([緯度],[経度],SRID)」でも可能です。&lt;br /&gt;
こちらのほうが直接的でわかりやすいかと思います。&lt;br /&gt;
------------------------------------------&lt;br /&gt;
追記終わり&lt;br /&gt;
------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SQLServerでのgeography型データは.NET 共通言語ランタイム (CLR) のデータ型として実装されているのでgeography::STGeomFromTextメソッドで座標を変換しています。「4326」はSRID (spatial reference ID) になります。（詳しく調べていないのですが固定値として指定しています。）&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
これで検索する準備ができました。&lt;br /&gt;
&lt;br /&gt;
登録されているデータで任意の位置から特定範囲（この場合は円内）に含まれる地点を検索するには任意の位置座標とデータの位置座標の距離を求めることによって検索することができます。&lt;br /&gt;
&lt;br /&gt;
距離（単位はメートルです）はgeography型のSTDistanceメソッドで求めることができます。&lt;br /&gt;
&lt;br /&gt;
次のようにクエリを発行すると任意の座標から各データの位置データまでの距離が計算されます。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;--任意の位置座標を代入する変数
declare @g geography

--任意の位置座標データとしてJR明石駅の位置座標を使用しています。
set @g=geography::STGeomFromText(&#39;POINT(134.993164 34.649096)&#39;,4326)

select name,address,@g.STDistance(geo) as distance from T_TEST
&lt;/pre&gt;
&lt;br /&gt;
上記のクエリに以下の条件を加えると任意の範囲に含まれるデータを検索できます。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;--200m以内にある地点を検索
where @g.STDistance(geo)&amp;lt;200
&lt;/pre&gt;
&lt;br /&gt;
以上の内容をストアドもしくはユーザー定義関数としてSQLServerに登録して呼び出せるようにしておけば任意の位置データと検索したい範囲の距離を与えて検索することができるようになります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/570410434753884996/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2014/02/sqlserver.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/570410434753884996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/570410434753884996'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2014/02/sqlserver.html' title='SQLServerで地図データ（緯度経度）を検索'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-788949705173453894</id><published>2013-12-31T16:49:00.001+09:00</published><updated>2013-12-31T16:49:21.717+09:00</updated><title type='text'>Windows7で音声合成できない・・・・</title><content type='html'>先日Windowsで音声合成するサンプルを書きましたが、Windows7では動作させることができません。&lt;br /&gt;
Windows7標準の音声合成機能はなぜか日本語音声合成エンジンの提供が通常では行われていないので、プログラムから標準機能のみでの音声合成はできないことになります。&lt;br /&gt;
&lt;br /&gt;
Microsoftの方針としてはSpeechPlatformをインストールして利用してほしいようです。&lt;br /&gt;
実際Office2010以降の読み上げ機能もSpeechPlatformをインストールするように説明があります。&lt;br /&gt;
&lt;br /&gt;
音声認識に関してもサンプルプログラムは動きませんでした。&lt;br /&gt;
&lt;br /&gt;
次回はちょっと予定を変更して、SpeechPlatformのインストールに関して書いてみたいと思います。</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/788949705173453894/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windows7.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/788949705173453894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/788949705173453894'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windows7.html' title='Windows7で音声合成できない・・・・'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-4377064365037758137</id><published>2013-12-27T07:41:00.000+09:00</published><updated>2013-12-27T07:41:17.395+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="音声認識"/><title type='text'>Windowsで音声認識（Choices+GrammarBuilder)</title><content type='html'>先日の音声合成に続いて、Windows標準の音声認識機能を使ってみます。&lt;br /&gt;
&lt;br /&gt;
標準の音声認識機能は学習方式と辞書方式どちらにも対応しているようなのですが、今回は辞書方式で認識させます。&lt;br /&gt;
&lt;br /&gt;
音声合成の場合と同じく特に用意するものはありません。&lt;br /&gt;
&lt;br /&gt;
さっそくサンプルプログラムです。コンソールアプリケーションです。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;using System;
using System.Speech.Recognition;

namespace SpeechRecognized_Sample
{
&amp;nbsp; &amp;nbsp; class Program
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;args&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static void Main(string[] args)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジン（既定のロケールを使用）
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (SpeechRecognitionEngine sre = new SpeechRecognitionEngine())
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //イベント登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.SpeechRecognized += new EventHandler&amp;lt;SpeechRecognizedEventArgs&amp;gt;(sre_SpeechRecognized);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //語彙登録
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Choices words = new Choices(new string[] { &quot;晴れ&quot;, &quot;曇り&quot;, &quot;雨&quot;, &quot;雪&quot; });

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //GrammarBuilderインスタンス
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; GrammarBuilder gb = new GrammarBuilder(&quot;今日の天気は&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //GrammarBuilderインスタンスに語彙を追加
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; gb.Append(words);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Grammarインスタンスを作成
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Grammar g = new Grammar(gb);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Grammarインスタンスをロード
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.LoadGrammar(g);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.Write(&quot;認識開始&quot; + &quot;\n&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //入力ソース（既定のマイク）
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.SetInputToDefaultAudioDevice();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //非同期で認識開始
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.RecognizeAsync(RecognizeMode.Multiple);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (true)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.ReadLine();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.WriteLine(&quot;認識しました:&quot; + e.Result.Text + &quot; 信頼度:&quot; + e.Result.Confidence);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;説明：&lt;/span&gt;&lt;br /&gt;
 &lt;span style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;「プロジェクト」＞「参照の追加」＞「アセンブリ」＞「フレームワーク」内の「System.Speech」のチェックを忘れないでください。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;今回辞書への登録方法としてChoicesクラスとGrammarBuilderクラスを使っています。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;Choicesクラスに認識させたい単語を文字列配列として与えます。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;その後Choicesオブジェクトを引数としてGrammarBuilderクラスに与えます。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;次にGrammarクラスに&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;GrammarBuilderオブジェクトを与えます。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;最後に認識エンジンに&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;Grammarオブジェクトをロードして辞書に登録します。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; line-height: 18px;&quot;&gt;サンプルではGrammarBuilderインスタンスを作成するときに文字列を与えています。&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;このようにすることで「今日の天気は」＋「Choicesクラスに登録した単語」の組み合わせの文章を登録できます。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;音声合成の場合より少し複雑ですが、手順がわかればそれほど難しくはないと思います。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;次回はSRGSを使って認識させるサンプルの予定です。&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 18px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small; line-height: 18px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/4377064365037758137/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windowschoicesgrammarbuilder.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4377064365037758137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/4377064365037758137'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windowschoicesgrammarbuilder.html' title='Windowsで音声認識（Choices+GrammarBuilder)'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-8234129366398386938</id><published>2013-12-25T17:21:00.000+09:00</published><updated>2013-12-25T17:22:28.406+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="音声合成"/><title type='text'>Windowsで音声合成</title><content type='html'>先日大阪でDev(ice)LOVE デバイス祭りという勉強会に参加しました。&lt;br /&gt;
「KINECTを使った音声対話」という内容で話をさせていただいたのですが、その時のスライドに対応したサンプルプログラム+αを何回かに分けて書いていきたいと思います。&lt;br /&gt;
&lt;br /&gt;
ちなみにスライドは&lt;a href=&quot;http://www.slideshare.net/yoshinorihayashi33/kinect-29480947&quot; target=&quot;_blank&quot;&gt;こちら&lt;/a&gt;にアップロードしています。&lt;br /&gt;
&lt;br /&gt;
まず最初に音声合成のサンプルプログラムです。&lt;br /&gt;
勉強会の時はSpeechPlatform11をインストールした状態での説明でしたが、Windows標準の状態でもできますので特に何も用意する必要はありません。（もちろん開発環境は必要です^^;）&lt;br /&gt;
&lt;br /&gt;
サンプルプログラムの動作確認は　Windows8 Pro+VS C# 2012 Express for Desktopですが、&lt;br /&gt;
Windows7やC#2010でも動くと思います。.NET Framework3.5以上なら大丈夫でしょう。もしかするとXPでも動くかもしれないです。&lt;br /&gt;
&lt;br /&gt;
さっそくプログラムです。コンソールアプリとなります。&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;using System;
using System.Speech.Synthesis;

namespace Speak_Sample
{
&amp;nbsp; &amp;nbsp; class Program
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static void Main(string[] args)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声合成エンジン
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SpeechSynthesizer ss = new SpeechSynthesizer();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //出力を既定のスピーカーに設定
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ss.SetOutputToDefaultAudioDevice();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声出力
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ss.Speak(&quot;こんにちは,今日はようこそいらっしゃいました。&quot;);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //キー入力待ち
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Console.ReadKey();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
}
&lt;/pre&gt;
&lt;br /&gt;
あらかじめ「プロジェクト」＞「参照の追加」＞「アセンブリ」＞「フレームワーク」内の「System.Speech」にチェックを入れてください。&lt;br /&gt;
&lt;br /&gt;
2行目の「System.Speech.Synthesis」でWindows標準の音声合成機能を利用できるようにしています。&lt;br /&gt;
&lt;br /&gt;
しゃべらせるだけならこれだけです。ひらがな、カタカナ、漢字も使えます。英語も標準で使えます。&lt;br /&gt;
多国語対応ですが、別に言語パックなどをインストールしなければいけないでしょう。</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/8234129366398386938/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windows.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/8234129366398386938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/8234129366398386938'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/12/windows.html' title='Windowsで音声合成'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-7761122598967520080</id><published>2013-08-02T18:10:00.000+09:00</published><updated>2013-08-02T18:23:56.009+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LeapMotion"/><category scheme="http://www.blogger.com/atom/ns#" term="VB"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>LeapMotion サンプル　その１　（WPF+VB）</title><content type='html'>KINECTよりすごい（かも）と言われているLeapMotionを手に入れました。&lt;br /&gt;
2013/7/22に一般発売でしたが、21日に注文して27日には到着しましたので比較手に入手はしやすいようです。&lt;br /&gt;
&lt;br /&gt;
さて、LeapMotionで何ができるのかと簡単に説明するとセンサー上の手指の位置や移動の情報を高精度で取得できるガジェットです。&lt;br /&gt;
&lt;br /&gt;
開発環境はC++,C#,JAVA,Javascript,Python等色々あります。OSはWindows7以降,MacOS X等（Linuxはまだβ版ドライバ）です。&lt;br /&gt;
&lt;br /&gt;
SDKも一通り揃っているので、開発しやすいと思います。&lt;br /&gt;
&lt;br /&gt;
ただ、SDK内のサンプルプログラムはWPF向けではないので、VB（開発環境には載っていないけれども.NetFramework3.5以降対応なので問題なし）+WPFのサンプルプログラムを作ってみました。&lt;br /&gt;
&lt;br /&gt;
内容は指一本をセンサー上で動かすとCanvas上のポインター（Ellipse）が指先と同じように動きます。&lt;br /&gt;
LeapMotionはSDK上に仮想スクリーンを生成する機能を持っているので、それを利用しています。&lt;br /&gt;
&lt;br /&gt;
早速コードをと行きたいところですが、まずは開発環境を整えましょう。&lt;br /&gt;
&lt;br /&gt;
環境についてはこちらの&lt;a href=&quot;http://www.naturalsoftware.jp/blog/8389&quot;&gt;ブログ&lt;/a&gt;を参照するのが早いと思います。&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;Natural Software&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;http://www.naturalsoftware.jp/blog/8389&lt;br /&gt;
&lt;br /&gt;
C#向けですが、VBも同じです。C++とかMacでの環境設定の説明もあるので他の記事も参考になると思います。&lt;br /&gt;
&lt;br /&gt;
それではプログラムコードです。&lt;br /&gt;
&lt;br /&gt;
まずはXAMLのソースです。画面構成はテキストボックスを4つと、Canvasを1つ配置しています。&lt;br /&gt;
Canvasのサイズは適当に変えても大丈夫です。&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;Window x:Class=&quot;MainWindow&quot;
&amp;nbsp; &amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
&amp;nbsp; &amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
&amp;nbsp; &amp;nbsp; Title=&quot;MainWindow&quot; Height=&quot;900&quot; Width=&quot;1228&quot;&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Grid&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Canvas Name=&quot;Canvas1&quot; Height=&quot;800&quot; Width=&quot;1200&quot; Margin=&quot;10,50,82,19&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox Name=&quot;textbox1&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;23&quot; Margin=&quot;85,10,0,0&quot; TextWrapping=&quot;Wrap&quot; Text=&quot;&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;80&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox x:Name=&quot;textbox2&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;23&quot; Margin=&quot;245,10,0,0&quot; TextWrapping=&quot;Wrap&quot; Text=&quot;&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;80&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox x:Name=&quot;textbox3&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;23&quot; Margin=&quot;358,10,0,0&quot; TextWrapping=&quot;Wrap&quot; Text=&quot;&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;80&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox x:Name=&quot;textbox4&quot; HorizontalAlignment=&quot;Left&quot; Height=&quot;23&quot; Margin=&quot;470,10,0,0&quot; TextWrapping=&quot;Wrap&quot; Text=&quot;&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;80&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;Frame ID:&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;10,10,0,0&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;70&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;Finger ID:&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;170,10,0,0&quot; VerticalAlignment=&quot;Top&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;X:&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;330,10,0,0&quot; VerticalAlignment=&quot;Top&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Label Content=&quot;Y:&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;443,10,0,0&quot; VerticalAlignment=&quot;Top&quot;/&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
次にプログラムコードです。&lt;/div&gt;
&lt;div&gt;
MainWindow.xaml.vb&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;Imports Leap
Class MainWindow
    Private leap As New Controller
    Private windowWidth As Integer = 1200       &#39;&#39;仮想スクリーンの幅
    Private windowHeight As Integer = 800       &#39;&#39;仮想スクリーンの高さ
    Public Sub New()
        &#39; この呼び出しはデザイナーで必要です。
        InitializeComponent()
        &#39; InitializeComponent() 呼び出しの後で初期化を追加します。
        &#39;&#39;イベント登録
        AddHandler CompositionTarget.Rendering, AddressOf UpdateFrame
    End Sub
    Private Sub UpdateFrame(sender As Object, e As EventArgs)
        Dim frame As Leap.Frame = leap.Frame
        Dim finger As Finger = frame.Fingers.Frontmost                      &#39;&#39;一番センサーに近い指を選択
        Dim stabilizedPosition As Vector = finger.StabilizedTipPosition
        Dim iBox As InteractionBox = leap.Frame.InteractionBox
        Dim normalizedPosition As Vector = iBox.NormalizePoint(stabilizedPosition)
        Dim x As Double = normalizedPosition.x * windowWidth
        Dim y As Double = windowHeight - normalizedPosition.y * windowHeight
        &#39;&#39;テキストボックスに各情報をセット
        textbox1.Text = frame.Id
        textbox2.Text = finger.Id
        textbox3.Text = CInt(x)
        textbox4.Text = CInt(y)
        &#39;&#39;Canvasのクリア
        Canvas1.Children.Clear()
        &#39;&#39;指を認識していないときは何もしない
        If finger.Id = -1 Then
        Else
            Dim el As New Ellipse
            Canvas1.Children.Add(el)
            With el
                .Margin = New Thickness(CInt(x), CInt(y), 0, 0)
                .Fill = New SolidColorBrush(Colors.Green)
                .Width = 10
                .Height = 10
            End With
        End If
    End Sub
End Class
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
WPFを使う場合に問題になるのが、要素の書き換え（この場合はCanvas）とセンサーからのデータ取得を同一スレッドで行う必要があることになります。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
今回はCompositionTarget.Renderingイベントに合わせて、センサーからデータを取得しています。&lt;/div&gt;
&lt;div&gt;
CompositionTarget.RenderingはWPFの描画プロセス中に発生するイベントです。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
プログラム内の描画ルーチン（UpdateFrame）は最低限のことしかしていません。本来であれば指先をロストした時の処理なども必要になると思います。（なので指先がセンサーの認識範囲外に移動するとポインターが暴れます。）&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
次はこのプログラムにタッチエミュレーションを加えてみようと思います。&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/7761122598967520080/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/08/leapmotion-wpfvb.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/7761122598967520080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/7761122598967520080'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/08/leapmotion-wpfvb.html' title='LeapMotion サンプル　その１　（WPF+VB）'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-3927108117834616461</id><published>2013-06-27T17:19:00.000+09:00</published><updated>2013-06-27T17:21:25.938+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="SQLServer"/><title type='text'>Node.jsからローカルのSQLServerに接続</title><content type='html'>最近はNode.jsとDB接続に関して色々調べています。&lt;br /&gt;
Node.jsと組み合わせるDBはNosql系のDBが多いですが、今回はSQLServerでやってみました。&lt;br /&gt;
&lt;br /&gt;
MS純正のNode用ドライバは以前から提供されているのですが、日本語での情報がほとんどないため結構苦労しました。&lt;br /&gt;
&lt;br /&gt;
今回はHyper-V上のWindows7にSQLServer2012ExpressとNode.jsをインストールしてみました。&lt;br /&gt;
&lt;br /&gt;
環境：&lt;br /&gt;
・Windows7 Pro SP1 32bit&lt;br /&gt;
・SQLServer 2012 Express x86版&lt;br /&gt;
・Node.js v0.8.25 32bit&lt;br /&gt;
&lt;br /&gt;
その他&lt;br /&gt;
・Express 3.3.0 + ejs&lt;br /&gt;
&lt;br /&gt;
また node-sqlserverのコンパイルに必要なのが&lt;br /&gt;
・Visual C++ 2010 Express&lt;br /&gt;
・Python 2.7&lt;br /&gt;
&lt;br /&gt;
となります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
導入手順&lt;br /&gt;
&lt;br /&gt;
１．&lt;a href=&quot;http://nodejs.jp/nodejs.org_ja/docs/v0.8/&quot; target=&quot;_blank&quot;&gt;Node.js&lt;/a&gt;のダウンロードとインストールをします。今回は0.8系の最新版を選択しました。&lt;br /&gt;
　　（最新安定版の10.0系ではnode-sqlserverがコンパイルできませんでした。）&lt;br /&gt;
&lt;br /&gt;
２．&lt;a href=&quot;http://www.microsoft.com/visualstudio/jpn/downloads#d-2010-express&quot; target=&quot;_blank&quot;&gt;Visual C++ 2010 Express&lt;/a&gt;と&lt;a href=&quot;http://www.microsoft.com/ja-jp/download/details.aspx?id=29062&quot; target=&quot;_blank&quot;&gt;SQLServer2012Express&lt;/a&gt;をダウンロードして、インストールします。&lt;br /&gt;
　　SQLServerはネットワーク接続できるようにファイアウォール等の設定をしています。&lt;br /&gt;
&lt;br /&gt;
３．&lt;a href=&quot;http://www.python.org/download/&quot; target=&quot;_blank&quot;&gt;Python2.7&lt;/a&gt;をダウンロードしてインストールします。&lt;br /&gt;
&lt;br /&gt;
４．SQLServerに「test」データベースを作成し、「T_M商品」テーブルを作成します。&lt;br /&gt;
　　内容は下の図を参照してください。データも適当に入れておきます。&lt;br /&gt;
　　&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWuhTztNAbkfESjtkM3EZZjaa9I30DoeFWSFHcaLoJiXaPC9B3QCa5ATYZZdlmeNSfXaqSoysyVr8fzm3Ku2nw-9jlZm2IOmk2sAu3Z8S5QilLnpVZO_ARcCJyDXzqQhKrBlkvqWxc8OH7/s1600/table.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWuhTztNAbkfESjtkM3EZZjaa9I30DoeFWSFHcaLoJiXaPC9B3QCa5ATYZZdlmeNSfXaqSoysyVr8fzm3Ku2nw-9jlZm2IOmk2sAu3Z8S5QilLnpVZO_ARcCJyDXzqQhKrBlkvqWxc8OH7/s320/table.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
５．C:\に「node」フォルダを作成し、この中にアプリケーションを配置するようにします。&lt;br /&gt;
&lt;br /&gt;
６．Node.jsコマンドプロンプトを起動してからC:\nodeフォルダに移動します。&lt;br /&gt;
&lt;br /&gt;
７．コマンドプロンプトで&lt;i&gt;c:\node&amp;gt;&amp;nbsp;&lt;/i&gt;npm install -g express と入力してExpressをインストールします。&lt;br /&gt;
&lt;br /&gt;
８．&lt;i&gt;c:\node&amp;gt; &lt;/i&gt;express -e test　と入力してtestフォルダにアプリケーションの雛形を作成します。&lt;br /&gt;
　　testフォルダには以下のように雛形が作成されます。&lt;br /&gt;
　　&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7d3fsIL9-AEi-Jit5nrOuVPMOOElShQACwqAuE6SCR878QjLGv2lgIYt4DhIzPTWydAmXGlHqzcsX6WxyOvFQKRyzS0Aq29tUXOaeGwZN8y0wcQP_ne0QvfE-4W1AKGlEEbV5yCBtV06Y/s1600/test%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;215&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7d3fsIL9-AEi-Jit5nrOuVPMOOElShQACwqAuE6SCR878QjLGv2lgIYt4DhIzPTWydAmXGlHqzcsX6WxyOvFQKRyzS0Aq29tUXOaeGwZN8y0wcQP_ne0QvfE-4W1AKGlEEbV5yCBtV06Y/s320/test%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
９．package.jsonファイルをエディタで以下のように編集します。&lt;br /&gt;
&lt;br /&gt;
--------------------------------------------------------　&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &quot;name&quot;: &quot;application-name&quot;,&lt;br /&gt;
&amp;nbsp; &quot;version&quot;: &quot;0.0.1&quot;,&lt;br /&gt;
&amp;nbsp; &quot;private&quot;: true,&lt;br /&gt;
&amp;nbsp; &quot;scripts&quot;: {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;start&quot;: &quot;node app.js&quot;&lt;br /&gt;
&amp;nbsp; },&lt;br /&gt;
&amp;nbsp; &quot;dependencies&quot;: {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;express&quot;: &quot;3.3.0&quot;,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &quot;ejs&quot;: &quot;*&quot;&lt;span style=&quot;color: red;&quot;&gt;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;node-sqlserver&quot;: &quot;*&quot;&lt;/span&gt; &amp;lt;------------赤字部分を追加&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
--------------------------------------------------------&lt;br /&gt;
このときファイルの文字コードに気をつけましょう。UTF-8で保存しておかないと正常に動作しない可能性があります。以下すべてのファイルの文字コードがUTF-8になるようにしてください。&lt;br /&gt;
&lt;br /&gt;
１０．コマンドプロンプト上でtestフォルダに移動してから　&lt;i&gt;c:\node\test&amp;gt; &lt;/i&gt;npm install　と入力する&lt;br /&gt;
　　　と先ほどのpackage.jsonの内容にしたがってインストールが行われます。このとき途中で&lt;br /&gt;
　　　黄色のワーニングメッセージが出るかもしれませんが、コンパイル環境が問題なければ&lt;br /&gt;
　　　そのまま問題なく終了します。&lt;br /&gt;
&lt;br /&gt;
１１．問題なくインストールができるとtestフォルダにはnode_modulesフォルダが追加されています。&lt;br /&gt;
　　　&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR7X7BwdJ_qNiZKEtMnug-o-jwErMQnKPrWe5afYrBRuD3HcA_kT6A3wO55RaFr8YUJjQ5CCKtuEKFrNGyiKorUt72wb7BcVrEqmJjqwF19cKhudt7dhk87uboacWiPim8oDRkpETDIYuw/s1600/test%E3%83%95%E3%82%A9%E3%83%AB%E3%83%802.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;209&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR7X7BwdJ_qNiZKEtMnug-o-jwErMQnKPrWe5afYrBRuD3HcA_kT6A3wO55RaFr8YUJjQ5CCKtuEKFrNGyiKorUt72wb7BcVrEqmJjqwF19cKhudt7dhk87uboacWiPim8oDRkpETDIYuw/s320/test%E3%83%95%E3%82%A9%E3%83%AB%E3%83%802.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
１２．node_modules&amp;gt;node-sqlserver&amp;gt;build&amp;gt;Releaseフォルダ内のsqlserver.nodeファイルを&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
　　　node_modules&amp;gt;node-sqlserver&amp;gt;libフォルダ内にコピーします。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
１３．testフォルダにあるapp.jsファイルを以下のように編集します。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
途中から&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
----------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
app.get(&#39;/&#39;, routes.index);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
app.get(&#39;/users&#39;, user.list);&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;app.post(&#39;/&#39;,routes.index);&lt;/span&gt;&amp;nbsp; &amp;lt;-----赤字の部分を追加&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
----------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
以下は変更なし&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
１４．test&amp;gt;routesフォルダにあるindex.jsファイルを以下のように編集します。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
-------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
exports.index = function(req, res){&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (req.body.code) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;var sql=require(&#39;node-sqlserver&#39;);&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;var cn_str=&quot;Driver={SQL Server Native Client 11.0};Server=(local);Database=test;Uid=&lt;i&gt;ユーザー名&lt;/i&gt;;Pwd=&lt;i&gt;パスワード&lt;/i&gt;;&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sql.query(cn_str,&quot;select * from T_M商品 where 商品コード=&#39;&quot; + req.body.code + &quot;&#39;&quot;,function(err,rst) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (err) {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;res.render(&#39;index&#39;, { title: &#39;ERROR&#39; });&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;console.log(err);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;res.render(&#39;index2&#39;,{ title: &#39;Result&#39;,&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt; &amp;nbsp; &amp;nbsp; rst: rst&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;});&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;});&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else {&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;res.render(&#39;index&#39;, { title: &#39;検索&#39; });&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
};&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
-------------------------------------------------------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
１５．test&amp;gt;viewsフォルダにあるindex.ejsファイルを以下のように編集します。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
-------------------------------------------------------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;html&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;meta charset=&quot;UTF-8&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;%= title %&amp;gt;&amp;lt;/title&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;link rel=&#39;stylesheet&#39; href=&#39;/stylesheets/style.css&#39; /&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/head&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;h1&amp;gt;検索&amp;lt;/h1&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;form method=&quot;POST&quot; action=&quot;/&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; コード検索: &amp;lt;input type=&quot;text&quot; name=&quot;code&quot; size=&quot;50&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;input type=&quot;submit&quot; value=&quot;検索実行&quot;&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;nbsp; &amp;lt;/body&amp;gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&amp;lt;/html&amp;gt;&lt;/div&gt;
&lt;div&gt;
-------------------------------------------------------------------------------&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
１６．test&amp;gt;viewsフォルダにindex2.ejsファイルを以下の内容で追加します。&lt;br /&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;head&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;title&amp;gt;&amp;lt;%= title %&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;link rel=&#39;stylesheet&#39; href=&#39;/stylesheets/style.css&#39; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;body&amp;gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;h1&amp;gt;Data&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;form method=&quot;POST&quot; action=&quot;/&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;コード検索: &amp;lt;input type=&quot;text&quot; name=&quot;code&quot; size=&quot;50&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;input type=&quot;submit&quot; value=&quot;検索実行&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&amp;lt;P&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;table border=&quot;1&quot;&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;th&amp;gt;商品コード&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;th&amp;gt;商品名&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;th&amp;gt;標準価格&amp;lt;/th&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;lt;% for(var i=0;i&amp;lt;rst.length;i++){ %&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&amp;lt;td&amp;gt; &amp;lt;%= rst[i][&#39;商品コード&#39;] %&amp;gt; &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&amp;lt;td&amp;gt; &amp;lt;%= rst[i][&#39;商品名&#39;] %&amp;gt; &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp;&amp;lt;td&amp;gt; &amp;lt;%= rst[i][&#39;価格&#39;] %&amp;gt; &amp;lt;/td&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;lt;% } %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
１７．アプリケーションを動かしてみます。コマンドプロンプトでc:\node\testフォルダに移動して&lt;br /&gt;
　　　&lt;i&gt;c:\node\test&amp;gt;&lt;/i&gt; node app.jsと入力します。&lt;br /&gt;
　　　問題がなければ「Express server listeng on port 3000」と表示されます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
１８．ブラウザで「http://localhost:3000/」にアクセスすると以下のように表示されます。&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2iNqJsJZQgBrzd241dRrWa-kXdjNhoSyQ158lC7Thyphenhyphenc2yLyoq6PglJiwOJpb7Tt7tZuzCnxC0qFgzbfWi87vE4TmztMurCUhxKDIgh9c-qQG_qqIceT4Q8tP7JYgGVxh-5t7akD39qLP1/s1600/index.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2iNqJsJZQgBrzd241dRrWa-kXdjNhoSyQ158lC7Thyphenhyphenc2yLyoq6PglJiwOJpb7Tt7tZuzCnxC0qFgzbfWi87vE4TmztMurCUhxKDIgh9c-qQG_qqIceT4Q8tP7JYgGVxh-5t7akD39qLP1/s320/index.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
１９．試しにコードを入力して検索を実行すると以下のような結果になりました。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdwINbdXu2A2eZG6-aYmnfQnEjmOteIn3EUG3mm6ipwjgczE_q7XLQO6q6D0dITeRB18Ie3NYcZ69yX3YaS-QhHGXAJYLuhfnXZQRpINDnbtV-gFIvDq6MHej5Ec1Ayb7wTeMwbzBwac1g/s1600/result.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdwINbdXu2A2eZG6-aYmnfQnEjmOteIn3EUG3mm6ipwjgczE_q7XLQO6q6D0dITeRB18Ie3NYcZ69yX3YaS-QhHGXAJYLuhfnXZQRpINDnbtV-gFIvDq6MHej5Ec1Ayb7wTeMwbzBwac1g/s320/result.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
まだSelect文のテストしかしていませんが、このようにNode.js＋SQLServerの組み合わせでアプリケーションが作成できました。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Node.jsはまだまだ勉強中なのでたいしたサンプルではないですが、少しでも参考になればと思います。&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/3927108117834616461/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/06/nodejssqlserver.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/3927108117834616461'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/3927108117834616461'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/06/nodejssqlserver.html' title='Node.jsからローカルのSQLServerに接続'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWuhTztNAbkfESjtkM3EZZjaa9I30DoeFWSFHcaLoJiXaPC9B3QCa5ATYZZdlmeNSfXaqSoysyVr8fzm3Ku2nw-9jlZm2IOmk2sAu3Z8S5QilLnpVZO_ARcCJyDXzqQhKrBlkvqWxc8OH7/s72-c/table.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-792989258190335817</id><published>2013-06-26T06:16:00.004+09:00</published><updated>2013-06-26T06:16:50.070+09:00</updated><title type='text'>Intel® Perceptual Computing Challenge　応募用スライド</title><content type='html'>Intel® Perceptual Computing Challenge　応募用スライドです。&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnX4hZce_e79tlbXSlSJPxHGg1Sg30R-knhQjFBWarg3YHIc-DVIbiZjnc7by0pCmqili3RZZ4oGnqC0O1uqbMqN64eh-fRq6VFyXkSWpgoC93QEdEVZMvn_eLuYe8g2ET53Bg6vZWn4Dq/s1600/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25891.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnX4hZce_e79tlbXSlSJPxHGg1Sg30R-knhQjFBWarg3YHIc-DVIbiZjnc7by0pCmqili3RZZ4oGnqC0O1uqbMqN64eh-fRq6VFyXkSWpgoC93QEdEVZMvn_eLuYe8g2ET53Bg6vZWn4Dq/s320/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25891.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Title&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6altlnxIe4n7pUhDiAcwzko0__hy23fogQEz4m0rKDy2pubCGZWKb2q-Twevi1EdTARnNppGcfpuxXXTm2OEE6pnTm7M6PvF4ste8QaRazuEvehKo4jz1c2c63Q6N1hd7GR2Le7-01wtk/s1600/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25892.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6altlnxIe4n7pUhDiAcwzko0__hy23fogQEz4m0rKDy2pubCGZWKb2q-Twevi1EdTARnNppGcfpuxXXTm2OEE6pnTm7M6PvF4ste8QaRazuEvehKo4jz1c2c63Q6N1hd7GR2Le7-01wtk/s320/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25892.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Slide1&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiimJrOajG7bDAVO3NX6AW7VU4TgH-Daa5NjolHIewAN8tWFoFAggHphGq846oirjZ0Ryf2C5tVk4aoIkdbrSMl9n9YxRCW_sHMSQCbMvH2IgjKjAXhUrUAJBdAwZApuzZofsOb1j3yP5St/s1600/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25893.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiimJrOajG7bDAVO3NX6AW7VU4TgH-Daa5NjolHIewAN8tWFoFAggHphGq846oirjZ0Ryf2C5tVk4aoIkdbrSMl9n9YxRCW_sHMSQCbMvH2IgjKjAXhUrUAJBdAwZApuzZofsOb1j3yP5St/s320/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25893.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Slide2&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Xk0KhZkRiBfDw-8NPhskEfoRdTEHKatHlRm-dc0SBSyzdpWfQ8YbnJ5wd_Z8ZoUpncjHM2dtkjWCzVyIIJrEU4ogBu0xR439RqkY1EOuNMMU-44CiIvVkIx9PhHsIbP9gg9H_wBhHxJd/s1600/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25894.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;180&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_Xk0KhZkRiBfDw-8NPhskEfoRdTEHKatHlRm-dc0SBSyzdpWfQ8YbnJ5wd_Z8ZoUpncjHM2dtkjWCzVyIIJrEU4ogBu0xR439RqkY1EOuNMMU-44CiIvVkIx9PhHsIbP9gg9H_wBhHxJd/s320/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25894.PNG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Slide3&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/792989258190335817/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/06/intel-perceptual-computing-challenge.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/792989258190335817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/792989258190335817'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/06/intel-perceptual-computing-challenge.html' title='Intel® Perceptual Computing Challenge　応募用スライド'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnX4hZce_e79tlbXSlSJPxHGg1Sg30R-knhQjFBWarg3YHIc-DVIbiZjnc7by0pCmqili3RZZ4oGnqC0O1uqbMqN64eh-fRq6VFyXkSWpgoC93QEdEVZMvn_eLuYe8g2ET53Bg6vZWn4Dq/s72-c/%25E3%2582%25B9%25E3%2583%25A9%25E3%2582%25A4%25E3%2583%25891.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-5972605383417168756</id><published>2013-02-14T12:17:00.001+09:00</published><updated>2013-02-14T12:48:50.204+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LocalDB"/><category scheme="http://www.blogger.com/atom/ns#" term="SQLServer"/><category scheme="http://www.blogger.com/atom/ns#" term="VBA"/><title type='text'>LocalDBをVBAから使ってみる</title><content type='html'>久しぶりの投稿です。&lt;br /&gt;
&lt;br /&gt;
しばらくKinectさわっていません。&lt;br /&gt;
なぜかHoGの投稿に定期的にアクセスがあります。どうしてなのかな？&lt;br /&gt;
&lt;br /&gt;
さて、今回はSQLServer2012から新たに追加になったLocalDBについてです。&lt;br /&gt;
&lt;br /&gt;
SQL Server2012Expressもほとんど同じですが、スタンドアローン環境で使うならLocalDBの方が手軽に使えそうです。&lt;br /&gt;
&lt;br /&gt;
ただ、色々なサイトで解説はあるんですが、VBAでの解説があまりないようです。&lt;br /&gt;
&lt;br /&gt;
試しにExcel2013でADO+NativeClientで接続してみようとすると、最初はうまく接続できませんでした。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
最初に書いたコードです。&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------------------------------------------&lt;br /&gt;
Sub DB接続()&lt;br /&gt;
&lt;br /&gt;
Dim cn As New ADODB.Connection&lt;br /&gt;
&lt;br /&gt;
cn.ConnectionString = &quot;provider=sqlncli11;server=(localdb)\v11.0;database=test;integrated security=true;DataTypeCompatibility=80;MARS Connection=True&quot;&lt;br /&gt;
&lt;br /&gt;
cn.Open&lt;br /&gt;
&lt;br /&gt;
Dim rs As New ADODB.Recordset&lt;br /&gt;
&lt;br /&gt;
rs.Open &quot;select * from T_商品&quot;, cn, adOpenStatic, adLockReadOnly&lt;br /&gt;
&lt;br /&gt;
If rs.BOF And rs.EOF Then&lt;br /&gt;
&lt;br /&gt;
Else&lt;br /&gt;
Range(&quot;A1&quot;).Select&lt;br /&gt;
ActiveCell.CopyFromRecordset rs&lt;br /&gt;
End If&lt;br /&gt;
&lt;br /&gt;
rs.Close&lt;br /&gt;
Set rs = Nothing&lt;br /&gt;
&lt;br /&gt;
End Sub&lt;br /&gt;
-----------------------------------------------------------------------------------------------------------&lt;br /&gt;
（あらかじめ既定のインスタンスにtestデータベースを作成して、T_商品テーブルを追加しています。）&lt;br /&gt;
&lt;br /&gt;
この場合コネクションを開いた時点でエラーが発生しました。&lt;br /&gt;
&lt;br /&gt;
色々試した結果は&lt;br /&gt;
&lt;br /&gt;
「integrated security=true」を「integrated security=SSPI」に変更すれば正常に動作しました。&lt;br /&gt;
&lt;br /&gt;
通常TrueでもADO.NETなどは動くようなのですが・・・・&lt;br /&gt;
&lt;br /&gt;
まぁ、これでEXCELやACCESSでもLocalDBが利用できそうです。&lt;br /&gt;
&lt;br /&gt;
あとLocalDBはSQLOLEDBプロバイダは使えないみたいです。&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/5972605383417168756/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2013/02/localdb.html#comment-form' title='2 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5972605383417168756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/5972605383417168756'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2013/02/localdb.html' title='LocalDBをVBAから使ってみる'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-7576807520697303090</id><published>2012-09-13T10:42:00.000+09:00</published><updated>2012-10-04T12:46:34.530+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="KINECT"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenCV"/><title type='text'>KINECTサンプル（C#)　HoGを使った人認識</title><content type='html'>今回はちょっと難しい（自分でも仕組みを全部理解できていません）サンプルです。&lt;br /&gt;
内容はSUBARUのEyeSightみたいに人物（EyeSightでは人物以外の物体も認識していますが）を認識するプログラムです。&lt;br /&gt;
もともとはFaceBookで知り合いが人認識できないかなという話題から始まって、たしかOpenCVにサンプルがあったことを思い出したので、それを参考に作ってみました。（最終的に参考にしたのはOpenCVSharpのサンプルプログラムですけど）&lt;br /&gt;
&lt;br /&gt;
ではサンプルです。&lt;br /&gt;
&lt;br /&gt;
まず、参照設定ですが、以前のOpenCVサンプルで追加した参照以外に今回は「OpenCvsharp.CPlusPlus」を追加してください。あと「OpenCvSharpExtern.dll」をプロジェクトにコピーして、コピーしたファイルプロパティ内の「出力ディレクトリにコピー」を「常にコピーする」に変更してください。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;&amp;lt;Window x:Class=&quot;Kinect_HoG.MainWindow&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Title=&quot;MainWindow&quot; Height=&quot;519&quot; Width=&quot;662&quot;&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Grid&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Image Height=&quot;480&quot; &amp;nbsp;Name=&quot;image1&quot; Stretch=&quot;Uniform&quot; &amp;nbsp;Width=&quot;640&quot; /&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Canvas Height=&quot;480&quot; HorizontalAlignment=&quot;Left&quot; Name=&quot;canvas1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;640&quot; /&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;
&lt;/pre&gt; &lt;br /&gt;
イメージコントロールとキャンバスコントロールを重ねて配置しています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml.cs&lt;br /&gt;
&lt;pre class=&quot;prettyprint&quot;&gt;using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using System.Drawing;
using Microsoft.Kinect;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using OpenCvSharp.CPlusPlus;
using CPP = OpenCvSharp.CPlusPlus;

namespace Kinect_HoG
{
&amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; /// MainWindow.xaml の相互作用ロジック
&amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; public partial class MainWindow : Window
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private KinectSensor kinect;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private byte[] colorPixel;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private IplImage CvImg;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private WriteableBitmap srcImg;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private Int32Rect bitmapRect;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public MainWindow()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (KinectSensor.KinectSensors.Count == 0)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MessageBox.Show(&quot;KINECTがみつかりません。&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Close();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect = KinectSensor.KinectSensors[0];

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.ColorStream.Enable();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.ColorFrameReady += new EventHandler&amp;lt;ColorImageFrameReadyEventArgs&amp;gt;(kinect_ColorFrameReady);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Start();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //カラー画像用
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; srcImg=new WriteableBitmap(kinect.ColorStream.FrameWidth,kinect.ColorStream.FrameHeight,96,96,PixelFormats.Rgb24,null);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bitmapRect =new Int32Rect(0,0,kinect.ColorStream.FrameWidth,kinect.ColorStream.FrameHeight);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrame != null)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorPixel = new byte[colorFrame.PixelDataLength];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorFrame.CopyPixelDataTo(colorPixel);

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //カラーイメージ表示
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; srcImg.WritePixels(bitmapRect, CvtBGR32toRGB24(colorPixel),srcImg.BackBufferStride, 0);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; image1.Source = srcImg;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //10フレームごとにHoG処理
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrame.FrameNumber % 10 == 0)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hog(srcImg);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;srcImg&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Hog(WriteableBitmap srcImg)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //画像をMat配列に読み込み
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CPP.Mat CvImg = new CPP.Mat(srcImg.ToIplImage());
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //HoG検出器の準備
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: red;&quot;&gt;CPP.HOGDescriptor hog = new CPP.HOGDescriptor();&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;//人物検出用分類器の準備
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; hog.SetSVMDetector(CPP.HOGDescriptor.GetDefaultPeopleDetector());&lt;/span&gt;
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;//人物検出の実行（パラメーターは元のサンプルのまま）
&lt;span style=&quot;color: red;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CvRect[] found = hog.DetectMultiScale(CvImg, 0, new CvSize(8, 8), new CvSize(24, 16), 1.05, 2);&lt;/span&gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //人物を認識したときはキャンバスに矩形を表示する
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //キャンバスのクリア
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas1.Children.Clear();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //検出時のみ矩形を描画
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (found.Length !=0)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach (CvRect rect in found)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas1.Children.Add(new System.Windows.Shapes.Rectangle()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Margin = new Thickness(rect.X + (int)Math.Round(rect.Width * 0.1), rect.Y + (int)Math.Round(rect.Height * 0.1), 0, 0),
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Stroke = new SolidColorBrush(Colors.Red),
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; StrokeThickness = 3,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Width = (int)Math.Round(rect.Width * 0.8),
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Height = (int)Math.Round(rect.Height * 0.8)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// BGR32からRGB24に変換
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;pixels&quot;&amp;gt;&amp;lt;/param&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private byte[] CvtBGR32toRGB24(byte[] pixels)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var bytes = new byte[pixels.Length / 4 * 3];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int i = 0; i &amp;lt; pixels.Length / 4; i++)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bytes[i * 3] = pixels[i * 4+2];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bytes[i * 3 + 1] = pixels[i * 4+1];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bytes[i * 3 + 2] = pixels[i * 4];
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return bytes;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
}
&lt;/pre&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;カラーイメージを表示している所はRGBサンプルとほぼ同じです。&lt;/div&gt;&lt;div&gt;Hog関数でカラーイメージをOpenCVを利用して処理しています。&lt;/div&gt;&lt;div&gt;カラーイメージ内で人を認識できた結果は矩形座標となるので、それを元にキャンバスコントロールに矩形を描画しています。&lt;/div&gt;&lt;div&gt;Hog関数自体はWritableBitmap形式のデータを与えれば動作するのでちょっと変更すればKINECT以外のデータ（静止画とかWEBカメラの映像イメージ）も処理できます。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;人認識のアルゴリズムについては理解できていないところが多いですが、赤字の部分ですべての処理ができるようです。認識精度などはパラメーターを変更すればあげられるかもしれません。&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;HoGを使った処理ですがやはり相当重いようです。使っているPCはCorei7-2600Kですが、動作中はすべてのコアの使用率が軒並み50%以上になりました。&lt;br /&gt;
30FPSで処理するとまともに画像が表示されません。&lt;br /&gt;
C++でプログラムを記述するほうがいいのかもしれませんね。（HoG処理自体C++のインターフェイス向けなので）&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/7576807520697303090/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectc.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/7576807520697303090'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/7576807520697303090'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectc.html' title='KINECTサンプル（C#)　HoGを使った人認識'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-2835024351457843996</id><published>2012-09-09T09:45:00.001+09:00</published><updated>2012-09-13T11:24:35.907+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="KINECT"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenCV"/><title type='text'>KINECTサンプル（C#)　OpenCV  for SDK1.5</title><content type='html'>今日のサンプルは&lt;a href=&quot;http://opencv.jp/&quot;&gt;OpenCV&lt;/a&gt;を使っての初歩的な画像処理を行います。&lt;br /&gt;
KINECTそのものはあくまでもセンサーなので、受け取ったデータはPCで処理をしなければいけません。その中でメインはやはり画像処理になってくるのでしょうが、Windows自体は画像処理は得意な方ではありません。そこで外部ライブラリを利用することになります。よく使われているのがOpenCVというライブラリになります。&lt;br /&gt;
OpenCVはもともとC++およびC言語向けとしてプログラミングインターフェイスを公開しているので.NetFrameworkからの利用は難しくなります。そこで&lt;a href=&quot;http://code.google.com/p/opencvsharp/&quot;&gt;OpenCVSharp&lt;/a&gt;というラッパーライブラリを利用することにします。&lt;br /&gt;
&lt;br /&gt;
まずはOpenCVのインストールです。&lt;br /&gt;
&lt;br /&gt;
現在OpenCVの最新バージョンは2.4.2（2012/09/09現在）となりますが、少し前のバージョン2.3.1を使います。&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/&quot;&gt;http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/&lt;/a&gt;より「OpenCV-2.3.1-win-superpack.exe」をダウンロードしてください。&lt;br /&gt;
ダウンロードしたファイルを解凍すると、opencvフォルダができますので、好きな場所にコピーします。今回はC:\にコピーしました。&lt;br /&gt;
次にシステム環境変数のPathを設定をします。ここでは使っているOSの種類やOpenCVの種類によって指定するPathが変わるのですが、今回は32bit向けの設定にします。（OSが64ビットでも動きます。）&lt;br /&gt;
「コンピュータ」のプロパティを開き、「システムの詳細設定」＞「詳細設定」タブ＞「環境変数」ボタンを押します。システム環境変数の「Path」の選び編集ボタンを押します。変数値の一番最後に「c:\opencv\build\x86\vc10\bin;c:\opencv\build\common\tbb\ia32\vc10」と2つのパスを追加します。かならず現在の変数値の最後に追加するようにしてください。誤ってほかの箇所を変更してしまうと動かなくなるアプリケーションが出るかもしれません。また追加する際にパスの区切りである「；」（セミコロン）を忘れずにつけましょう。&lt;br /&gt;
以上でOpenCVの設定は終わりです。&lt;br /&gt;
&lt;br /&gt;
続いてOpenCVSharpの設定です。&lt;br /&gt;
&lt;a href=&quot;http://code.google.com/p/opencvsharp/&quot;&gt;http://code.google.com/p/opencvsharp/&lt;/a&gt;の左メニューの「Downloads」から「OpenCvSharp-2.3.1-x86-20120519.zip」をダウンロードして適当な場所に解凍します。&lt;br /&gt;
このままでもいいのですが、解凍したフォルダ内のDLLと「XmlDoc-Japanese」内のファイルを同一フォルダにまとめておくと、プログラム入力中に日本語でツールチップが表示されるので便利です。&lt;br /&gt;
&lt;br /&gt;
ではサンプルプログラムです。&lt;br /&gt;
サンプルではKINECTのカラーイメージとOpenCVでCannyを用いた2値化画像を同時に表示しています。&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml&lt;br /&gt;
------------------------------------------------------------------------------
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Window x:Class=&quot;KinectOpenCV.MainWindow&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Title=&quot;MainWindow&quot; mc:Ignorable=&quot;d&quot; xmlns:d=&quot;http://schemas.microsoft.com/expression/blend/2008&quot; xmlns:mc=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot; d:DesignWidth=&quot;1308&quot; SizeToContent=&quot;WidthAndHeight&quot; d:DesignHeight=&quot;519&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Grid&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Image Height=&quot;480&quot; HorizontalAlignment=&quot;Left&quot; &amp;nbsp;Name=&quot;image1&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;640&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;Image Height=&quot;480&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;646,0,0,0&quot; Name=&quot;image2&quot; Stretch=&quot;Fill&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;640&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/Grid&amp;gt;&lt;br /&gt;
&amp;lt;/Window&amp;gt;&lt;br /&gt;
------------------------------------------------------------------------------
&lt;br /&gt;
イメージコントロールを２つ横に並べて配置しています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
参照設定がいくつか必要になります。&lt;br /&gt;
「参照設定」＞「参照の追加」の「.NET」タブから「Microsoft.Kinect」と「System.Drawing」を追加してください。次に参照タブから先ほどOpenCVSharpを保存したフォルダを選択して、「OpenCvSharp.dll」と「OpenCvSharp.Extensions.dll」を選択してください。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
MainWindow.xaml.cs&lt;br /&gt;
------------------------------------------------------------------------------
&lt;br /&gt;
&lt;br /&gt;
using System;&lt;br /&gt;
using System.Windows;&lt;br /&gt;
using System.Windows.Media;&lt;br /&gt;
using System.Windows.Media.Imaging;&lt;br /&gt;
&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
&lt;br /&gt;
using Microsoft.Kinect;&lt;br /&gt;
using OpenCvSharp;&lt;br /&gt;
using OpenCvSharp.Extensions;&lt;br /&gt;
&lt;br /&gt;
namespace KinectOpenCV&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /// MainWindow.xaml の相互作用ロジック&lt;br /&gt;
&amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public partial class MainWindow : Window&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private KinectSensor kinect;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private WriteableBitmap srcImg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private WriteableBitmap distImg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private Int32Rect bitmapRect;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private IplImage CvImg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private IplImage CvGrayImg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private IplImage CannyImg;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public MainWindow()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (KinectSensor.KinectSensors.Count == 0)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MessageBox.Show(&quot;KINECTがみつかりません。&quot;);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Close();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect = KinectSensor.KinectSensors[0];&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.ColorStream.Enable();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.ColorFrameReady += new EventHandler&amp;lt;ColorImageFrameReadyEventArgs&amp;gt;(kinect_ColorFrameReady);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Start();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV用&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; srcImg=new WriteableBitmap(kinect.ColorStream.FrameWidth,kinect.ColorStream.FrameHeight,96,96,PixelFormats.Bgra32,null);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV処理後用&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; distImg = new WriteableBitmap(kinect.ColorStream.FrameWidth, kinect.ColorStream.FrameHeight, 96, 96, PixelFormats.Bgr32, null);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //画像のサイズ(640*480)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bitmapRect=new Int32Rect(0,0,kinect.ColorStream.FrameWidth,kinect.ColorStream.FrameHeight);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV用画像&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CvImg = Cv.CreateImage(new CvSize(640, 480), BitDepth.U8, 3);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV用グレースケール画像&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CvGrayImg = new IplImage(CvImg.Size, BitDepth.U8, 1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV用Canny処理画像&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CannyImg = new IplImage(CvImg.Size, BitDepth.U8, 1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; using (ColorImageFrame colorFrame = e.OpenColorImageFrame())&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (colorFrame != null)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTからのカラーイメージデータ&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; byte[] colorPixel = new byte[colorFrame.PixelDataLength];&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; colorFrame.CopyPixelDataTo(colorPixel);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //OpenCV向けWritablebitmapに書込み&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; srcImg.WritePixels(bitmapRect, colorPixel, colorFrame.Width * colorFrame.BytesPerPixel, 0);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //通常画像むけWritablebitmapに書込み&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; distImg.WritePixels(bitmapRect, colorPixel, colorFrame.Width * colorFrame.BytesPerPixel, 0);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //WritablebitmapをIplImageに変換&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CvImg = srcImg.ToIplImage();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //グレースケール処理&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cv.CvtColor(CvImg, CvGrayImg, ColorConversion.BgrToGray);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Canny処理（2値化）&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Cv.Canny(CvGrayImg, CannyImg, 50, 200);&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //通常画像を表示&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; image1.Source = distImg;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Canny処理後の画像を変換して表示&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; image2.Source = CannyImg.ToWriteableBitmap();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
以前のRGBカメラサンプルではイメージコントロールにBitmapSourceを使っていましたが、今回はWritableBitmapを使っています。&lt;br /&gt;
OpenCVでは画像処理形式としてIplImageというデータ形式を使っています。IplImageではBGR32データは受け取れないのでRGB24形式に変換するプログラムを書くか、BGRA32形式のデータを使うかしなければいけません。&lt;br /&gt;
今回はBGRA32形式のWritabebitmapを変換してOpenCVに渡すようにしています。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/2835024351457843996/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectcopencv-for-sdk15.html#comment-form' title='3 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2835024351457843996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2835024351457843996'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectcopencv-for-sdk15.html' title='KINECTサンプル（C#)　OpenCV  for SDK1.5'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4995941213040074756.post-2820494073873671408</id><published>2012-09-08T08:30:00.000+09:00</published><updated>2012-09-08T08:30:26.452+09:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C#"/><category scheme="http://www.blogger.com/atom/ns#" term="KINECT"/><title type='text'>KINECTサンプル（C#)　Speech2 for SDK1.5</title><content type='html'>前回の音声認識サンプルではプログラム内で認識したい言葉を記述していましたが、SpeechPlatform自体はSRGS（Speech Recognition Grammar Specification）形式でのGrammar設定もできるようになっています。SRGSはxmlですので決められたタグを用いて、柔軟に認識させたい言葉、文章を記述することができます。&lt;br /&gt;
&lt;br /&gt;
まずはGrammarファイルです。今回は２つ用意しました。&lt;br /&gt;
&lt;br /&gt;
greeting.xml&lt;br /&gt;
------------------------------------------------------------------------------
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&lt;br /&gt;
&amp;lt;grammar xml:lang=&quot;ja-JP&quot; version=&quot;1.0&quot;&lt;br /&gt;
xmlns=&quot;http://www.w3.org/2001/06/grammar&quot;&lt;br /&gt;
tag-format=&quot;semantics/1.0&quot; root=&quot;greeting&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;rule id=&quot;greeting&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;one-of&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;おはよう&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;こんにちは&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;こんばんは&amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/one-of&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;lt;/rule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/grammar&amp;gt;&lt;br /&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
前半はほぼ固定された内容になります。rootエレメントは自由に記述できます。&lt;/div&gt;
&lt;div&gt;
ruleタグのidエレメントも自由に記述することができます。&lt;/div&gt;
&lt;div&gt;
itemタグで認識させたい内容を記述するのですが、one-ofタグがない場合には連続した言葉として登録されます。one-ofタグでくくることによりitemタグ毎の言葉として登録することができるようになります。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
次は文章を表すSRGSの記述方法です。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
main.xml&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;grammar xml:lang=&quot;ja-JP&quot; version=&quot;1.0&quot;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
xmlns=&quot;http://www.w3.org/2001/06/grammar&quot;&lt;/div&gt;
&lt;div&gt;
tag-format=&quot;semantics/1.0&quot; root=&quot;main&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;rule id=&quot;main&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ruleref uri=&quot;#fruits&quot; /&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; を&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;ruleref uri=&quot;#verb&quot; /&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/rule&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;rule id=&quot;fruits&quot; scope=&quot;public&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;one-of&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;みかん&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;りんご&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;すいか&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;なし&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;ぶどう&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/one-of&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/rule&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;rule id=&quot;verb&quot; scope=&quot;public&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;one-of&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;とる&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;かう&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;むく&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;item&amp;gt;たべる&amp;lt;/item&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/one-of&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;lt;/rule&amp;gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/grammar&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
rulerefタグを使うことで別に記述したruleタグの内容を当てはめることができるようになります。&lt;/div&gt;
&lt;div&gt;
このファイルの場合mainのところで「fruitsの内のどれか1つ」　＋　「を」　＋　「verb」の内のどれか一つという文章を定義しています。&lt;/div&gt;
&lt;div&gt;
フルーツ5種類×動詞4種類＝20種類の文章を定義していることになります。&lt;/div&gt;
&lt;div&gt;
rulerefタグで参照されるruleタグではscopeエレメントにpublicを指定してください。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
以上のファイルをUTF-8形式で保存してください。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
プロジェクト＞追加＞既存の項目で2つのファイルを追加してください。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
画面設定です。&lt;/div&gt;
&lt;div&gt;
MainWindows.xaml&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;lt;Window x:Class=&quot;KinectSpeech2forSDK15.MainWindow&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot; Loaded=&quot;Window_Loaded&quot; Closed=&quot;Window_Closed&quot;&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;Grid&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;TextBox Height=&quot;50&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;12,90,0,0&quot; Name=&quot;textBox1&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;479&quot; TextAlignment=&quot;Center&quot; FontSize=&quot;36&quot; Text=&quot;&quot; /&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/Grid&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;lt;/Window&amp;gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
テキストボックスを1つ配置しています。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
メインプログラムです。&lt;/div&gt;
&lt;div&gt;
MainWindows.xaml.cs&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
using System;&lt;/div&gt;
&lt;div&gt;
using System.Windows;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
using Microsoft.Kinect;&lt;/div&gt;
&lt;div&gt;
using Microsoft.Speech.AudioFormat;&lt;/div&gt;
&lt;div&gt;
using Microsoft.Speech.Recognition;&lt;/div&gt;
&lt;div&gt;
using System.IO;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
namespace KinectSpeech2forSDK15&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /// MainWindow.xaml の相互作用ロジック&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public partial class MainWindow : Window&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private KinectSensor kinect;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private KinectAudioSource audio;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private SpeechRecognitionEngine sre;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //日本語音声認識エンジンの名前&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; const string sreName = &quot;SR_MS_ja-JP_Kinect_11.0&quot;;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public MainWindow()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (KinectSensor.KinectSensors.Count == 0)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MessageBox.Show(&quot;KINECTがみつかりません。&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Close();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Window_Loaded(object sender, RoutedEventArgs e)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTの初期化&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect = KinectSensor.KinectSensors[0];&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //音声認識エンジンの初期化&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre = new SpeechRecognitionEngine(sreName);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //Grammarファイルを読み込む（SRGS形式）&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var greet = new Grammar(&quot;../../greeting.xml&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var ma = new Grammar(&quot;../../main.xml&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンにグラマーを登録&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.LoadGrammar(greet);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.LoadGrammar(ma);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //イベントの登録&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.SpeechRecognized += new EventHandler&amp;lt;SpeechRecognizedEventArgs&amp;gt;(sre_SpeechRecognized);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.SpeechRecognitionRejected += new EventHandler&amp;lt;SpeechRecognitionRejectedEventArgs&amp;gt;(sre_SpeechRecognitionRejected);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTのスタート&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Start();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //KINECTのマイク入力&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audio = kinect.AudioSource;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audio.AutomaticGainControlEnabled = false;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; audio.EchoCancellationMode = EchoCancellationMode.None;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //マイク入力開始&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Stream s = audio.Start();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //オーディオフォーマットの設定&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var speechAudioFormat = new SpeechAudioFormatInfo(EncodingFormat.Pcm,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16000,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 16,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 32000,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; null);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識エンジンに入力ストリームとフォーマットを指定&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.SetInputToAudioStream(s, speechAudioFormat);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識開始（非同期、複数認識を有効にする。）　&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //※認識が可能になるのが数秒かかる&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.RecognizeAsync(RecognizeMode.Multiple);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void sre_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; textBox1.Text = &quot;認識できません。&quot;;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識信頼度が0.7以上のときに認識したことにする　&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //（認識信頼度　-1&amp;lt;0&amp;lt;1 -1が低信頼度　0が標準　1が高信頼度　数字が大きいほど認識率が厳しくなる）　&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (e.Result.Confidence &amp;gt;= 0.7)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //認識した単語の表示&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; textBox1.Text = e.Result.Text;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ///&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;/summary&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;sender&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// &amp;lt;param name=&quot;e&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void Window_Closed(object sender, EventArgs e)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (kinect != null)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (kinect.IsRunning == true)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.AudioSource.Stop();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kinect.Stop();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sre.RecognizeAsyncStop();&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
------------------------------------------------------------------------------
&lt;/div&gt;
&lt;div&gt;
プログラムの基本的な部分は以前のサンプルとほぼ一緒です。&lt;/div&gt;
&lt;div&gt;
Grammarを指定する部分でSRGS形式で記述したxmlファイルを読み込んでいます。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
KINECTにおける音声認識の目的はPCを音声でコントロールすることがメインのようです。&lt;/div&gt;
&lt;div&gt;
ただ、SpeechPlatformは現在LyncServerにも含まれていますので、コミュニケーションアイテムとしての可能性もあるのではないかと思います。&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
参考としてKINECTを使ったこんなプロジェクトもあるようです。&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://msdn.microsoft.com/ja-jp/magazine/hh882450.aspx&quot;&gt;http://msdn.microsoft.com/ja-jp/magazine/hh882450.aspx&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://linyi-zatta.blogspot.com/feeds/2820494073873671408/comments/default' title='コメントの投稿'/><link rel='replies' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectcspeech2-for-sdk15.html#comment-form' title='0 件のコメント'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2820494073873671408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4995941213040074756/posts/default/2820494073873671408'/><link rel='alternate' type='text/html' href='http://linyi-zatta.blogspot.com/2012/09/kinectcspeech2-for-sdk15.html' title='KINECTサンプル（C#)　Speech2 for SDK1.5'/><author><name>linyi</name><uri>http://www.blogger.com/profile/02471608177817645545</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>