C # via EMGU CV play streaming media (RTSP)

Source: Internet
Author: User
Tags image processing library

Emgu CV is a cross platform. Net Wrapper to the OpenCV image processing library. Allowing OpenCV functions to is called from. NET compatible languages such as C #, VB, VC + +, IronPython etc. The wrapper can compiled by Visual Studio, Xamarin Studio and Unity, it can run on Windows, Linux, Mac OS X, IOS, Andro ID and Windows Phone.

Emgu cv:http://www.emgu.com/wiki/index.php/main_page, need to download version 3.0 later, EMGU CV 3.0 became ffmpeg

  

New //rtsp://user:[email protected]:554/   _capture. imagegrabbed + = capture_imagegrabbed;_capture. Start ();

private void Capture_imagegrabbed (object sender, EventArgs e)
{
Try
{
Mat frame = new mat ();

Lock (Lockobj)
{
if (capture! = NULL)
{
if (!capture. Retrieve (frame))
{
Frame. Dispose ();
Return
}
if (frame. IsEmpty)
Return

The display picture can be displayed using the Imagebox provided by the EMGU CV, or it can be turned into a bitmapsource display.

Slightly

}
}
}
catch (Exception ex)
{
}
}

 Public Static classBitmapsourceconvert {/// <summary>        ///Delete a GDI object/// </summary>        /// <param name= "O" >The Poniter to the GDI object to be deleted</param>        /// <returns></returns>[DllImport ("GDI32")]        Private Static extern intDeleteObject (IntPtr o); /// <summary>        ///Convert an IImage to a WPF bitmapsource. The result can be used in the Set property of Image.source/// </summary>        /// <param name= "image" >The emgu CV Image</param>        /// <returns>The equivalent BitmapSource</returns>         Public StaticBitmapSource Tobitmapsource (IImage image) {using(System.Drawing.Bitmap Source =image. Bitmap) {IntPtr ptr= Source. Gethbitmap ();//Obtain the HbitmapBitmapSource BS=System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap (PTR, IntPtr.Zero, Int32rect.empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions ())                ; DeleteObject (PTR); //Release the Hbitmap                returnBS; }        }    }

Note: Because FFmpeg uses TCP synchronous connection to request the video source by default, the connection time-out is very long,

Capture _capture = new Capture (fileName), which can cause blocking if the media being accessed does not exist. You need to set FFmpeg connection mode or time-out.

How to set it up:
public bool Setcaptureproperty (Capprop property, double value); Capture method. Specifically how to set not know, or EMGU CV does not provide this interface

C # via EMGU CV play streaming media (RTSP)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.