国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

C# 通過Emgu CV播放流媒體(RTSP)

2019-11-17 02:20:45
字體:
來源:轉載
供稿:網友

C# 通過Emgu CV播放流媒體(RTSP)

Emgu CVis a cross platform .Net wrapper to theOpenCVimage PRocessing library. AllowingOpenCVfunctions to be called from .NET compatible languages such as C#, VB, VC++, IronPython etc. The wrapper can be compiled by Visual Studio, Xamarin Studio and Unity, it can run on Windows, linux, Mac OS X, iOS, Android and Windows Phone.

  Emgu CV 下載地址:http://www.emgu.com/wiki/index.php/Main_Page,需要下載3.0版本以后的,Emgu CV 3.0集成了ffmpeg

  

Capture _capture = new Capture(fileName); //rtsp://user:passWord@192.168.1.66: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;

        //顯示圖片 可以使用Emgu CV 提供的ImageBox顯示視頻, 也可以轉成BitmapSource顯示。

        //略

      }     }   }   catch (Exception ex)   {   } }

public static class BitmapSourceConvert    {        /// <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 int DeleteObject(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 static BitmapSource ToBitmapSource(IImage image)        {            using (System.Drawing.Bitmap source = image.Bitmap)            {                IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap                BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(                    ptr,                    IntPtr.Zero,                    Int32Rect.Empty,                    System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());                DeleteObject(ptr); //release the HBitmap                return bs;            }        }    }

 注意事項:由于ffmpeg 默認使用TCP阻塞方式建立連接,連接超時時間很長。如果連接不成功,會導致阻塞。需要設置ffmpeg連接方式或者設置超時時間。

設置方式:public bool SetCaptureProperty(CapProp property, double value); //Capture方法。具體怎么設置不知道、或者Emgu CV沒有提供這個接口


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 塔城市| 将乐县| 措美县| 云龙县| 襄汾县| 克山县| 丰宁| 安仁县| 无为县| 墨玉县| 肇源县| 内黄县| 九龙县| 双流县| 平乐县| 盐边县| 五河县| 永吉县| 磐安县| 额尔古纳市| 白朗县| 崇左市| 界首市| 扶风县| 柘城县| 赤壁市| 红桥区| 阜宁县| 唐河县| 高尔夫| 北海市| 华宁县| 南雄市| 遵义县| 潮安县| 清远市| 长汀县| 锡林郭勒盟| 株洲县| 崇信县| 嘉善县|