我想创建一个简单的应用程序,它将具有打开和关闭Windows媒体设备中闪光灯的功能。 我已经初始化相机如下:控制寡妇媒体设备闪光灯
var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
var rearCamera = devices.FirstOrDefault(item => item.EnclosureLocation != null &&
item.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back);
if (rearCamera != null)
{
DeviceName.Content = rearCamera.Name;
FlashButton.Visibility = System.Windows.Visibility.Visible;
mediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
{
VideoDeviceId = rearCamera.Id
});
LowLagPhotoCapture lowLagCaptureMgr = null;
// Image properties
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
// Create LowLagPhotoCapture object
lowLagCaptureMgr = await mediaCapture.PrepareLowLagPhotoCaptureAsync(imgFormat);
}
而且对我写了下面的代码闪光灯开关:
var MyVideoDeviceController = mediaCapture.VideoDeviceController;
var MyTorch = MyVideoDeviceController.TorchControl;
var MyFlash = MyVideoDeviceController.FlashControl;
if (MyTorch.Supported)
{
MyTorch.PowerPercent = 100;
MyTorch.Enabled = true;
}
else
{
if (MyFlash.Supported)
{
MyFlash.PowerPercent = 100;
MyFlash.Enabled = true;
}
else
{
MessageBox.Show("No Flash and Torch Support", "Flash and Torch");
}
}
,但似乎都TorchControl和FlashControl在代码中不支持。我不确定是否也使用正确的API。我想在运动F5M运行此 - 平板电脑
在此先感谢
谢谢@Mike,这是非常翔实的。只是供参考,我的意图是保持光源作为火炬。我会尝试你的链接。再次感谢您的信息。保持良好的工作。 –
嗨@Mike,你知道任何可以将设备暴露给Windows的驱动程序吗? –
驱动程序通常不可互换,特别是如果您希望启用某些功能。现在,Microsoft提供了一个通用相机驱动程序,因此您可以尝试恢复到该驱动程序(通过在设备管理器中卸载相机并删除驱动程序软件),或者如果您已经在运行Microsoft驱动程序,则安装由生产厂家。制造商是否提供可以使用闪光灯的应用程序?内置相机中没有闪光灯吗?如果是这样,你应该联系他们要求更好的司机。 – Mike