{"id":537,"date":"2011-12-24T08:17:38","date_gmt":"2011-12-23T23:17:38","guid":{"rendered":"http:\/\/blog.hi-farm.net\/?p=537"},"modified":"2016-12-07T19:19:27","modified_gmt":"2016-12-07T10:19:27","slug":"openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/","title":{"rendered":"OpenNI\u3092Openframeworks\u3067\u4f7f\u3046"},"content":{"rendered":"<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"OpenNI\u3092Openframeworks\u3067\u4f7f\u3046\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" data-text=\"OpenNI\u3092Openframeworks\u3067\u4f7f\u3046\" data-via=\"mmlemon\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" colorscheme=\"light\" ><\/fb:send><\/div>\n            <div class=\"wsbl_tumblr\"><a href=\"\/\/www.tumblr.com\/share?v=3&u=http%3A%2F%2Fblog.hi-farm.net%2Fen%2F2011%2F12%2F24%2Fopenni%25e3%2582%2592openframeworks%25e3%2581%25a7%25e4%25bd%25bf%25e3%2581%2586%2F&t=OpenNI%E3%82%92Openframeworks%E3%81%A7%E4%BD%BF%E3%81%86\" title=\"Share on Tumblr\" style=\"display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('\/\/platform.tumblr.com\/v1\/share_1.png') top left no-repeat transparent;\">Share on Tumblr<\/a><\/div>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"inline\" href=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" width=\"250\"><\/g:plusone><\/div>\n            <div class=\"wsbl_evernote\">[`evernote` not found]<\/div>\n            <div class=\"wsbl_line\"><a href='http:\/\/line.me\/R\/msg\/text\/?OpenNI%E3%82%92Openframeworks%E3%81%A7%E4%BD%BF%E3%81%86%0D%0Ahttp%3A%2F%2Fblog.hi-farm.net%2Fen%2F2011%2F12%2F24%2Fopenni%25e3%2582%2592openframeworks%25e3%2581%25a7%25e4%25bd%25bf%25e3%2581%2586%2F' title='LINE\u3067\u9001\u308b' rel=nofollow class='wp_social_bookmarking_light_a' ><img src='http:\/\/blog.hi-farm.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/line88x20.png' alt='LINE\u3067\u9001\u308b' title='LINE\u3067\u9001\u308b' width='88' height='20' class='wp_social_bookmarking_light_img' \/><\/a><\/div>\n            <div class=\"wsbl_pocket\"><a href=\"https:\/\/getpocket.com\/save\" class=\"pocket-btn\" data-lang=\"en\" data-save-url=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\" data-pocket-count=\"none\" data-pocket-align=\"left\" >Pocket<\/a><script type=\"text\/javascript\">!function(d,i){if(!d.getElementById(i)){var j=d.createElement(\"script\");j.id=i;j.src=\"https:\/\/widgets.getpocket.com\/v1\/j\/btn.js?v=1\";var w=d.getElementById(i);d.body.appendChild(j);}}(document,\"pocket-btn-js\");<\/script><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n<div style=\"float: right; margin-left: 10px;\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-count=\"vertical\" data-url=\"http:\/\/blog.hi-farm.net\/en\/2011\/12\/24\/openni%e3%82%92openframeworks%e3%81%a7%e4%bd%bf%e3%81%86\/\">Tweet<\/a><\/div>\n<p>\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u306f<a href=\"http:\/\/atnd.org\/events\/22725\" target=\"_blank\">OpenNI Advent Calendar 2011<\/a> : ATND\u306e12\u670823\u65e5\u5206\u3067\u3059!!<\/p>\n<p><img src=\"http:\/\/openframeworks.cc\/images\/ofw-logo.png\"\/><\/p>\n<p>Openframeworks\u3067OpenNI\u306e\u9023\u643a\u306b\u3064\u3044\u3066\u66f8\u304d\u307e\u3059\u3002<\/p>\n<p>Openframeworks ( <a href=\"http:\/\/www.openframeworks.cc\/\" target=\"_blank\">http:\/\/www.openframeworks.cc\/<\/a> )\uff08\u4ee5\u4e0b\u3001oF\uff09\u3068\u306f\u3001\u30e1\u30c7\u30a3\u30a2\u30a2\u30fc\u30c8\u754c\u9688\u3067\u4f7f\u308f\u308c\u3066\u3044\u308b\u63cf\u753b\u3084\u52d5\u753b\u306e\u6271\u3044\u3084\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u66f8\u304d\u65b9\u304cprocessing\u3063\u307d\u304f\u4f5c\u3089\u308c\u3066\u3044\u308b\u3001\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u52d5\u4f5c\u3059\u308bC++\u306e\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3059\u3002<br \/>\noF\u306f\u305f\u304f\u3055\u3093\u306e\u6709\u5fd7\u306b\u3088\u308a\u69d8\u3005\u306a\u30a2\u30c9\u30aa\u30f3\u304c\u914d\u5e03\u3055\u308c\u3066\u304a\u308a\u3001\u305d\u308c\u3092\u4f7f\u3046\u3068\u30bd\u30b1\u30c3\u30c8\u3084OSC\u3001OpenCV\u306a\u3069\u306e\u6a5f\u80fd\u3092\u7c21\u5358\u306b\u4f7f\u3046\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>oF\u3067\u4f7f\u3048\u308b\u30a2\u30c9\u30aa\u30f3<\/h2>\n<p>oF\u3067\u4f7f\u3048\u308bKinect\u95a2\u9023\u306e\u30a2\u30c9\u30aa\u30f3\u304c\u3044\u304f\u3064\u304b\u3001\u4e0b\u8a18\u306e\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u30fbofxKinect\uff1a ( <a href=\"https:\/\/github.com\/ofTheo\/ofxKinect\" target=\"_blank\">https:\/\/github.com\/ofTheo\/ofxKinect<\/a> )<br \/>\n\u2192\u6df1\u5ea6\u60c5\u5831\u3068RGB\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u30b9\u30b1\u30eb\u30c8\u30f3\u306e\u53d6\u5f97\u6a5f\u80fd\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u30fbofxOpenNI\uff1a( <a href=\"https:\/\/github.com\/gameoverhack\/ofxOpenNI\" target=\"_blank\">https:\/\/github.com\/gameoverhack\/ofxOpenNI<\/a> )<br \/>\n\u2192OpenNI\u3092oF\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b\u4f5c\u3063\u305f\u3082\u306e\u3002<\/p>\n<p>\u305f\u3060\u3001OpenNI\u81ea\u4f53\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u304c\u65e9\u3044\u4e8b\u3082\u3042\u308b\u306e\u3067\u4eca\u56de\u306f\u666e\u901a\u306eOpenNI\u3092oF\u3067\u4f7f\u3046\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<h2>oF\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b<\/h2>\n<p>oF\u306eWeb\u30b5\u30a4\u30c8\u304b\u3089\u5fc5\u8981\u306a\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u79c1\u306e\u5834\u5408\u306fMac\u306a\u306e\u3067osx\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/www.openframeworks.cc\/download\/\" target=\"_blank\">http:\/\/www.openframeworks.cc\/download\/<\/a><\/p>\n<p>\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3059\u308b\u3068\u4e0b\u8a18\u306e\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>add ons \/ oF\u306e\u30a2\u30c9\u30aa\u30f3\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<li>apps \/ \u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u304c\u305f\u304f\u3055\u3093\u5165\u3063\u3066\u3044\u307e\u3059\u3002\u5b9f\u969b\u306boF\u3067\u30a2\u30d7\u30ea\u3092\u958b\u767a\u3059\u308b\u5834\u5408\u306f\u3053\u306e\u4e2d\u306eexamples\/EmptyExample\u3092\u30d9\u30fc\u30b9\u306b\u3057\u307e\u3059\u3002<\/li>\n<li>libs \/ oF\u81ea\u4f53\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3084oF\u304c\u4f7f\u3063\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<p><a rel=\"lightbox\" href=\"http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/of_directory.png\"><img loading=\"lazy\" src=\"http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/of_directory-155x300.png\" alt=\"of_directory\" title=\"of_directory\" width=\"155\" height=\"300\" class=\"aligncenter size-medium wp-image-549\" srcset=\"http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/of_directory-155x300.png 155w, http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/of_directory.png 345w\" sizes=\"(max-width: 155px) 100vw, 155px\" \/><\/a><\/p>\n<p>\u3067\u306f\u3001oF\u306e\u57fa\u672c\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306b EmptyExample\u3092\u307f\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>testApp.cpp\u3092\u307f\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u306f\u3058\u3081\u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u30e1\u30bd\u30c3\u30c9\u306e\u5b9f\u88c5\u3092\u9032\u3081\u3066\u958b\u767a\u3092\u9032\u3081\u307e\u3059\u3002<\/p>\n<dl style=\"background-color: #ccc;\">\n<dt>setup() \uff1a<\/dt>\n<dd>\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u8d77\u52d5\u6642\u3042\u308b\u3044\u306fnew\u3057\u305f\u76f4\u5f8c\u306b\u547c\u3070\u308c\u308b\u95a2\u6570\u3067\u3059\u3002\u521d\u671f\u5316\u306a\u3069\u306f\u3053\u3053\u3067\u884c\u3044\u307e\u3059\u3002<\/dd>\n<dt>update()\uff1a<\/dt>\n<dd>\u6bce\u30d5\u30ec\u30fc\u30e0\u6bcedraw()\u306e\u524d\u306b\u547c\u3070\u308c\u307e\u3059\u3002\u3053\u3053\u3067\u30c7\u30fc\u30bf\u3084\u5ea7\u6a19\u8a08\u7b97\u306e\u66f4\u65b0\u3092\u3059\u308b\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/dd>\n<dt>draw()\uff1a<\/dt>\n<dd>\u6bce\u30d5\u30ec\u30fc\u30e0\u6bce\u3001update()\u306e\u5f8c\u306b\u547c\u3070\u308c\u307e\u3059\u3002\u3053\u3053\u306b\u306f\u63cf\u753b\u51e6\u7406\u3092\u304b\u304d\u307e\u3059\u3002<\/dd>\n<\/dl>\n<p>\u57fa\u672c\u7684\u306b\u306f\u3053\u308c\u3089\u3092\u4f7f\u3046\u306e\u3067\u3059\u304c\u3001\u30de\u30a6\u30b9\u3084\u30ad\u30fc\u30dc\u30fc\u30c9\u306e\u30e6\u30fc\u30b6\u30fc\u5165\u529b\u306b\u3082\u5bfe\u5fdc\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<dl>\n<dt>keyPressed, keyReleased\uff1a<\/dt>\n<dd>\u30ad\u30fc\u30dc\u30fc\u30c9\u3092\u62bc\u3057\u305f\u3068\u304d\u3001\u96e2\u3057\u305f\u3068\u304d\u306b\u547c\u3070\u308c\u307e\u3059\u3002<\/dd>\n<dt>mouseMoved, mouseDragged, mousePressed, mouseReleased\uff1a<\/dt>\n<dd>\u30de\u30a6\u30b9\u306e\u79fb\u52d5\u3001\u30c9\u30e9\u30c3\u30b0\u3001\u30de\u30a6\u30b9\u30c0\u30a6\u30f3\u3001\u30de\u30a6\u30b9\u3092\u96e2\u3057\u305f\u6642\u306b\u547c\u3070\u308c\u307e\u3059\u3002<\/dd>\n<\/dl>\n<h2>OpenNI\u306e\u8a2d\u5b9a\uff1a<\/h2>\n<h3>\u6e96\u5099<\/h3>\n<p>\u4eca\u56de\u306f\u3068\u306b\u304b\u304f\u7c21\u5358\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u4e8b\u3092\u8003\u3048\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305a\u3001OpenNI\u306eInclude\u3068Lib\u30d5\u30a9\u30eb\u30c0\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u76f4\u4e0b\u306b\u201dOpenNI\u201d\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u3092\u4f5c\u6210\u3057\u3001\u305d\u3053\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u30d8\u30c3\u30c0\u30fc\u53c2\u7167\u30d1\u30b9\u3068\u30e9\u30a4\u30d6\u30e9\u30ea\u30d1\u30b9\u306e\u8a2d\u5b9a\u3092\u3057\u307e\u3059\u3002<br \/>\n\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u8a2d\u5b9a\u306e \u201cBuild Settings\u201d \u2192 \u201cSearch Paths\u201d\u306e<\/p>\n<p style=\"background-color: #ddd;\">\nHeader Search Paths\u306b\u4ee5\u4e0b\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n&#8220;$(SRCROOT)\/..\/OpenNI\/Include<br \/>\nLibrary Search Paths\u306b\u4ee5\u4e0b\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br \/>\n&#8220;$(SRCROOT)\/..\/OpenNI\/Lib\n<\/p>\n<p>\u203b\u8a2d\u5b9a\u5f8c\u3001\u81ea\u52d5\u7684\u306b\u5225\u306e\u9805\u76ee\u306b\u5909\u66f4\u3055\u308c\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u30d3\u30eb\u30c9\u304c\u901a\u308c\u3070\u554f\u984c\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u79c1\u306e\u74b0\u5883\u3067\u306f\u3001<br \/>\nHEADER_SEARCH_PATHS_QUOTED_FOR_TARGET_1<br \/>\nLIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1<br \/>\n\u306e\u9805\u76ee\u304c\u8ffd\u52a0\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u3055\u3066\u3001\u305d\u308c\u3067\u306fOpenNI\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u3087\u3046\u3002NiSimpleViewer\u3092\u30d1\u30af\u3001\u3001\u3044\u3084\u3082\u3068\u306b\u3057\u3066\u3001\u6df1\u5ea6\u60c5\u5831\u3092\u8868\u793a\u3055\u305b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br \/>\n\u8868\u793a\u306b\u306foFTexture\u30af\u30e9\u30b9\u3092\u4f7f\u3044\u3001\u30c6\u30af\u30b9\u30c1\u30e3\u3068\u3057\u3066\u8868\u793a\u3055\u305b\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306f\u7c21\u5358\u306b\u79fb\u690d\u3059\u308b\u305f\u3081\u3001NiSimpleViewer\u304b\u3089\u30b3\u30d4\u30da\u3059\u308b\u4e8b\u306b\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305a\u3001<\/p>\n<h4>testApp.h<\/h4>\n<p>testApp.h\u306b\u4e0b\u8a18\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;XnCppWrapper.h&gt;\r\nusing namespace xn;\r\n<\/pre>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/---------------------------------------------------------------------------\r\n\/\/ Defines\r\n\/\/---------------------------------------------------------------------------\r\n#define SAMPLE_XML_PATH &quot;..\/..\/..\/data\/SamplesConfig.xml&quot;\r\n\r\n#define DISPLAY_MODE_DEPTH\t\t2\r\n#define DEFAULT_DISPLAY_MODE\tDISPLAY_MODE_DEPTH\r\n\r\n#define MAX_DEPTH 10000\r\n<\/pre>\n<p>SamplesConfig.xml\u306fbin\/data\/\u4ee5\u4e0b\u306b\u8a2d\u7f6e\u3057\u305f\u305f\u3081\u3001<br \/>\nSAMPLE_XML_PATH\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>&#8212;&#8212;-<\/p>\n<h4>testApp.cpp<\/h4>\n<p>testApp.cpp\u306b\u201dGlobals\u201d\u306e\u5185\u5bb9\u3092\u3082\u3068\u306b\u79fb\u690d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/---------------------------------------------------------------------------\r\n\/\/ Globals\r\n\/\/---------------------------------------------------------------------------\r\nfloat g_pDepthHist[MAX_DEPTH];\r\nXnRGB24Pixel* g_pTexMap = NULL;\r\nunsigned int g_nTexMapX = 0;\r\nunsigned int g_nTexMapY = 0;\r\n\r\nunsigned int g_nViewState = DEFAULT_DISPLAY_MODE;\r\n\r\nContext g_context;\r\nScriptNode g_scriptNode;\r\nDepthGenerator g_depth;\r\nDepthMetaData g_depthMD;\r\n<\/pre>\n<p>&#8212;&#8212;&#8211;<br \/>\nNiSimpleViewer\u306emain\u95a2\u6570\u304c\u521d\u671f\u5316\u306b\u95a2\u3059\u308b\u5185\u5bb9\u306a\u306e\u3067\u3001setup\u306b\u79fb\u690d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\tXnStatus rc;\r\n\t\r\n\tEnumerationErrors errors;\r\n\trc = g_context.InitFromXmlFile(SAMPLE_XML_PATH, g_scriptNode, &amp;errors);\r\n\tif (rc == XN_STATUS_NO_NODE_PRESENT)\r\n\t{\r\n\t\tXnChar strError[1024];\r\n\t\terrors.ToString(strError, 1024);\r\n\t\tprintf(&quot;%s\\n&quot;, strError);\r\n\t\treturn ;\r\n\t}\r\n\telse if (rc != XN_STATUS_OK)\r\n\t{\r\n\t\tprintf(&quot;Open failed: %s\\n&quot;, xnGetStatusString(rc));\r\n\t\treturn;\r\n\t}\r\n\t\r\n\trc = g_context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_depth);\r\n\tif (rc != XN_STATUS_OK)\r\n\t{\r\n\t\tprintf(&quot;No depth node exists! Check your XML.&quot;);\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tg_depth.GetMetaData(g_depthMD);\r\n\t\r\n\t\/\/ Texture map init\r\n\tg_nTexMapX = (((unsigned short)(g_depthMD.FullXRes()-1) \/ 512) + 1) * 512;\r\n\tg_nTexMapY = (((unsigned short)(g_depthMD.FullYRes()-1) \/ 512) + 1) * 512;\r\n\tg_pTexMap = (XnRGB24Pixel*)malloc(g_nTexMapX * g_nTexMapY * sizeof(XnRGB24Pixel));\r\n<\/pre>\n<p>&#8212;&#8212;-<br \/>\nsetup\u95a2\u6570\u306e\u6700\u5f8c\u306bofTexture\u30af\u30e9\u30b9\u3068ofTexture\u3067\u8868\u793a\u3055\u305b\u308b\u305f\u3081\u306eunsigned char*\u306e\u30c7\u30fc\u30bf\u3092\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\tpixels = (unsigned char*)malloc(640*480*3*sizeof(unsigned char));\r\n\ttex.allocate(640, 480, GL_RGB);\r\n<\/pre>\n<p>&#8212;&#8212;-<br \/>\nOpenNI\u3067\u306e\u30c7\u30fc\u30bf\u3092\u66f4\u65b0\u3059\u308b\u51e6\u7406\u3092update\u306b\u79fb\u690d\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\tXnStatus rc = XN_STATUS_OK;\r\n\t\r\n\t\/\/ Read a new frame\r\n\trc = g_context.WaitAnyUpdateAll();\r\n\tif (rc != XN_STATUS_OK)\r\n\t{\r\n\t\tprintf(&quot;Read failed: %s\\n&quot;, xnGetStatusString(rc));\r\n\t\treturn;\r\n\t}\r\n\t\r\n\tg_depth.GetMetaData(g_depthMD);\r\n\t\/\/g_image.GetMetaData(g_imageMD);\r\n\t\r\n\tconst XnDepthPixel* pDepth = g_depthMD.Data();\r\n\t\r\n\t\/\/ Calculate the accumulative histogram (the yellow display...)\r\n\txnOSMemSet(g_pDepthHist, 0, MAX_DEPTH*sizeof(float));\r\n\t\r\n\tunsigned int nNumberOfPoints = 0;\r\n\tfor (XnUInt y = 0; y &lt; g_depthMD.YRes(); ++y)\r\n\t{\r\n\t\tfor (XnUInt x = 0; x &lt; g_depthMD.XRes(); ++x, ++pDepth)\r\n\t\t{\r\n\t\t\tif (*pDepth != 0)\r\n\t\t\t{\r\n\t\t\t\tg_pDepthHist[*pDepth]++;\r\n\t\t\t\tnNumberOfPoints++;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tfor (int nIndex=1; nIndex&lt;MAX_DEPTH; nIndex++)\r\n\t{\r\n\t\tg_pDepthHist[nIndex] += g_pDepthHist[nIndex-1];\r\n\t}\r\n\tif (nNumberOfPoints)\r\n\t{\r\n\t\tfor (int nIndex=1; nIndex&lt;MAX_DEPTH; nIndex++)\r\n\t\t{\r\n\t\t\tg_pDepthHist[nIndex] = (unsigned int)(256 * (1.0f - (g_pDepthHist[nIndex] \/ nNumberOfPoints)));\r\n\t\t}\r\n\t}\r\n\t\r\n\txnOSMemSet(g_pTexMap, 0, g_nTexMapX*g_nTexMapY*sizeof(XnRGB24Pixel));\r\n\t\r\n\t\/\/ check if we need to draw depth frame to texture\r\n\tconst XnDepthPixel* pDepthRow = g_depthMD.Data();\r\n\tXnRGB24Pixel* pTexRow = g_pTexMap + g_depthMD.YOffset() * g_nTexMapX;\r\n\t\r\n\tfor (XnUInt y = 0; y &lt; g_depthMD.YRes(); ++y)\r\n\t{\r\n\t\tconst XnDepthPixel* pDepth = pDepthRow;\r\n\t\tXnRGB24Pixel* pTex = pTexRow + g_depthMD.XOffset();\r\n\t\t\r\n\t\tfor (XnUInt x = 0; x &lt; g_depthMD.XRes(); ++x, ++pDepth, ++pTex)\r\n\t\t{\r\n\t\t\tint idx = (x + y * g_depthMD.XRes()) * 3;\r\n\t\t\tif (*pDepth != 0)\r\n\t\t\t{\r\n\t\t\t\tint nHistValue = g_pDepthHist[*pDepth];\r\n\t\t\t\t\r\n\t\t\t\tpixels[idx] = nHistValue;\r\n\t\t\t\tpixels[idx+1] = nHistValue;\r\n\t\t\t\tpixels[idx+2] = nHistValue;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpixels[idx] = 0;\r\n\t\t\t\tpixels[idx+1] = 0;\r\n\t\t\t\tpixels[idx+2] = 0;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tpDepthRow += g_depthMD.XRes();\r\n\t\tpTexRow += g_nTexMapX;\r\n\t}\r\n\t\r\n\ttex.loadData(pixels, 640, 480, GL_RGB);\r\n<\/pre>\n<p>ofTexture\u306eloadData\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u3001\u6df1\u5ea6\u30c7\u30fc\u30bf\u3092\u30c6\u30af\u30b9\u30c1\u30e3\u3068\u3057\u3066\u8aad\u307f\u8fbc\u307e\u305b\u307e\u3059\u3002<br \/>\n&#8212;&#8212;<br \/>\n\u6700\u5f8c\u306bdraw\u30e1\u30bd\u30c3\u30c9\u306bofTexeture\u306edraw\u3092\u4f7f\u3063\u3066\u5b9f\u969b\u306b\u63cf\u753b\u3057\u307e\u3059\u3002<\/p>\n<p>\u5f15\u6570\u306f\u3001x\u5ea7\u6a19\u3001y\u5ea7\u6a19\u3001\u5e45\u3001\u9ad8\u3055\u3092\u793a\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n&#8212;&#8211;<\/p>\n<p>\u3053\u308c\u3067\u30d3\u30eb\u30c9\u3059\u308b\u3068\u8868\u793a\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u305f\u304f\u3055\u3093\u306e\u8b66\u544a\u306f\u3042\u308a\u307e\u3059\u304c\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u5185\u90e8\u7684\u306a\u3082\u306e\u3082\u3042\u308b\u306e\u3067\u7121\u8996\u3059\u308b\u4e8b\u306b\u3057\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" src=\"http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/advant_of-300x229.png\" alt=\"advant_of\" title=\"advant_of\" width=\"300\" height=\"229\" class=\"aligncenter size-medium wp-image-538\" srcset=\"http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/advant_of-300x229.png 300w, http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/advant_of-1024x783.png 1024w, http:\/\/blog.hi-farm.net\/wp-content\/uploads\/2011\/12\/advant_of.png 1025w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u30d5\u30a1\u30a4\u30eb\u4e00\u5f0f\u3092\u3053\u3061\u3089\u306b\u30a2\u30c3\u30d7\u3057\u307e\u3057\u305f\u306e\u3067\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u8a66\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<a href=\"https:\/\/github.com\/mmlemon\/OpenNI_Advent_oFSample\" target=\"_blank\">https:\/\/github.com\/mmlemon\/OpenNI_Advent_oFSample<\/a><\/p>\n<p>\u203bOpenNI\u306f1.4.0.2\u3001oF\u306f007\u3067\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tweet \u3053\u306e\u30a8\u30f3\u30c8\u30ea\u306fOpenNI Advent Calendar 2011 : ATND\u306e12\u670823\u65e5\u5206\u3067\u3059!! Openframeworks\u3067OpenNI\u306e\u9023\u643a\u306b\u3064\u3044\u3066\u66f8\u304d\u307e\u3059\u3002 Openframeworks ( &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[213],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/537"}],"collection":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/comments?post=537"}],"version-history":[{"count":25,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":902,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/posts\/537\/revisions\/902"}],"wp:attachment":[{"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/media?parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/categories?post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.hi-farm.net\/en\/wp-json\/wp\/v2\/tags?post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}