using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Windows;

using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;

using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Ozeki.Camera;
using Ozeki.Media;
using Ozeki;
using System.Windows.Media;

namespace BasicCameraViewer
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private VideoViewerWPF _videoViewerWPF;
        private BitmapSourceProvider _provider;
        private IIPCamera _ipCamera;
        private WebCamera _webCamera;
        private MediaConnector _connector;

        public MainWindow()
        {
            InitializeComponent();

            _connector = new MediaConnector();
            _provider = new BitmapSourceProvider();

            SetVideoViewer();

        }
        private void SetVideoViewer()
        {
            _videoViewerWPF = new VideoViewerWPF
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Stretch,
                Background= Brushes.Black

             };
            CameraBox.Children.Add(_videoViewerWPF);

            _videoViewerWPF.SetImageProvider(_provider);
        }

        #region IP Camera Connect/Disconnect

        private void ConnectIPCamera_Click(object sender, RoutedEventArgs e)
        {
            var host = HostTextBox.Text;
            var user = userTextBox.Text;
            var pass = Password.Password;

            _ipCamera = IPCameraFactory.GetCamera(host, user, pass);
            if (_ipCamera == null) return;
            _connector.Connect(_ipCamera.VideoChannel, _provider);

            _ipCamera.Start();
            _videoViewerWPF.Start();

        }

        private void DiconnectIPCamera_Click(object sender, RoutedEventArgs e)
        {
            _videoViewerWPF.Stop();

            _ipCamera.Disconnect();
            _ipCamera.Dispose();

            _connector.Disconnect(_ipCamera.VideoChannel, _provider);
        }
        #endregion
    }
}

有人可以告诉我该怎么做吗?它告诉我,我无法将_videoViewerWPF.SetImageProvider(_provider)行从Ozeki.Media.BitmapSourceProvider转换为Ozeki.Media.IImageProvider,而且我完全不知道该怎么做才能起作用。

我几次尝试做某事,但我什至不知道我在做什么。
如果有人可以帮助我,我将不胜感激,这样我就可以完成。

最佳答案

在YouTube上观看Ozeki视频C# camera tutorial #3 - Camera viewer之后,我遇到了同样的问题。

自该视频以来,API可能已经继续运行,因为Ozeki网站(How to connect to an RTSP camera and display the picture in C#)上的示例代码使用了DrawingImageProvider而不是BitmapSourceProvider:

...

private DrawingImageProvider _provider = new DrawingImageProvider();

...

...然后(对于WPF应用):
_videoViewerWpf.SetImageProvider(_provider);

就我而言,这解决了编译器错误,现在我可以在WPF应用程序中显示RTSP视频。

关于c# - 为什么此Ozeki文件中出现编译器错误(CS1503)?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52836699/

10-11 15:40