C# 调用emguCV3.1播放网络rtsp视频
运用emguCV3.1,调用rtsp网络视频:
.cs:
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication45
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();          
        }
        Capture cam;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            CvInvoke.UseOpenCL = false;
            cam = new Capture("xxxx");   //这里是rtsp地址
            cam.ImageGrabbed += Cam_ImageGrabbed;
            cam.Start();           
        }
        Mat frame = new Mat();
        private void Cam_ImageGrabbed(object sender, EventArgs e)
        {
            cam.Retrieve(frame, 0);
            pic.Image = frame.Bitmap;         
        }        
    }
}
xaml:
<Window x:Class="WpfApplication45.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication45"
        mc:Ignorable="d"
     xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
        xmlns:xx="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid>
            <wfi:WindowsFormsHost Margin="0,3,0,62">
                <xx:PictureBox x:Name="pic"></xx:PictureBox>
            </wfi:WindowsFormsHost>
            <Button Width="50" Height="30" Margin="21,271,446,19" Click="Button_Click"/>
        </Grid>
    </Grid>
</Window>
需要引用的库:

 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号