Why do I have a compiler error (CS1503) in this Ozeki file?

1.9k views Asked by At
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
    }
}

Can somebody tell me what I could do? It tells me that i can not convert the _videoViewerWPF.SetImageProvider(_provider) line from Ozeki.Media.BitmapSourceProvider to Ozeki.Media.IImageProvider and i have absolutely no idea what to do that it could work.

I tried several times to do something, but I dont even know what I´m doing. I would be thankfull if somebody could help me so I can finish this.

1

There are 1 answers

0
YetMoreStuff On

I came across the same issue after following the Ozeki video C# camera tutorial #3 - Camera viewer on YouTube.

It may be that the API has moved on since that video because sample code on the Ozeki Website (How to connect to an RTSP camera and display the picture in C#) uses a DrawingImageProvider instead of a BitmapSourceProvider:

...

private DrawingImageProvider _provider = new DrawingImageProvider();

...

...and then (for a WPF app):

_videoViewerWpf.SetImageProvider(_provider);

In my case, this fixed the compiler error and I can now display RTSP video in a WPF app.