首页 > 解决方案 > 为什么此 Ozeki 文件中出现编译器错误 (CS1503)?

问题描述

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,我完全不知道该怎么做才能起作用。

我尝试了几次做某事,但我什至不知道我在做什么。如果有人可以帮助我,我会很感激,所以我可以完成这个。

标签: c#compiler-errorsaxisonvifozeki

解决方案


在遵循 Ozeki 视频C# 相机教程 #3 - YouTube 上的相机查看器后,我遇到了同样的问题。

可能是因为 Ozeki 网站上的示例代码(如何连接到 RTSP 相机并在 C# 中显示图片)上的示例代码使用了 DrawingImageProvider 而不是 BitmapSourceProvider:

...

private DrawingImageProvider _provider = new DrawingImageProvider();

...

...然后(对于 WPF 应用程序):

_videoViewerWpf.SetImageProvider(_provider);

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


推荐阅读