Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoCapture(String) constructor fails to open gstreamer pipeline on Tegra / CUDA 8.0 #8005

Open
iandreariley opened this issue Jan 12, 2017 · 2 comments

Comments

@iandreariley
Copy link

System information (version)
  • OpenCV => 3.1
  • Operating System / Platform => Ubuntu 16.04 Linux 4 Tegra 24.2.1 aarch64 / Jetson TX1
  • Compiler => g++ 5.4.0
Detailed description

VideoCapture(string) constructor using a gstreamer pipeline string fails to open a stream, even though the stream can be launched with the same pipeline using gst-launch-1.0. Note that the VideoCapture(int) constructor succeeds at opening a stream with VideoCapture(0) -- although for me, the feed is blank because i currently have no usb camera connected to the tx1.

Steps to reproduce

Flash TX1 with Jetpack 2.3.1.
Build opencv 3.1.0 from source using the instructions found here.

Add the following code to a cpp file named test.cpp

#include "highgui.hpp"
#include "videoio.hpp"
#include "imgproc.hpp"
#include <iostream>
#include <string.h>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
  string gst_pipe = "videotestsrc ! videoconvert ! appsink";
  VideoCapture cap(gst_pipe);

  if (!cap.isOpened())
    {
      std::cout << "Failed to open camera." << endl;
      return -1;
    }

  for(;;)
    {
      Mat frame;
      cap >> frame;
      imshow("original", frame);
      waitKey(1);
    }

  cap.release();
}

Build it with

g++ -o test -I /usr/include/opencv2 -Wall test.cpp -L/usr/lib -l:libopencv_core.so.3.1.0 -l:libopencv_videoio.so.3.1.0 -l:libopencv_imgproc.so.3.1.0 -l:libopencv_highgui.so.3.1.0

Run the resulting executable with ./test. Note that no stream is opened, and "Failed to open camera." is printed to the console.

@mshabunin mshabunin added the bug label Jan 13, 2017
@alexbennett
Copy link

What is the status of this bug? I am having the same issue with the Jetson TX2.

@alexbennett
Copy link

I have finally alleviated this issue for my setup. It turned out to be a conflict between my OpenCV built from source and one installed by ROS.

The ros-kinetic-opencv3 package had been installed on my system as a dependency of another package I was using for my project. In turn, ROS ended up using the files built from that package when linking rather than the ones I built that specified GStreamer support with the -DWITH_GSTREAMER=ON flag. This caused the stream to fail to open in my program because it wasn't interpreting the string as a GStreamer pipe.

The solution was to manually build the ROS packages I needed (vision_opencv) from source, and specify in the makefile to link the OpenCV I built.

I can't say for certain that this is the same issue @iandreariley had, but given our very similar setups it may very well be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants