The program I would like to make is like this:
Track the joint of right hand and on that coordinate, an ellipse is displayed.
I made this ellipse track my hand.
I want to make the trail of ellipse not disappear, so the ellipse can be used like a brush tool.
I added this statement,
canvasPaint.Children.Add(ellipse);
but it doesn't work. Actually, the program stops running because of this statement.
So, how can I draw multiple ellipses like in this video ?
I am developing in c# and xaml.
Do I need openni? is it necessary?
I solved this problem by myself :) The problem occurred because 1. I didn't make a new object and just added an existing ellipse. 2. I should have handled Zindex to print ellipses in front of Kinect video.
So I implemented a method drawEllipse,
void drawEllipse(SolidColorBrush c, double x, double y)
{
Ellipse ellipse = new Ellipse()
{
Fill = c,
Height = 30,
Width = 30,
Opacity = 0.5
};
Canvas.SetLeft(ellipse, x);
Canvas.SetTop(ellipse, y);
canvasPaint.Children.Add(ellipse);
}
and handled the property Zindex.
<Window x:Class="KinectPractice01.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="480" Width="640">
<Grid>
<Image Height="441" Canvas.Left="10" Canvas.Top="0" Width="618" Name="image1" Panel.ZIndex="0"/>
<Canvas Margin="0,0,0,0">
<Canvas Name="canvasPaint" Width="640" Height="480" Margin="90,0,0,0" Panel.ZIndex="1"/>
<TextBox Height="23" Canvas.Left="32" TextWrapping="Wrap" Text="null" Canvas.Top="10" Width="120" Name="textbox1"/>
<Ellipse Opacity="0.5" Fill="White" HorizontalAlignment="Left" Height="30" Stroke="Black" VerticalAlignment="Top" Width="30" Name="ellipse1"/>
<Ellipse Opacity="0.5" Fill="Cyan" HorizontalAlignment="Left" Height="30" Stroke="Black" VerticalAlignment="Top" Width="30" Name="ellipse2"/>
</Canvas>
</Grid>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.