2

I'm having trouble capturing video from an ASUS Xtion on an Nvidia Jetson TK1 using OpenCV (also on a laptop -- see update below). When I run the following code, I always get "Error."

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <iostream>

int main()
{
  cv::VideoCapture input;
  input.open(CV_CAP_OPENNI_ASUS);

  if(!input.isOpened())
    {
      std::cout << "Error.\n";
      return -1;
    }
}

I'm using OpenCV2, installed with the JetPack. I installed OpenNI2 following instructions here (built from source). I can run SimpleViewer and other programs just fine, so the Asus is communicating. Following Tutorial 2 here, I am able to load a video image in an OpenCV program from a file, but not read the Asus. Running lsusb shows that the device is active:

Bus 002 Device 002: ID 1d27:0601 ASUS 

I have successfully read from the Asus from within ROS.

I have seen this thread, but it does not help (I did incorporate the _ASUS for the open macro).

[UPDATE] I have since loaded openNI2 and OpenCV3 on an ubuntu laptop (14.04). Again, SimpleViewer works fine. The built in camera works fine (with input.open(0) to access the default camera). The only thing that doesn't work is reading the Asus from within an OpenCV program.

:grumble:

Does anyone have suggestions for what to try next? I'm sure I'm missing something obvious -- any debugging help appreciated.

Community
  • 1
  • 1
gcl8a
  • 41
  • 4
  • maybe it takes a while for the sensor to initialise ? Can you try something like this:```int main() { cv::Mat image0,image0Show; cv::VideoCapture input; input.open(CV_CAP_OPENNI_ASUS); while(true){ if( !input.grab() ){ cout << "can not grab images." << endl; return -1; }else if( input.retrieve( image0, CV_CAP_OPENNI_DEPTH_MAP ) ){ image0.convertTo( image0Show, CV_8UC1, 0.05f); imshow("image0",image0Show); } if(waitKey(30) == 27) break;//press ESC to exit } }``` ? – George Profenza Dec 20 '16 at 14:31
  • Thanks. I modified your code (to remove the `return -1` so that it just retries) and it neither grabs an image nor retrieves the depth map. – gcl8a Dec 20 '16 at 22:00
  • [Sorry - I can't edit the previous reply.] I'm going to try everything out on a different computer to see if I'm doing something wrong, or if my sensor is (unlikely) malfunctioning. My goal for the moment is just learning OpenCV, but eventually I have to run it on the Jetson, so any other ideas are appreciated. – gcl8a Dec 20 '16 at 22:02

0 Answers0