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)