{"id":565,"date":"2012-02-15T20:54:06","date_gmt":"2012-02-15T11:54:06","guid":{"rendered":"http:\/\/www.digifie.jp\/blog\/?p=565"},"modified":"2012-02-16T09:33:54","modified_gmt":"2012-02-16T00:33:54","slug":"xtion-%e3%81%a8-flash-%e3%82%92%e3%81%8f%e3%81%a3%e3%81%a4%e3%81%91%e3%81%a6%e3%81%a1%e3%82%87%e3%81%a3%e3%81%a8%e3%81%a0%e3%81%91%e9%81%8a%e3%82%93%e3%81%a7%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.digifie.jp\/blog\/archives\/565","title":{"rendered":"Xtion \u3068 Flash \u3092\u304f\u3063\u3064\u3051\u3066\u3061\u3087\u3063\u3068\u3060\u3051\u904a\u3093\u3067\u307f\u305f"},"content":{"rendered":"<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fwww.digifie.jp%2Fblog%2Farchives%2F565&t=Xtion%20%E3%81%A8%20Flash%20%E3%82%92%E3%81%8F%E3%81%A3%E3%81%A4%E3%81%91%E3%81%A6%E3%81%A1%E3%82%87%E3%81%A3%E3%81%A8%E3%81%A0%E3%81%91%E9%81%8A%E3%82%93%E3%81%A7%E3%81%BF%E3%81%9F' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/www.digifie.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.digifie.jp\/blog\/archives\/565\" data-text=\"Xtion \u3068 Flash \u3092\u304f\u3063\u3064\u3051\u3066\u3061\u3087\u3063\u3068\u3060\u3051\u904a\u3093\u3067\u307f\u305f\" data-via=\"LLC DigiFie\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n<p>\u4ed5\u4e8b\u304c\u30a2\u30ec\u3067\u5168\u7136\u89e6\u308c\u3066\u306a\u304b\u3063\u305f Xtion\uff08\u4f8b\u306eKinect\u306e\u3061\u3063\u3053\u3044\u30e4\u30c4\u306d\uff09\u3092\u3001OpenNI\uff08NiHandTracker\uff09\u3068 Flash\uff08AIR 2.0 NativeProcess)\uff09\u3067\u7d50\u5408\u3055\u305b\u3066\u3001\u4ee5\u524d Wonderfl \u306b\u30dd\u30b9\u30c8\u3057\u3066\u3044\u305f WebCmera \u3092\u4f7f\u3063\u305f\u30e2\u30fc\u30b7\u30e7\u30f3\u30c8\u30e9\u30c3\u30af\u3067\u904a\u3076\u30cc\u30f3\u30c1\u30e3\u30af\u3054\u3063\u3053\u3092\u3001\u7cbe\u5ea6\u304c\u9ad8\u3044 Xtion\u7248\u3068\u3057\u3066\u4f5c\u308a\u76f4\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u52d5\u4f5c\u306e\u30c7\u30e2\u6620\u50cf\u306f\u3053\u3061\u3089\u3002<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/_YAAMyqMQeE\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\n\uff08\u30cc\u30f3\u30c1\u30e3\u30af\u306e\u7db4\u308a\u304c\u9593\u9055\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u304c\u6c17\u306b\u3057\u306a\u3044\u6c17\u306b\u3057\u306a\u3044w\uff09<\/p>\n<p>\u3067\u3001Flash \u3068 Xtion \u3092\u3069\u3046\u3084\u3063\u3066\u7d50\u5408\u3057\u305f\u304b\u3068\u3044\u3048\u3070\u2026<br \/>\nAIR 3.0 \u306e ANE\uff08\u30cd\u30a4\u30c6\u30a3\u30d6\u62e1\u5f35\uff09\u3092\u4f7f\u7528\u3057\u3066\u304f\u3063\u3064\u3051\u3088\u3046\u304b\u3068\u3082\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u4eca\u65e5\u4e00\u65e5\u3057\u304b\u89e6\u308c\u308b\u6642\u9593\u304c\u53d6\u308c\u305d\u3046\u306b\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u5b89\u5168\u7b56\uff08\uff1f\uff09\u3092\u3068\u3063\u3066\u3001AIR 2.0 \u306e NativeProcess API \u3092\u4f7f\u7528\u3057\u3066 C++\uff08OpenNI\uff09\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3068 Flash \u3092\u7d50\u5408\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u308f\u3051\u3067\u3001NativeProcess \u3067 Xtion \u304b\u3089\u5024\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u66f8\u3044\u305f AS \u306e\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">package \r\n{\r\n\timport flash.desktop.*;\r\n\timport flash.filesystem.*;\r\n\timport flash.events.*;\r\n\timport flash.geom.Point;\r\n\r\n\tpublic class GetXtion2DPoint\r\n\t{\r\n\r\n\t\tprivate var _process:NativeProcess;\r\n\t\t\r\n\t\tpublic var xtionPoint:Point = new Point();\r\n\t\tpublic var msg:String = &quot;&quot;;\r\n\t\t\r\n\t\tpublic function GetXtion2DPoint()\r\n\t\t{\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\tinit();\r\n\t\t\t}\r\n\t\t\tcatch (e:Error)\r\n\t\t\t{\r\n\t\t\t\ttrace(e);\r\n\t\t\t}\r\n\t\t\ttrace(NativeProcess.isSupported);\r\n\t\t}\r\n\t\t\r\n\t\tprivate function init():void\r\n\t\t{\r\n\t\t\tvar info:NativeProcessStartupInfo = new NativeProcessStartupInfo();\r\n\t\t\tvar file:File = File.applicationDirectory.resolvePath(&quot;bin\/start.sh&quot;);\r\n\r\n\t\t\tinfo.executable = file;\r\n\r\n\t\t\tvar args:Vector.&lt;String&gt; = new Vector.&lt;String&gt;();\r\n\t\t\tinfo.arguments = args;\r\n\r\n\t\t\t_process = new NativeProcess();\r\n\t\t\t_process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, outputHandler);\r\n\t\t\t_process.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, progressHandler);\r\n\t\t\t_process.start(info);\r\n\r\n\t\t}\r\n\t\t\r\n\t\tprivate function outputHandler(e:ProgressEvent):void\r\n\t\t{\r\n\t\t\tvar data:String = e.target.standardOutput.readUTFBytes(_process.standardOutput.bytesAvailable);\r\n\t\t\tdataToPoint(data);\r\n\t\t}\r\n\r\n\t\tprivate function progressHandler(e:ProgressEvent):void\r\n\t\t{\r\n\t\t\ttrace(e);\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tprivate function dataToPoint(data:String):void\r\n\t\t{\r\n\t\t\tvar list:Array = data.split(&quot; &quot;);\r\n\r\n\t\t\tvar p:Point = new Point(0,0);\r\n\t\t\tif (list.length &gt; 1)\r\n\t\t\t{\r\n\t\t\t\tp.x = int(list[0]);\r\n\t\t\t\tp.y = int(list[1]);\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tmsg = p.toString();\r\n\t\t\txtionPoint = p;\r\n\t\t}\r\n\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>Xtion\uff08OpenNI\uff09\u5074\u306e\u30b3\u30fc\u30c9\u306f\u3001OpenIN \u306e\u30b5\u30f3\u30d7\u30eb\u306b\u3042\u308b\u300cNiHandTracker\uff08NiHandTracker.cpp \u306e DisplayPostDraw \u95a2\u6570\uff09\u300d\u3092\u4e00\u90e8\u66f8\u304d\u76f4\u3057\u3066\u4f7f\u7528\u3057\u307e\u3057\u305f\u3002<br \/>\n\u66f8\u304d\u76f4\u3057\u305f\u90e8\u5206\u306f\u3053\u3061\u3089<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">void HandViewer::DisplayPostDraw()\r\n{\r\n\ttypedef TrailHistory\t\t\tHistory;\r\n\ttypedef History::ConstIterator\tHistoryIterator;\r\n\ttypedef History::Trail\t\t\tTrail;\r\n\ttypedef Trail::ConstIterator\tTrailIterator;\r\n\r\n\tstatic const float colours[][3] =\r\n\t{\r\n\t\t{ 0.5f, 0.5f, 0.5f},\r\n\t\t{ 0.0f, 1.0f, 0.0f},\r\n\t\t{ 0.0f, 0.5f, 1.0f},\r\n\t\t{ 1.0f, 1.0f, 0.0f},\r\n\t\t{ 1.0f, 0.5f, 0.0f},\r\n\t\t{ 1.0f, 0.0f, 1.0f}\r\n\t};\r\n\tconst TrailHistory&amp;\thistory = m_HandTracker.GetHistory();\r\n\r\n\t\/\/ History points coordinates buffer\r\n\tXnFloat\tcoordinates[3 * MAX_HAND_TRAIL_LENGTH];\r\n\r\n\tconst HistoryIterator\thend = history.end();\r\n\tfor(HistoryIterator\t\thit = history.begin(); hit != hend; ++hit)\r\n\t{\r\n\r\n\t\t\/\/ Dump the history to local buffer\r\n\t\tint\t\t\t\tnumpoints = 0;\r\n\t\tconst Trail&amp;\ttrail = hit.GetTrail();\r\n\r\n\t\tconst TrailIterator\ttend = trail.end();\r\n\t\tfor(TrailIterator\ttit = trail.begin(); tit != tend; ++tit)\r\n\t\t{\r\n\t\t\tXnPoint3D\tpoint = *tit;\r\n\t\t\tm_depth.ConvertRealWorldToProjective(1, &amp;point, &amp;point);\r\n\t\t\tScalePoint(point);\r\n\t\t\tcoordinates[numpoints * 3] = point.X;\r\n\t\t\tcoordinates[numpoints * 3 + 1] = point.Y;\r\n\t\t\tcoordinates[numpoints * 3 + 2] = 0;\r\n\t\t\t++numpoints;\r\n\t\t}\r\n\t\tassert(numpoints &lt;= MAX_HAND_TRAIL_LENGTH);\r\n\r\n\t\t\/\/ Draw the hand trail history\r\n\t\tXnUInt32 nColor = hit.GetKey() % LENGTHOF(colours);\r\n\t\tglColor4f(colours[nColor][0],\r\n\t\t\tcolours[nColor][1],\r\n\t\t\tcolours[nColor][2],\r\n\t\t\t1.0f);\r\n\t\tglPointSize(2);\r\n\t\tglVertexPointer(3, GL_FLOAT, 0, coordinates);\r\n\t\tglDrawArrays(GL_LINE_STRIP, 0, numpoints);\r\n\t\t\/\/ Current point as a larger dot\r\n\t\tglPointSize(8);\r\n\t\tglDrawArrays(GL_POINTS, 0, 1);\r\n\t\tglFlush();\r\n\t}\r\n\tprintf(&quot;%f %f\\n&quot;,coordinates[3], coordinates[4]); \/\/ \u5ea7\u6a19\u3092\u51fa\u529b\r\n\tfflush(stdout); \/\/ \u51fa\u529b\u30d0\u30c3\u30d5\u30a1\u3092\u524a\u9664\r\n}\r\n<\/pre>\n<p>\u3053\u308c\u3067\u3001NiHandTracker \u304b\u3089\u51fa\u529b\u3055\u308c\u308b\u5024\u3092 Flash \u5074\u3067\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3093\u306a\u3053\u3093\u306a\u3067\u3001\u3053\u3046\u3044\u3046\u30e2\u30fc\u30b7\u30e7\u30f3\u30ad\u30e3\u30d7\u30c1\u30e3\u30c7\u30d0\u30a4\u30b9\u3067\u904a\u3076\u306e\u306f\u7d50\u69cb\u697d\u3057\u3044\u306e\u3067\u3001\u4eca\u5f8c\u3082\u30d2\u30de\u3092\u898b\u3064\u3051\u3066 Xtion \u3067\u904a\u3093\u3067\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fwww.digifie.jp%2Fblog%2Farchives%2F565&t=Xtion%20%E3%81%A8%20Flash%20%E3%82%92%E3%81%8F%E3%81%A3%E3%81%A4%E3%81%91%E3%81%A6%E3%81%A1%E3%82%87%E3%81%A3%E3%81%A8%E3%81%A0%E3%81%91%E9%81%8A%E3%82%93%E3%81%A7%E3%81%BF%E3%81%9F' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/www.digifie.jp\/blog\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.digifie.jp\/blog\/archives\/565\" data-text=\"Xtion \u3068 Flash \u3092\u304f\u3063\u3064\u3051\u3066\u3061\u3087\u3063\u3068\u3060\u3051\u904a\u3093\u3067\u307f\u305f\" data-via=\"LLC DigiFie\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4ed5\u4e8b\u304c\u30a2\u30ec\u3067\u5168\u7136\u89e6\u308c\u3066\u306a\u304b\u3063\u305f Xtion\uff08\u4f8b\u306eKinect\u306e\u3061\u3063\u3053\u3044\u30e4\u30c4\u306d\uff09\u3092\u3001OpenNI\uff08NiHandTracker\uff09\u3068 Flash\uff08AIR 2.0 NativeProcess)\uff09\u3067\u7d50\u5408\u3055\u305b\u3066\u3001\u4ee5\u524d Wonderf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,29],"tags":[],"_links":{"self":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/565"}],"collection":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/comments?post=565"}],"version-history":[{"count":6,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/565\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/posts\/565\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/media?parent=565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/categories?post=565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.digifie.jp\/blog\/wp-json\/wp\/v2\/tags?post=565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}