opencvsharp
opencvsharp copied to clipboard
Videocapture does not work with rtsp
Summary of your issue
Hi, I am new to OpenCvSharp and having a hard time understanding what I am doing wrong. My problem is the Cv2.VideoCapture method. When pass as a parameter "0" to connect to my laptop camera it works fine, however when I pass the rtsp address of my external surveillance camera it returns empty matrix. I have researched the topic and I think the issue is in GSTREAM setting being turned off. I tried to set it on, but ended up only corrupting core files of my PC. I would be very grateful if someone could explain me how to fix this problem as detailed as possible.
Environment
Windows 10 Visual Studio 2022 Console app with .NET OpenCvSharp4
Example code:
private static string camera = "rtsp://login:[email protected]:554/11"
.......
var cap = new VideoCapture(@camera);
Mat frame = new Mat();
cap.Read(frame);
Console.WriteLine(frame.Empty());
Cv2.ImShow("frame", frame);
Cv2.WaitKey();
Output:
True (means matrix is empty)
Then error, smth like: "Mat.height <= 0, Mat.width <= 0". Basically means matrix is empty
What did you intend to be?
I want it to be able to connect and stream from camera using the rtsp address as input for the VideoCapture method.
As a sidenote: I have also tried the address without "@", and other ways like rtmp and http protocols. Doesn't work.
Could be a stupid test but did you try to watch your camera url in VLC ?
Hi guys. I have same issue cannot share stream we use in compnay, but can some please try to play this stream (and yes it does play in VLC). rtsp://demo:[email protected]:5541/onvif-media/media.amp?profile=profile_1_h264&sessiontimeout=60&streamtype=unicast
@Davidkulpe Hi, I don't know what caused this problem for me, but I tried downgrading my Visual Studio from 2022 to 2019 and it started working. Also I only added one OpenCvSharp Nuget package, the OpenCvSharp.Windows or smth like that.
happy to hear. I'm using vs2019 with ,Net 4.8. still stuck
@Davidkulpe Hi, I can't open your rtsp link in VLC
try .net core, instead of .net framework. this worked for me.
I managed to make it work by using the .net core version. Then I realized the only difference is this dll in the bin folder bin/Debug/dll/x64/opencv_videoio_ffmpeg460_64.dll. after I copied it to my .Net 4.8 project everything worked!
谁能分享一下树莓派香橙派上已经编译好的文件,arm32
try .net core, instead of .net framework. this worked for me.
谢谢,你的回答解决了我的问题
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.