UWP IOT,如何访问机载摄像头?,而不是 USB 摄像头
UWP IOT, How to access camera on board?, not usb camera
我在访问物联网相机时遇到问题,
我尝试创建简单的代码来访问摄像头,从该摄像头查看实时流媒体。
它适用于 Windows-phone 10 && Windows 10。
但是在 IOT 设备上尝试时出现错误,显示 'No devices found'
相机就像 here in this link
here is the code
private async Task StartPreviewAsync()
{
try
{
mediaCapture = new MediaCapture();
var allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var count = allVideoDevices.Count;
System.Diagnostics.Debug.WriteLine(count+"Video Capture Device");
await mediaCapture.InitializeAsync();
PreviewControl.Source = mediaCapture;
await mediaCapture.StartPreviewAsync();
}
catch (UnauthorizedAccessException)
{
// This will be thrown if the user denied access to the camera in privacy settings
System.Diagnostics.Debug.WriteLine("The app was denied access to the camera");
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("MediaCapture initialization failed.");
}
}
//protected async override void OnNavigatedFrom(NavigationEventArgs e)
//{
// await CleanupCameraAsync();
//}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
StartPreviewAsync();
}
对我的问题有什么建议吗?
Windows 10 物联网版目前支持有限数量的设备,这些设备位于 Hardware Compatibility List (see Cameras 部分)。不幸的是,如果您的相机未在此处列出,您将无法从 UWP 应用程序中使用它。据我所知,不支持Raspberry Pi原生相机。
我在访问物联网相机时遇到问题, 我尝试创建简单的代码来访问摄像头,从该摄像头查看实时流媒体。 它适用于 Windows-phone 10 && Windows 10。 但是在 IOT 设备上尝试时出现错误,显示 'No devices found' 相机就像 here in this link
here is the code
private async Task StartPreviewAsync()
{
try
{
mediaCapture = new MediaCapture();
var allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var count = allVideoDevices.Count;
System.Diagnostics.Debug.WriteLine(count+"Video Capture Device");
await mediaCapture.InitializeAsync();
PreviewControl.Source = mediaCapture;
await mediaCapture.StartPreviewAsync();
}
catch (UnauthorizedAccessException)
{
// This will be thrown if the user denied access to the camera in privacy settings
System.Diagnostics.Debug.WriteLine("The app was denied access to the camera");
}
catch (Exception)
{
System.Diagnostics.Debug.WriteLine("MediaCapture initialization failed.");
}
}
//protected async override void OnNavigatedFrom(NavigationEventArgs e)
//{
// await CleanupCameraAsync();
//}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
StartPreviewAsync();
}
对我的问题有什么建议吗?
Windows 10 物联网版目前支持有限数量的设备,这些设备位于 Hardware Compatibility List (see Cameras 部分)。不幸的是,如果您的相机未在此处列出,您将无法从 UWP 应用程序中使用它。据我所知,不支持Raspberry Pi原生相机。