c# - Cannot find Front, Back Camera in windows 8.1 store app -


I have developed the windows 8.1 store app, it needs to capture the photo using the camera and post.

 MediaCaptureInitializationSettings _captureSettings = new var devices = Wait for the device information. FindAllSync (DeviceClass.VideoCapture); Forward (different devices in device) {if (device.EnclosureLocation! = Null & amp; Device.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back) {deviceId = device.Id; break; }} If (! String.IsNullOrEmpty (deviceId)) {_captureSettings.AudioDeviceId = ""; _captureSettings.VideoDeviceId = deviceId; . _captureSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Video; } CaptureManager = New MediaCapture (); Wait for the manager to catch up. The initial aisin (_captureSettings); Manage Capture Manager. Clean Effix Sink (MediaStreamTip Photo); CapturePrint1 Source = capture manager; Wait for the Capture Manager. StartProSync (); & Lt; / Code & gt; Here I am getting two devices but this device is empty of anchor space, so I do not know who is front and rear camera therefore decided to get another device from the list & lt; Code & gt; DeviceId = Device [1] .Id; & Lt; / Code & gt; But it throws an error such as "The current capture source does not have an independent photo stream." In the line to start MediaCapture & lt; Code & gt; Wait for the manager to catch up. The initial aisin (_captureSettings); & Lt; / Code & gt;  

I have tried in window surface Pro 2 and Acer devices. Please advise. thank you in advanced.

Try to better organize your code, you get two equal signs on the same line of your code It is not well prepared, so it's hard to read.

I use this code to use the camera in the Windows 8.1 stop app:

  // First of all webcam DeviceInformationCollection webcamList = wait DeviceInformation.FindAllAsync ( DeviceClass.VideoCapture) // if I have a question to put before webcam DeviceInformation frontWebcam = (in webcamList where webcam webcam.EnclosureLocation = null & amp ;! & amp; webcam.EnclosureLocation.Panel == Windows.Devices. Select Enumeration.Panel.Front Webcam) .FirstOrDefault (); // back to the Web the same DeviceInformation backWebcam = camera (in webcamList where webcam webcam.EnclosureLocation = null & amp ;! & Amp; webcam.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back select webcam ) .FirstOrDefault (); // Then you need to initialize your MediaCaptureVare Capture Manager = new MediaCapture (); Wait for the manager to catch up. Early Aesink (new MediaCaptureInitializationSettings {// If you want to select webcam (back webcam or front webcam) VideoDeviceId = backWebcam.Id, AudioDeviceId = "", streaming Kapcrmod = streaming Kapcrmod. Video, PhotoCaptureSource = PhotoCaptureSource.VideoPreview}); // Set the source of Capture Element on your Media Capture Capture Preview 1 Source = capture manager; // Start Preview Select Capture Manager. Startupsink ();   

In this way it is easy to read. This code is not very different, the MediaCapture basicization setting is not the same.

This code works for me on the surface 2 RT and Nokia 635, so it should work for you.

EDIT:

It seems that it works on devices with Windows RT, but on full Windows 8.1 device it is always null. MSDN says that:

If the location information of an enclosure is not available, then the property will be

then you can see what it can do First try whether you find a backwebcam and if it is zero take the last one; DeviceInformation backWebcam = (Webcam in webcamList where webcam.EnclosureLocation = Null & amp; Webcam.EnclosureLocation.Panel == Windows Tools.Alignment Panel.back selection Webcam). FirstOrDefault (); If (backWebcam == empty) {backWebcam = webcamList.Last (); }

But you are not sure that the last one in the archive is past, so you should add a button to give the user switch camera

If you change the camera,

  Wait for Capture Manager. Stop DisplaySync (); Wait captureManager.InitializeAsync (New MediaCaptureInitializationSettings {// another webcam VideoDeviceId = // new webcam, AudioDeviceId = "Select ID", StreamingCaptureMode = StreamingCaptureMode.Video, PhotoCaptureSource = PhotoCaptureSource.VideoPreview}); Wait for the Capture Manager. StartProSync (); In this way, you can ensure that the user can select the right camera, even you are programmatic who can not tell which   

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -