{"id":308,"date":"2012-03-29T11:44:30","date_gmt":"2012-03-29T17:44:30","guid":{"rendered":"http:\/\/csmartonline.com\/blog\/?p=308"},"modified":"2014-06-17T11:38:05","modified_gmt":"2014-06-17T17:38:05","slug":"compile-openni-for-kinect-motor-control-on-linux","status":"publish","type":"post","link":"http:\/\/csmartonline.com\/blog\/2012\/03\/29\/compile-openni-for-kinect-motor-control-on-linux\/","title":{"rendered":"Compile OpenNI for Kinect Motor Control on Linux"},"content":{"rendered":"<p>First, make sure you have everything you need to compile OpenNI (if you don&#8217;t already have a Java JDK, you will need to install one):<\/p>\n<pre class=\"snippet-code\">sudo apt-get install git-core cmake freeglut3-dev pkg-config \\\r\n build-essential libxmu-dev libxi-dev libusb-1.0-0-dev \\\r\n doxygen graphviz mono-complete<\/pre>\n<p>Next, make a directory to store the build in, then clone the OpenNI source from GitHub:<\/p>\n<pre class=\"snippet-code\">mkdir ~\/kinect\r\ncd ~\/kinect\r\ngit clone https:\/\/github.com\/OpenNI\/OpenNI.git<\/pre>\n<p>Due to a bug in the OpenNI driver, you cannot use custom USB control types on Linux and Mac without first changing some lines in the XnUSBLinux.cpp file. Here&#8217;s how:<\/p>\n<pre class=\"snippet-code\">gedit ~\/kinect\/OpenNI\/Source\/OpenNI\/Linux\/XnUSBLinux.cpp<\/pre>\n<p>Search for the two lines that contain &#8220;XN_STATUS_USB_WRONG_CONTROL_TYPE&#8221;, comment them out and then insert &#8220;bmRequestType = nType;&#8221; just before them, as is in the following snippet:<\/p>\n<pre class=\"snippet-code\">\telse if (nType == XN_USB_CONTROL_TYPE_STANDARD)\r\n\t{\r\n\t\tbmRequestType = LIBUSB_REQUEST_TYPE_STANDARD;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tbmRequestType = nType;\r\n\t\t\/\/return (XN_STATUS_USB_WRONG_CONTROL_TYPE);\r\n\t}\r\n\t\r\n\tbmRequestType |= LIBUSB_ENDPOINT_IN;<\/pre>\n<p>The line numbers for this should be 761 and 819.<\/p>\n<p>Now compile OpenNI by using the RedistMaker script in the Platform\/Linux folder and install the binaries that are created by using the install script:<\/p>\n<pre class=\"snippet-code\">cd ~\/kinect\/OpenNI\/Platform\/Linux\/CreateRedist\/\r\nchmod +x RedistMaker\r\n.\/RedistMaker\r\ncd ..\/Redist\/OpenNI-Bin-Dev-Linux-x86-v1.5.2.23\/\r\nsudo .\/install.sh<\/pre>\n<p>That&#8217;s it! You should now have a working OpenNI installation that is compatible with my <a href=\"http:\/\/csmartonline.com\/blog\/2012\/03\/29\/kinect-motor-control-linux\/\" title=\"Kinect Motor Control (Linux)\">kinectmotorcontrol<\/a> program. If you want to install SensorKinect and NITE, this page should help you continue with that:<\/p>\n<p><a href=\"http:\/\/mitchtech.net\/ubuntukinect-openni-primesense\/\">http:\/\/mitchtech.net\/ubuntukinect-openni-primesense\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>First, make sure you have everything you need to compile OpenNI (if you don&#8217;t already have a Java JDK, you will need to install one): Next, make a directory to store the build in, then clone the OpenNI source from &hellip;<\/p>\n<p class=\"read-more\"><a href=\"http:\/\/csmartonline.com\/blog\/2012\/03\/29\/compile-openni-for-kinect-motor-control-on-linux\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[89],"tags":[],"class_list":["post-308","post","type-post","status-publish","format-standard","hentry","category-software"],"_links":{"self":[{"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/posts\/308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":19,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":412,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/412"}],"wp:attachment":[{"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/csmartonline.com\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}