简体   繁体   中英

EMGU QueryFrame returns "streaky" Image over RTSP

I have a HD network camera that I am trying to grab frames over rtsp and using the following code:

//in Form_Load
Application.Idle += getNextFrame;

And the Event Handler:

private void getNextFrame(object sender, EventArgs ags)
{
        //where _imgCount is the total image Grabs
        lbl_Count.Text = _imgCount++.ToString(); 
        // and ibLive is a Emgu ImageBox
        ibLive.Image = capAxis.QueryFrame().Resize(640, 480, INTER.CV_INTER_AREA);
}

When I start the program, it'll grab 20-40 frames before the "streakiness" appears at the bottom of the screen. It's always on the bottom of the image, but some times it takes up half the screen.

在此处输入图片说明

The stream resolution is 1920x1080 and it's using mjpeg. I tried switching to h.264 but had the same results.

I am using Emgu version x86-2.4.0.1717

Any Ideas? Thanks.

I know this is an old question but I ran into the same problem recently. I would recommend using another streaming library. Eg.

If you really need to stream using EMGU then create a stream profile with a lower resolution or higher compression. I set compression to 30 and used the same resolution then provided the stream profile name in the rtsp url. (Assuming you're using an Axis camera like me capAxis )

Capture cap = new Capture(@"rtsp://10.0.0.1/axis-media/media.amp?videocodec=h264&streamprofile=rtspstream");

I have the same problem like that and I have solved it by myself. I used iSpy to know url of my ONVIF Ip Camera. My IP Camera's url is rtsp://192.168.1.xxx:554//user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream For stream = 0, my IP Cam is running in HD resolution (1280 x 720) and that resolution makes a streaky result of my image. So there were two options of URL that iSpy gave, and the other one is just different in stream. I changed stream = 1 for low resolution (352 x 288) and the image result is good ! There's no streaky in my image. Something that I learned from this problem was using RTSP you must use it in low resolution. High resolution will make the image result not good. Hope it can help your problem.

Regards, Alfonsus Dhani

At the end of Capture string add this "?tcp"

Capture cap = new Capture(@"rtsp://10.0.0.1/axis-media/media.amp?videocodec=h264&streamprofile=rtspstream?tcp");

EDIT

This is my code, and yes, it works, I'am using an IP cam DAHUA.

Capture cap = Capture(@"rtsp://admin:12345@10.0.0.01:554/cam/realmonitor?channel=1&subtype=01?tcp"); 

A late reply but may help someone facing similar challenged.

Emgu's capabilities to deal with RTSP streams are limited and not stable. I was facing similar issues as discussion in this question,

Unable to use EMGU CV to grab images from RTSP stream continuously

The solution was to use RTSPClientSharp which works like a charm. ( https://github.com/BogdanovKirill/RtspClientSharp )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM