Multiple VideoCaptureElement's From One Source

Jan 25, 2010 at 11:20 AM

I was wondering if it was possible to have multiple VideoCaptureElement's be fed from a single video source?

Coordinator
Jan 25, 2010 at 5:58 PM
Not sure what you are asking.  But you can have multiple VideoCaptureElements.
Jan 25, 2010 at 6:10 PM

But can I have multiple instances that both have the same DsDevice as their VideoCaptureDevice? I tried doing it, but the second instance always comes up blank.

Coordinator
Jan 25, 2010 at 6:28 PM
If you want to duplicate the visual, either use the VisualBrush or use VideoCaptureElement.CloneD3DRenderer and add what is returned to your visual tree.
Jan 25, 2010 at 9:53 PM

Those methods get me part of the way there. However, I'm looking for the different instances to be more independant. Right now, if I create a couple of instances fed from one VideoCaptureElement's DsDevice via CloneD3DRenderer, and then close the parent instance, the other instances die as well.

By the way, I'm really liking the work you've done. It's very impressive.

Coordinator
Jan 25, 2010 at 9:56 PM
Thank you!  It's been a labor of love!

I'm not sure you can do exactly what you are looking for.  Most (if not all) web cam devices allow for one open connection to them at a time.

-Jer
Jan 25, 2010 at 10:08 PM

Ok, That's kind of what I was thinking. My project is going to end up supporting as many devices as you have resources for. In some cases, mostly for testing purposes, I need to be able to have multiple video instances from a single source.

Maybe what I'll do is for the first instance that is created of a device, I'll make that the parent. If another instance is created, I'll pull the VideoCaptureElement out of the parent instance and put a clone in it's place, and the second instance will also have a clone. So, there will be three total instances, but the visible ones can be closed independently. When the last visible instance is closed, the source will be closed as well. Make sense?

Coordinator
Jan 25, 2010 at 10:12 PM
That makes sense.  You might want to also check into some optimizations, such as maybe not invalidating the D3DImage if the specific element is not in the visual tree (not sure I already do that).  This should work in a "cloned" scenario...but not a VisualBrush one.

-Jer
Jan 26, 2010 at 1:53 AM

Now it seems that I can't programmatically add a VideoCaptureElement to a container.

This is what I'm doing:

 

var vce = new VideoCaptureElement();
            vce.DesiredPixelHeight = 720;
            vce.DesiredPixelWidth = 1280;
            vce.VideoCaptureDevice = (DsDevice)videoCapDevices.SelectedItem; ;
            vce.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            vce.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            stack.Children.Add(vce);

When this code executes, nothing happens. Actually, an exception is thrown from WPFMediaKit.dll, but I can't seem to track down where it is coming from.

 

Coordinator
Jan 26, 2010 at 2:07 AM
What happens if you put a vce.BeginInit() before you set your values and and vce.EndInit() before you add it to your children?

On Mon, Jan 25, 2010 at 5:53 PM, kettch <notifications@codeplex.com> wrote:

From: kettch

Now it seems that I can't programmatically add a VideoCaptureElement to a container.

This is what I'm doing:

 

var vce = new VideoCaptureElement();
            vce.DesiredPixelHeight = 720;
            vce.DesiredPixelWidth = 1280;
            vce.VideoCaptureDevice = (DsDevice)videoCapDevices.SelectedItem; ;
            vce.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            vce.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            stack.Children.Add(vce);

When this code executes, nothing happens. Actually, an exception is thrown from WPFMediaKit.dll, but I can't seem to track down where it is coming from.

 

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFMediaKit@discussions.codeplex.com)

To start a new discussion for this project, email WPFMediaKit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 26, 2010 at 8:03 PM

Cool! That did the trick. The only trouble at this point is that if I remove the VideoCaptureElement from the visual tree, the clones seem to die too. It doesn't seem to want to render unless it is part of a visual tree. You mentioned optimizing when D3DImage is invalidated. I'm going to have to do some reading until I figure out where to do that.

Would it make more sense to use the sample grabber to just stream the video to any potential child instances?

Coordinator
Jan 26, 2010 at 8:05 PM
Try setting the UnloadedBehavior to Manual.  Just remember to run .Close() when you are done with the instance.
Jan 27, 2010 at 3:32 AM

Sweet. This is working pretty well. Thanks!

Jan 27, 2010 at 7:42 AM

Oh, I just remembered what it was that I was going to ask. The webcam that I am using is a Microsoft LifeCam Cinema, and it's supposed to be widescreen. In the app that comes with the camera, it's widescreen, but when I load it into a VideoCaptureElement, it is cropped to a 4:3 aspect ratio.

Coordinator
Jan 27, 2010 at 7:43 AM
What is your "DesiredPixelWidth/Height" set to?  Does it looked stretched?  There is a Stretch property you can set in that case.

On Tue, Jan 26, 2010 at 11:42 PM, kettch <notifications@codeplex.com> wrote:

From: kettch

Oh, I just remembered what it was that I was going to ask. The webcam that I am using is a Microsoft LifeCam Cinema, and it's supposed to be widescreen. In the app that comes with the camera, it's widescreen, but when I load it into a VideoCaptureElement, it is cropped to a 4:3 aspect ratio.

Read the full discussion online.

To add a post to this discussion, reply to this email (WPFMediaKit@discussions.codeplex.com)

To start a new discussion for this project, email WPFMediaKit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jan 27, 2010 at 9:27 AM

The maximum the camera supports is 1280x720, so that's what I set the DesiredPixel* properties to. Comparing screenshots from the two of them, it's definitely cropping and not stretching. If I grab frames it's still cropped, so I don't think it has anything to do with the layout.

Mar 21, 2010 at 3:13 AM

Hi kettch,

Did you ever figure this out with the Microsoft Lifecam Cinema? I'm also wanting to get the higher widescreen resolutions from the camera but am unable to get them. According to AMCAP, you can achieve the resolutions at RBG 24 but if i set the desiredWidth/desiredHeight, it stretches the panel, but the output is zoomed in and cropped at around 80% of the original resolution from the top/center.

Feb 20, 2014 at 6:22 PM
Hi What did the trick, i am trying to do the same can you share regarding clone webcam single source