本文整理汇总了C#中Windows.Media.Capture.MediaCapture.PrepareLowLagPhotoCaptureAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MediaCapture.PrepareLowLagPhotoCaptureAsync方法的具体用法?C# MediaCapture.PrepareLowLagPhotoCaptureAsync怎么用?C# MediaCapture.PrepareLowLagPhotoCaptureAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.Media.Capture.MediaCapture
的用法示例。
在下文中一共展示了MediaCapture.PrepareLowLagPhotoCaptureAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: startDevice
private async void startDevice()
{
// CamView.Visibility = Visibility.Visible;
try
{
await Task.Delay(TimeSpan.FromSeconds(3));
m_bReversePreviewRotation = false;
m_mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
var chosenDevInfo = m_devInfoCollection[devListView.SelectedIndex];
settings.VideoDeviceId = chosenDevInfo.Id;
if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
{
m_bRotateVideoOnOrientationChange = true;
m_bReversePreviewRotation = false;
}
else if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front)
{
m_bRotateVideoOnOrientationChange = true;
m_bReversePreviewRotation = true;
}
else
{
m_bRotateVideoOnOrientationChange = false;
}
await m_mediaCaptureMgr.InitializeAsync(settings);
m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());
// await Task.Delay(TimeSpan.FromSeconds(2));
//myGlobals.newProc(2);
}
catch (Exception ex)
{
var dialog = new MessageDialog(ex.ToString());
await dialog.ShowAsync();
//Debug.WriteLine(ex.ToString());
}
}
示例2: btnStartDevice_Click
internal async void btnStartDevice_Click(Object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
try
{
btnStartDevice2.IsEnabled = false;
m_bReversePreviewRotation = false;
ShowStatusMessage("Starting device");
m_mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
var chosenDevInfo = m_devInfoCollection[EnumedDeviceList2.SelectedIndex];
settings.VideoDeviceId = chosenDevInfo.Id;
if (EnumedMicrophonesList2.SelectedIndex >= 0 && m_microPhoneInfoCollection.Count > 0)
{
var chosenMicrophoneInfo = m_microPhoneInfoCollection[EnumedMicrophonesList2.SelectedIndex];
settings.AudioDeviceId = chosenMicrophoneInfo.Id;
}
if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
{
m_bRotateVideoOnOrientationChange = true;
m_bReversePreviewRotation = false;
}
else if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front)
{
m_bRotateVideoOnOrientationChange = true;
m_bReversePreviewRotation = true;
}
else
{
m_bRotateVideoOnOrientationChange = false;
}
await m_mediaCaptureMgr.InitializeAsync(settings);
if (m_mediaCaptureMgr.MediaCaptureSettings.VideoDeviceId != "" && m_mediaCaptureMgr.MediaCaptureSettings.AudioDeviceId != "")
{
btnStartPreview2.IsEnabled = true;
ShowStatusMessage("Device initialized successful");
chkAddRemoveEffect.IsEnabled = true;
chkAddRemoveEffect.IsChecked = false;
m_mediaCaptureMgr.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded);
m_mediaCaptureMgr.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(Failed);
if (!m_mediaCaptureMgr.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported)
{
radTakePhoto.IsEnabled = true;
radRecord.IsEnabled = true;
//choose TakePhoto Mode as defaul
radTakePhoto.IsChecked = true;
}
else
{
//prepare lowlag photo, then prepare lowlag record
m_lowLagPhoto = await m_mediaCaptureMgr.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg());
btnTakePhoto2.IsEnabled = true;
m_bLowLagPrepared = true;
PrepareLowLagRecordAsync();
//disable check options
radTakePhoto.IsEnabled = false;
radRecord.IsEnabled = false;
}
EnumerateSceneModeAsync();
}
else
{
btnStartDevice2.IsEnabled = true;
ShowStatusMessage("No VideoDevice/AudioDevice Found");
}
}
catch (Exception exception)
{
ShowExceptionMessage(exception);
}
}
示例3: CameraInit
private async void CameraInit()
{
try
{
if (_mediaCapture != null)
{
// Cleanup MediaCapture object
CameraCleanup();
}
// Task.Delay(TimeSpan.FromSeconds(10)).Wait();
Debug.WriteLine("Initing Video Capture... ");
// Use default-ish initialization
MediaCaptureInitializationSettings capInitSettings = new MediaCaptureInitializationSettings();
capInitSettings.StreamingCaptureMode = StreamingCaptureMode.Video;
_mediaCapture = new MediaCapture();
_mediaCapture.Failed += new MediaCaptureFailedEventHandler(CameraInit_Failed);
var deviceList = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
foreach (DeviceInformation di in deviceList)
{
Debug.WriteLine("-> " + di.Id + " -> " + di.Name);
}
// capInitSettings.VideoDeviceId = MediaCapture.
await _mediaCapture.InitializeAsync(capInitSettings);
IReadOnlyList<IMediaEncodingProperties> resolutions =
_mediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview);
VideoEncodingProperties bestRes = null;
// search for minimal available frame rate and resolution.
Debug.WriteLine("Available Resolutions: ");
for (var i = 0; i < resolutions.Count; i++)
{
if (resolutions[i].GetType().Name != "VideoEncodingProperties")
continue;
var r = (VideoEncodingProperties) resolutions[i];
Debug.WriteLine(i.ToString() + " res: " + r.Width + "x" + r.Height + " @ " + r.FrameRate.Numerator +
"/" + r.FrameRate.Denominator + " fps (" + r.Type + ": " + r.Subtype + ")");
if (r.FrameRate.Denominator != 1)
continue;
if (bestRes == null)
{
bestRes = r;
continue;
}
if (r.FrameRate.Numerator <= bestRes.FrameRate.Numerator &&
r.Height*r.Width <= bestRes.Height*bestRes.Width &&
r.Height >= 400 &&
r.Subtype == "YUY2")
{
bestRes = r;
}
}
await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.Photo, bestRes);
_mediaCapture.VideoDeviceController.Focus.TrySetAuto(true);
_LLPC =
_mediaCapture.PrepareLowLagPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg())
.GetAwaiter()
.GetResult();
Debug.WriteLine("Using: " + bestRes.Width + "x" + bestRes.Height + " @ " + bestRes.FrameRate.Numerator +
"/" + bestRes.FrameRate.Denominator + " fps");
PreviewElement.Source = _mediaCapture;
PreviewElement.Stretch = Stretch.None;
_mediaCapture.StartPreviewAsync().GetAwaiter().GetResult();
Debug.WriteLine("done.");
}
catch (Exception ex)
{
Debug.WriteLine("Unable to initialize camera for audio/video mode: " + ex.Message);
}
}