VideoCaptureElement not displaying any video

May 1, 2009 at 4:55 PM
I am trying to get my webcam video to display in my WPF application. (I am running Windows XP)

I can see that it connects to my camera, because the camera light lights up when I run the app. No Video is showing though. Here is my xaml:

 <Grid>
       
            <Border BorderBrush="Blue"  BorderThickness="2,2,2,2" Background="Beige" CornerRadius="5,5,5,5">
                <Grid Width="320"
                                   Height="240">
                    <WPFMediaKit:VideoCaptureElement x:Name="videoCapElement"
                                 LoadedBehavior="Play"
                                 UnloadedBehavior="Stop"
                                 DesiredPixelWidth="320"
                                 DesiredPixelHeight="240" IsRenderingEnabled="True"  Visibility="Visible" 
                                  Stretch="Fill"
                               ToolTip="test" 
                                 VideoCaptureSource="{Binding Path=CaptureDeviceName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Window1}}}"
                                 FPS="30" />
                </Grid>
            </Border>

    </Grid>

Code behind: 
public static readonly DependencyProperty CaptureDeviceNameProperty =
DependencyProperty.Register("CaptureDeviceName",
typeof(string),
typeof(Window1),
new UIPropertyMetadata(null));

public string CaptureDeviceName {
get { return (string) GetValue(CaptureDeviceNameProperty); }
set { SetValue(CaptureDeviceNameProperty, value); }
}

public Window1() {
string[] capDevices;

// Get the collection of video devices
capDevices = MultimediaUtil.VideoInputNames;

if (capDevices.Length > 0) {
CaptureDeviceName = capDevices[0];
}

InitializeComponent();
}



Any help is greatly appericiated
May 1, 2009 at 5:58 PM
Updated xaml and the NaturalVideoWidth/Height are 0; HasVideo is false... and there is no VideoImage:

<Grid>
        <StackPanel>
            <Border BorderBrush="Blue"  BorderThickness="2,2,2,2" Background="Beige" CornerRadius="5,5,5,5">
                <Grid Width="320"
                                   Height="240">
                    <WPFMediaKit:VideoCaptureElement x:Name="videoCapElement"
                                 LoadedBehavior="Play"
                                 UnloadedBehavior="Stop" 
                                 DesiredPixelWidth="320"
                                 DesiredPixelHeight="240" IsRenderingEnabled="True"
                                 VideoCaptureSource="{Binding Path=CaptureDeviceName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Window1}}}"
                                 FPS="30"  />
                </Grid>
            </Border>
            <Label Content="{Binding ElementName=videoCapElement, Path=VideoCaptureSource}" />
            <Label Content="{Binding ElementName=videoCapElement, Path=NaturalVideoWidth}" />
            <Label Content="{Binding ElementName=videoCapElement, Path=NaturalVideoHeight}" />
            <CheckBox IsChecked="{Binding ElementName=videoCapElement, Path=HasVideo, Mode=OneWay}" />
            <Image Source="{Binding ElementName=videoCapElement, Path=VideoImage, Mode=OneWay}" />
        </StackPanel>
    </Grid>