why opencv fails to capture video from ip axis camera in C++ but works in Python

asked 2019-08-02 14:52:01 -0500

gamedude_7 gravatar image

updated 2019-08-02 15:51:52 -0500

I can't open the video camera in C++ using Qt but I'm able to in Python for an axis camera. It's able to display the video in Python

I was able to open a webcam and have it display video using VidoCapture cap(0); I've tried using the same url from the database in Python and it worked in python. Then I hard code the same rtsp url in C++ but it failed to even open the ip camera for video capture. I've tried replacing rtsp to http but still didn't work. I've tried putting ipAddress:port# but that didn't work either. Furthermore, I have tried putting my rtsp address in the browser and in VLC player and it streamed fine for both of those but not in the C++ program.

Python:

url = None        
url = channel.url
print('channel.url: ' + url)
vs = cv2.VideoCapture(url)

print("camera " + str(url) + " is opened : " + str(vs.isOpened()))

Output: camera rtsp://username:password@xxx.xxx.x.xx/axis-media/media.amp is opened : True

C++

VideoCapture cap("rtsp://username:password@xxx.xxx.x.xx/axis-media/media.amp");

if(!cap.isOpened())  // check if we succeeded
    qDebug() << "Failed to video capture";
else
    qDebug() << "able to open camera";

Output: Failed to video capture

I'm trying to to successfully open the VideoCapture.

edit retag flag offensive close merge delete

Comments

Do you use lib opencv in your system for C++ and opencv from pip in python ?

kiet gravatar imagekiet ( 2019-08-05 21:43:18 -0500 )edit