2014-10-06 2 views
1

WP 용으로 처음으로 응용 프로그램을 만들 때 기본 카메라 응용 프로그램을 만들려고합니다. 또한 촬영하기 전에 카메라 데이터를 화면에 미리보고 싶습니다.Windows Phone 8.1의 카메라 미리보기 스트림에 액세스

그러나 유일한 샘플 내가 MSDN 등 온라인 참조는

난 그냥 시작하기에 문제가있어 (라이브러리는 자주 사용되지 않는 물품을 업데이트되는 즉, 많은 개체가 제거되었습니다) 너무 오래된 미리보기 스트림 지식이있는 사람이이 문제에 도움이 될 수 있으면 크게 감사하겠습니다.

감사합니다. 당신은 내가 모두 코드를 보여줄 수 있도록 전면 또는 후면 웹캠을 사용하려면

<CaptureElement x:Name="Capture" 
       Stretch="UniformToFill" 
       FlowDirection="LeftToRight" /> 

나도 몰라 :

답변

1

나는이를 추가하려면 XAML에서 [CaptureElement 제어

을 사용하는 것이 좋습니다.

당신의 코드 숨김에서

(또는 뷰 모델 당신이 MVVM을 사용하는 경우)이 코드를 추가합니다 : 이것은 당신의 CaptureElement 컨트롤에서 선택된 웹캠의 흐름을 보여줍니다

// First need to find all webcams 
DeviceInformationCollection webcamList = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture) 

// Then I do a query to find the front webcam 
DeviceInformation frontWebcam = (from webcam in webcamList 
where webcam.EnclosureLocation != null 
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front 
select webcam).FirstOrDefault(); 

// Same for the back webcam 
DeviceInformation backWebcam = (from webcam in webcamList 
where webcam.EnclosureLocation != null 
&& webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back 
select webcam).FirstOrDefault(); 

// Then you need to initialize your MediaCapture 
var newCapture = new MediaCapture(); 
await newCapture.InitializeAsync(new MediaCaptureInitializationSettings 
{ 
    // Choose the webcam you want (backWebcam or frontWebcam) 
    VideoDeviceId = backWebcam.Id, 
    AudioDeviceId = "", 
    StreamingCaptureMode = StreamingCaptureMode.Video, 
    PhotoCaptureSource = PhotoCaptureSource.VideoPreview 
}); 

// Set the source of the CaptureElement to your MediaCapture 
Capture.Source = newCapture; 

// Start the preview 
await newCapture.StartPreviewAsync(); 

을 모두 윈도우 폰 8.1 및 Windows에서 작동 8.1

+0

대단히 감사합니다! 이것은 완벽하게 – Tokfrans

+0

도움이되어 기뻤습니다! –

관련 문제