face tracking rotation情報の表示方法

2
1.MainWindow.xaml の編集 Rotation の内容を表示する場所を作る <Viewbox Grid.Row="1" Stretch="Uniform" HorizontalAlignment="Center"> <Grid Name="MainGrid" Width="640" Height="480"> <Image Name="ColorImage"/> <local:FaceTrackingViewer x:Name="faceTrackingViewer" /> < TextBlock x : Name ="RotationInfo" FontSize ="24" HorizontalAlignment ="Left"/> </Grid> </Viewbox> 2.FaceTrackingViewer.xaml.cs の編集 Public メンバ変数の追加 public static string RotationInfoText; OnFrameReady 関数内の lastFaceTrackSucceeded 内で RotationInfoText の更新 /// <summary> /// Updates the face tracking information for this skeleton /// </summary> internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage, Skeleton skeletonOfInterest) { ・・・ this.lastFaceTrackSucceeded = frame.TrackSuccessful; if (this.lastFaceTrackSucceeded) { //Console.WriteLine(frame.Rotation.X.ToString() + " " + frame.Rotation.Y.ToString() + " " + frame.Rotation.Z.ToString()); RotationInfoText = string .Format( "{0}, {1}, {2}" , frame.Rotation.X, frame.Rotation.Y, frame.Rotation.Z); ・・・ 3.MainWindow.xaml.cs の編集 KinectSensorOnAllFramesReady イベントハンドラ内でカラー画像取得後、テキスト内容を更新 private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs allFramesReadyEventArgs) { ・・・ colorImageFrame.CopyPixelDataTo(this.colorImageData); this.colorImageWritableBitmap.WritePixels( new Int32Rect(0, 0, colorImageFrame.Width, colorImageFrame.Height), this.colorImageData, colorImageFrame.Width * Bgr32BytesPerPixel,

Upload: satoshi-fujimoto

Post on 29-Jul-2015

88 views

Category:

Software


4 download

TRANSCRIPT

Page 1: Face Tracking Rotation情報の表示方法

1.MainWindow.xamlの編集Rotationの内容を表示する場所を作る

<Viewbox Grid.Row="1" Stretch="Uniform" HorizontalAlignment="Center">

<Grid Name="MainGrid" Width="640" Height="480">

<Image Name="ColorImage"/>

<local:FaceTrackingViewer x:Name="faceTrackingViewer" />

< TextBlock x : Name ="RotationInfo" FontSize ="24" HorizontalAlignment ="Left"/>

</Grid>

</Viewbox>

2.FaceTrackingViewer.xaml.csの編集Public メンバ変数の追加public static string RotationInfoText;

OnFrameReady関数内の lastFaceTrackSucceeded内で RotationInfoTextの更新

/// <summary>

/// Updates the face tracking information for this skeleton

/// </summary>

internal void OnFrameReady(KinectSensor kinectSensor, ColorImageFormat

colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage,

Skeleton skeletonOfInterest)

{

・・・ this.lastFaceTrackSucceeded = frame.TrackSuccessful;

if (this.lastFaceTrackSucceeded)

{

//Console.WriteLine(frame.Rotation.X.ToString() + " " +

frame.Rotation.Y.ToString() + " " + frame.Rotation.Z.ToString());

RotationInfoText = string .Format( "{0}, {1}, {2}" , frame.Rotation.X,

frame.Rotation.Y, frame.Rotation.Z);

・・・

3.MainWindow.xaml.csの編集KinectSensorOnAllFramesReadyイベントハンドラ内でカラー画像取得後、テキスト内容を更新 private void KinectSensorOnAllFramesReady(object sender, AllFramesReadyEventArgs

allFramesReadyEventArgs)

{

・・・

colorImageFrame.CopyPixelDataTo(this.colorImageData);

this.colorImageWritableBitmap.WritePixels(

new Int32Rect(0, 0, colorImageFrame.Width, colorImageFrame.Height),

this.colorImageData,

colorImageFrame.Width * Bgr32BytesPerPixel,

Page 2: Face Tracking Rotation情報の表示方法

0);

RotationInfo.Text = FaceTrackingViewer .RotationInfoText;

}

・・・

4.実行する

画像の左上に rotationの角度が表示されることを確認