title: how to connect xBox kinect to opencv in ubuntu?
body: <p>I want to work kinect with openCV in ubuntu (14.04) by C++.
  I install openni and libfreenect.</p>
  
  <p>when I type <strong>lsusb</strong> in terminal, the system answer text following to me.</p>
  
  <pre><code>Bus 003 Device 005: ID 045e:02ae Microsoft Corp. Xbox NUI Camera
  Bus 003 Device 003: ID 045e:02b0 Microsoft Corp. Xbox NUI Motor
  Bus 003 Device 004: ID 045e:02ad Microsoft Corp. Xbox NUI Audio
  </code></pre>
  
  <p>when I type <strong>freenect-glview</strong> in terminal, the system answer text following to me.</p>
  
  <pre><code>Kinect camera test
  Number of devices found: 1
  </code></pre>
  
  <p>and the system shows RGB and depth.</p>
  
  <p>also,I activated openni when cmake opencv (-D WITH_OPENNI:ON) and after  system shows:</p>
  
  <pre><code>openni: yes
  prime-sensor-kinect : yes
  </code></pre>
  
  <p>I am compiling code by :</p>
  
  <pre><code>g++ -o test1   test1.cpp `pkg-config opencv --cflags --libs` 
  </code></pre>
  
  <p>but when I am runing code, system error:</p>
  
  <pre><code>CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create 
  </code></pre>
  
  <p>any node of the requested type!</p>
  
  <p>code:</p>
  
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include "opencv2/opencv.hpp"
  #include &lt;vector&gt;
  #include &lt;stdio.h&gt;
  using namespace cv;
  int main(int, char**)
  {
      VideoCapture cap(CV_CAP_OPENNI); // open the default camera
      if(!cap.isOpened())  // check if we succeeded
          return -1;
  
      Mat edges;
      namedWindow("edges",1);
      for(;;)
      {
          Mat frame;
          cap &gt;&gt; frame; // get a new frame from camera
          cvtColor(frame, edges, CV_BGR2GRAY);
          GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
          Canny(edges, edges, 0, 30, 3);
          imshow("edges", edges);
          if(waitKey(30) &gt;= 0) break;
      }
      // the camera will be deinitialized automatically in VideoCapture destructor
      return 0;
  }
  </code></pre>
  
  <p>and when running python code, system error:</p>
  
  <pre><code>CvCapture_OpenNI::CvCapture_OpenNI : Failed to enumerate production trees: Can't create any node of the requested type!
  0.0
  Unable to Retrieve Disparity Map from camera
  </code></pre>
  
  <p>code python :</p>
  
  <pre><code>import cv2
  import cv2.cv as cv
  
  capture = cv2.VideoCapture(cv.CV_CAP_OPENNI)
  capture.set(cv.CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE, cv.CV_CAP_OPENNI_VGA_30HZ)
  
  print capture.get(cv.CV_CAP_PROP_OPENNI_REGISTRATION)
  
  while True:
      if not capture.grab():
          print "Unable to Grab Frames from camera"
          break
      okay1, depth_map = capture.retrieve(0,cv.CV_CAP_OPENNI_DEPTH_MAP)
      if not okay1:
          print "Unable to Retrieve Disparity Map from camera"
          break
      okay2, gray_image = capture.retrieve(0,cv.CV_CAP_OPENNI_GRAY_IMAGE)
      if not okay2:
          print "Unable to retrieve Gray Image from device"
          break
      cv2.imshow("depth camera", depth_map)
      cv2.imshow("rgb camera", gray_image)
      if cv2.waitKey(10) == 27:
          break
  cv2.destroyAllWindows()
  capture.release()
  </code></pre>
  
  <p>opencv doesn't recognize kinect as an input device.How to solve this problem?</p>
  
  <p>I am sorry for bad writing because my English language is bad.  </p>