How to display the preview of 2 cameras in windows 8 using the MediaCapture class

I want to be able to show the preview of several camera devices using the MediaCapture class. Currently I initialize the MediaCapture with a MediaCaptureInitializationSettings object which contains the device id. The settings object receives only 1 VideoDeviceId so I cannot set several video sources for the same MediaCapture object. Another thing I tried was to create several MediaCapture objects, one per device. However, it looks like the last one that gets initialized is the one who gets the device access, so even when there are several media devices each one associated to a different device, only the video of one of the devices is allowed to be displayed as a preview.

Below is the code so that you can have a better understanding.

async private void PreviewDevice(string deviceId)
{
    var mediaCapture = new MediaCapture();
    var mediaCaptureSettings = new MediaCaptureInitializationSettings
    {
        VideoDeviceId = deviceId
    };
    await mediaCapture.InitializeAsync(mediaCaptureSettings);
    var previewElement = new CaptureElement
    {
        Source = mediaCapture
    };
    CamerasDisplayGrid.Children.Add(previewElement);
    await mediaCapture.StartPreviewAsync();
}

What I want to achieve is to get the preview of several cameras in the screen at the same time.

Please advice. Thank you in advance

Upvotes: 1

Views: 500

Answers (2)

James
James

Reputation: 2610

maybe this link can help: http://social.msdn.microsoft.com/Forums/sr-Cyrl-CS/winappswithcsharp/thread/13d2ce8f-de6d-47c0-8992-4d443a49326f

It's theoretically possible from an application perspective, but there are hardware limitations also in place.

Upvotes: 1

vm2p
vm2p

Reputation: 1

I had the same problem and here is what I did:

  1. Create a canvas object
  2. Insert in that canvas object as many capture elements as I wanted
  3. Enumerate all the cameras available with DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
  4. Associate every camera id that i find with a capture element.
  5. Deploy.

However, when I run the app starting with vs 11 it only shows one active camera, but, when I run it from start menu, it shows me all the cameras I have.

Upvotes: 0

Related Questions