Home › Forums › Software Development › How to convert EyeX X & Y into Canvas.X, Canvas.Y positions?
- This topic has 2 replies, 2 voices, and was last updated 7 years, 7 months ago by
Denny [Tobii].
Viewing 3 posts - 1 through 3 (of 3 total)
- AuthorPosts
- 29/01/2016 at 12:38 #4209
TRO
ParticipantI am building a very simple WPF app to show the position on a Canvas of both eyes.
I have 2 ellipse, one for each eye on a Canvas.
Obviously the EyeX coordinates don’t map directly into Canvas.X and Canvas.Y positions so how would I achieve this?
thanks
29/01/2016 at 12:45 #4210TRO
ParticipantMy code so far:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.Loaded += MainWindow_Loaded; this.Closing += (s, e) => { this.EyePositionDataStream.Dispose(); }; } private EyeXFramework.EyePositionDataStream EyePositionDataStream { get; set; } private void MainWindow_Loaded(object sender, RoutedEventArgs routedEventArgs) { this.EyePositionDataStream = (Application.Current as App).WpfEyeXHost.CreateEyePositionDataStream(); this.EyePositionDataStream.Next += (s, e) => { txtLeftEye.Text = string.Format("LEFT: X: {0:0.00}, Y: {1:0.00}", e.LeftEye.X, e.LeftEye.Y); txtRightEye.Text = string.Format("RIGHT: X: {0:0.00}, Y: {1:0.00}", e.RightEye.X, e.RightEye.Y); leftEye.SetValue(Canvas.LeftProperty, e.LeftEye.X); leftEye.SetValue(Canvas.TopProperty, e.LeftEye.Y); rightEye.SetValue(Canvas.LeftProperty, e.RightEye.X); rightEye.SetValue(Canvas.TopProperty, e.RightEye.Y); }; } }
23/02/2016 at 16:10 #4524Denny [Tobii]
MemberHi,
I would use the normalized eye coordinates if you want to visualize the eye positions. The positions are in the 0-1 range, so you will need to scale they eyes yourself in the canvas.
stream.Next += (s, e) => { Debug.WriteLine("EyePos = {0} {1} {2} {3}", e.LeftEyeNormalized.X, e.LeftEyeNormalized.Y, e.RightEyeNormalized.X, e.RightEyeNormalized.Y); };
Hope it helps,
Denny
- AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.