0

I am using OpenCV 2.4.10 and I want to take image from my Asus Xtion Pro Live. When I'm trying to execute the code below, I get this error: "Can not open capture." I tried everything, like Sensor update, opencv with openni compiling and opencv re-installing (even the version 2.4.6).

OpenNI and Sensor are working properly since I am able to run examples such as NiViewer. But the example openni_capture.cpp (on opencv-2.4.10/samples/cpp) cannot run properly.

The code:

#include "opencv2/opencv.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>

using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture capture;
    capture.open(CV_CAP_OPENNI_ASUS);
    if ( !capture.isOpened() )
    {
    cout << "Error opening capture" << endl;
    return -1;
    }
    if( !capture.grab() )
    {
    cout << "Can not grab image" << endl;
    }
    return 0;
}

The compiling is done with the following command: g++ capture.cpp -o capture pkg-config --cflags opencv --libs opencv

How can i fix this error? Is there any problem with the opencv version that i use?

I did what is being said on Can not grab image from VideoCapture OpenCV with Asus Xtion Pro Live but the problem still exists.

Community
  • 1
  • 1
MTs
  • 199
  • 2
  • 19

1 Answers1

0

What serial ports are listed when you print out the list as you're doing ? Have you checked to see what serial port your camera is connected to ? On Linux you can list mounted devices with :

lsusb
danieljay
  • 113
  • 2
  • 11
  • Well.. It the point I guess is to make sure your camera is showing up. You'd then need to explicitly find it in opencv. I think this is a good thread on solving this: http://stackoverflow.com/questions/7322939/how-to-count-cameras-in-opencv-2-3 – danieljay Mar 14 '15 at 13:57
  • When i run the lsusb command i get this: "Bus 001 Device 004: ID 1d27:0601 ". The usbinterface that it uses is UsbInterface=2. – MTs Mar 14 '15 at 14:08
  • danieljay, i followed the instructions on the thread you showed me, but nothing happened. Is there a problem with Xtion? Is it closed (the sensors or the camera)? – MTs Mar 14 '15 at 14:56
  • Can you see it as a connected device first and foremost before interfacing it with opencv? Tried any default software to make sure you can grab a stream ? Also once this is established... I'm not sure the default on what opencv opens videos... But you'd want to check the resolution and max frame rate @ that res of your camera – danieljay Mar 14 '15 at 14:59
  • Excuse me, could you tell me if the command that i use for compiling is the proper one? – MTs Mar 14 '15 at 19:45