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();
}
任何信息將是偉大的,在此先感謝您的幫助。