I have found a lot of similar posts about this, but none that are recent or actually address the issue. Hoping someone can help. Sorry if this is duplicate. I am not a WPF or xaml expert and have cobbled together code from various sources.
Everything is working as I am expecting it to, but there is a flicker (either solid white or black background) on the Image control when the Visibility of the images change when over the top of the video. If I hide the video as a test, there is no flicker, which suggests to me a rendering/drawing problem with the layering of the images and video. I started by borrowing from the Microsoft Kinect V2 samples and then building from there, but I don't think the Kinect itself would be causing the issue. All of the PC's I have been testing on exhibit this behaviour and are all recent powerful machines that have no problem running more complex applications.
Basic Video setup code (because I read about it somewhere, I didn't come up with it myself)
MediaPlayer mp = new MediaPlayer();
mp.ScrubbingEnabled = true;
mp.MediaEnded += MediaElement_MediaEnded;
mp.MediaOpened += MediaElement_MediaOpened;
VideoDrawing vd = new VideoDrawing();
vd.Player = mp;
vd.Rect = new Rect(0, 0, 1920, 1080);
DrawingBrush db = new DrawingBrush(vd);
grid.Background = db;
Title="Kinect 2 Face HD (.NET)"
Height="735" Width="770" Loaded="Window_Loaded" Closed="Window_Closing"
WindowState="Maximized" WindowStyle="None" ResizeMode="NoResize"
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Bottom">
<Image Name="noPerson" Source="images/noone.png" Stretch="None" >
<Image Name="seenPerson" Source="images/can_you_see.png" Stretch="None" Visibility="Collapsed" >
<Image Name="ignorePerson" Source="images/ignored.png" Stretch="None" Visibility="Collapsed" >
Switching the images example code (there are 3 variations):-
noPerson.Visibility = Visibility.Collapsed;
ignorePerson.Visibility = Visibility.Visible;
seenPerson.Visibility = Visibility.Collapsed;
I've looked various things
- Setting cachemode on images
- Doublebuffering doesn't seem to be thing anymore with modern WPF apps?
- Using opacity instead of visibility
- Stopping the video before the visibility is set (although probably doesn't matter without an actual delay timer?)
- Although the Kinect is firing at 30fps, the "person state change" events are only fired once and the switching code only fires once i.e. there are flags set to stop repeat entries
It doesn't do it all of the time, just most of the time.
Any help would be appreciated