face tracking rotation情報の表示方法
Post on 29-Jul-2015
88 Views
Preview:
TRANSCRIPT
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,
0);
RotationInfo.Text = FaceTrackingViewer .RotationInfoText;
}
・・・
4.実行する
画像の左上に rotationの角度が表示されることを確認
top related