Tuesday, March 29, 2016

Auto focus camera without preview

Leave a Comment

I am running Win10 IoT on a pi 2. I need to be able to take pictures that are focused but cannot get the focus working. The application is a background app so I don't have a way of previewing the camera on a display. Is there any way of doing this? Currently I have

await _mediaCapture.StartPreviewAsync(); _mediaCapture.VideoDeviceController.FocusControl.Configure(new FocusSettings {     Mode = FocusMode.Continuous,     WaitForFocus = true }); await _mediaCapture.VideoDeviceController.FocusControl.FocusAsync(); await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream); await _mediaCapture.StopPreviewAsync(); 

but I am getting the error

WinRT information: Preview sink not set

when I try to focus. All of the examples I've seen online show that the preview is output to a control and I assume it wires a sink up automagically. Is there a way to do this manually through code? Possibly without the preview?

1 Answers

Answers 1

I wonder if the code may work even without FocusControl.

I propose you follow Customer Media Sink implementation example and use of StartPreviewToCustomSinkIdAsync method described at http://www.codeproject.com/Tips/772038/Custom-Media-Sink-for-Use-with-Media-Foundation-To

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment