c# - 为什么此 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,我完全不知道该怎么做才能起作用。
我尝试了几次做某事,但我什至不知道我在做什么。如果有人可以帮助我,我会很感激,所以我可以完成这个。
解决方案
在遵循 Ozeki 视频C# 相机教程 #3 - YouTube 上的相机查看器后,我遇到了同样的问题。
可能是因为 Ozeki 网站上的示例代码(如何连接到 RTSP 相机并在 C# 中显示图片)上的示例代码使用了 DrawingImageProvider 而不是 BitmapSourceProvider:
...
private DrawingImageProvider _provider = new DrawingImageProvider();
...
...然后(对于 WPF 应用程序):
_videoViewerWpf.SetImageProvider(_provider);
就我而言,这修复了编译器错误,我现在可以在 WPF 应用程序中显示 RTSP 视频。
推荐阅读
- java - 随机数组生成
- r - r:随机替换一定数量的缺失值
- reactjs - 如何等到测试库中按钮的禁用状态发生更改?
- python - 聚合和自定义函数 pandas
- java - 使用 JDK 1.8 编译期间出现“调用 com.sun.tools.ws.wscompile.WsimportTool 失败”错误
- python - 大熊猫在垂直连接后得到原始数据框
- java - 两种方式的 SSL 身份验证问题:HTTP 500 - 对等方终止 Hadoop | 套接字写入错误 | PKCS12
- python - 使用 cv2 将 video.mp4(小尺寸)转换为图像序列(统称为更大尺寸)时的尺寸差异
- mysql - Docker SpringBoot MySql:驱动没有从服务器收到任何数据包
- firebase - 颤抖着在firebase中获得名字