国产探花免费观看_亚洲丰满少妇自慰呻吟_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沒有提供這個接口


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东乡县| 辽中县| 阿图什市| 抚远县| 乌海市| 泾源县| 鲁甸县| 洪泽县| 双流县| 库伦旗| 汾阳市| 镇远县| 城固县| 丽江市| 韶山市| 柘荣县| 浦江县| 额尔古纳市| 玛曲县| 洞口县| 柯坪县| 衡山县| 洱源县| 武山县| 如东县| 宜州市| 古浪县| 渝北区| 青铜峡市| 中阳县| 渝中区| 诸暨市| 阜新市| 张家界市| 东莞市| 卢湾区| 通海县| 河曲县| 汉寿县| 西畴县| 大新县|