0
我们试图使用MediaCapture类从网络摄像头自动捕获图像。我们正在尝试创建一个应用程序,它可以打开相机,等待片刻并捕获前面的图像,而无需点击屏幕进行拍摄。我们尝试使用LowLagPhotoCapture类,但不能按需要工作。示例代码 -如何使用MediaCapture类打开并自动捕获摄像头
async private void InitMediaCapture()
{
MediaCapture _mediaCapture = new MediaCapture();
await _mediaCapture.InitializeAsync();
_displayRequest.RequestActive();
PreviewControlCheckIn.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
await Task.delay(500);
CaptureImage();
}
async private void CaptureImage()
{
storeFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync ("TestPhoto.jpg",CreationCollisionOption.GenerateUniqueName);
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
await _mediaCapture.CapturePhotoToStorageFileAsync(imgFormat, storeFile);
await _mediaCapture.StopPreviewAsync();
}
任何信息将是伟大的,在此先感谢您的帮助。