1

I am experimenting with OpenCV on Android. I have seen a lot of online material that utilise VideoCapture to read an rtsp stream.

In all Java examples that I found, the VideoCapture constructor takes a String. However the official javadoc pages (http://docs.opencv.org/java/2.4.11/) only says that an int can be passed to the constructor which is the camera id.

If you have a look at the following stackoverflow thread (OpenCV IP Camera RTSP stream) you notice that an URL is passed to the constructor.

What am I missing?

Community
  • 1
  • 1
Fouad
  • 855
  • 1
  • 11
  • 30
  • 1
    Did you check latest release - 3.1. See VideoCapture under VideoIO package here: http://docs.opencv.org/java/3.0.0/ – saurabheights Jan 06 '17 at 13:04
  • @saurabheights good catch, I will give it a try, Are you aware if the parameter in this constructor "VideoCapture(java.lang.String filename)" can be an URL? – Fouad Jan 06 '17 at 13:08
  • Sorry, I am not. I haven't used the Android Api, but since Android/Java api hasn't been added too long ago, my best guess was that this must have been added recently. Also this link may help: http://answers.opencv.org/question/24154/how-to-using-opencv-api-get-web-video-stream/ , note that the answer doesn't use url in strings, looks typo. P.S. opencv 3 is much better and easier to handle than opencv 2. Although, there will be less online resources compared to opencv 2, I would suggest you to use opencv3 if possible. :) – saurabheights Jan 06 '17 at 13:13
  • FYI: Check parent root here: http://docs.opencv.org/ and then here http://docs.opencv.org/ref/2.4.13/d8/dfe/classcv_1_1VideoCapture.html#a425c12b4f3aa56febad00835833c9e32 . So if you build opencv 2.4.13, you will have url api. :). See this as well: https://github.com/opencv/opencv/releases – saurabheights Jan 06 '17 at 13:18
  • do add your answer when solved, it will help others who will face the same issue – saurabheights Jan 09 '17 at 02:55
  • @saurabheights i tried opencv 3.2.0 for android. the VideoCapture constructor with an URL for an rtsp stream doesn't work. The method isOpened() always returns false – Fouad Jan 10 '17 at 07:20
  • Ok, sorry to hear that. You can take git pull of latest code to see if it will work, or raise issue at github.con/itseez/opencv – saurabheights Jan 10 '17 at 12:05

1 Answers1

2

The reason behind VideoCapture failing to open an RTSP stream was because on my machine OpenCV was missing ffmpeg. The way I ended up solving it was by using brew to install ffmpeg and then compiling OpenCV from source using cmake. After that was done, I was able to use OpenCV to read RTSP streams

Fouad
  • 855
  • 1
  • 11
  • 30