/// <summary>
 /// Creates a new feature vector from the tracking result.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>An option of newly created Single array.</returns>
 public Option<Array> Compute(TrackingResult result)
 {
     Single[] feature = null;
       if (result.RightHandRelPos.IsSome && result.DepthBoundingBoxes.Count > 0) {
     var pos = result.RightHandRelPos.Value;
     var ptr = ComputeFeature(pos, result.DepthImage, result.DepthBoundingBoxes.Last(),
     result.ColorImage, result.ColorBoundingBoxes.LastOrDefault());
     if (!ptr.Equals(IntPtr.Zero)) {
       feature = new Single[FeatureLength];
       Marshal.Copy(ptr, feature, 0, FeatureLength);
       return new Some<Array>(feature);
     }
       }
       return new None<Array>();
 }
 /// <summary>
 /// Creates a new feature array.
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Option<Array> Compute(TrackingResult result)
 {
     if (result.RightHandRelPos.IsSome) {
     var feature = new float[MotionFeatureLength + DescriptorLength];
     var relPos = result.RightHandRelPos.Value;
     feature[0] = (float)relPos.X;
     feature[1] = (float)relPos.Y;
     feature[2] = (float)relPos.Z;
     AddImageFeature(result.ColorImage, result.ColorBoundingBoxes.Last(), feature,
                 MotionFeatureLength);
     AddImageFeature(result.DepthImage, result.DepthBoundingBoxes.Last(), feature,
                 MotionFeatureLength + FeatureImageWidth * FeatureImageWidth);
     return new Some<Array>(feature);
       }
       return new None<Array>();
 }
 /// <summary>
 /// Creates a new feature array.
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Option<Array> Compute(TrackingResult result)
 {
     if (result.RightHandRelPos.IsSome) {
     var colorBb = result.ColorBoundingBoxes.Last();
     var descriptorLen = colorBb.Width * colorBb.Height;
     var feature = new float[MotionFeatureLength + descriptorLen + 2];
     var relPos = result.RightHandRelPos.Value;
     feature[0] = (float)relPos.X;
     feature[1] = (float)relPos.Y;
     feature[2] = (float)relPos.Z;
     feature[3] = colorBb.Width;
     feature[4] = colorBb.Height;
     AddImageFeature(result.ColorImage, colorBb, feature, MotionFeatureLength + 2);
     return new Some<Array>(feature);
       }
       return new None<Array>();
 }
 /// <summary>
 /// Creates a new feature array.
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Option <Array> Compute(TrackingResult result)
 {
     if (result.RightHandRelPos.IsSome)
     {
         var feature = new float[MotionFeatureLength + DescriptorLength];
         var relPos  = result.RightHandRelPos.Value;
         feature[0] = (float)relPos.X;
         feature[1] = (float)relPos.Y;
         feature[2] = (float)relPos.Z;
         AddImageFeature(result.ColorImage, result.ColorBoundingBoxes.Last(), feature,
                         MotionFeatureLength);
         AddImageFeature(result.DepthImage, result.DepthBoundingBoxes.Last(), feature,
                         MotionFeatureLength + FeatureImageWidth * FeatureImageWidth);
         return(new Some <Array>(feature));
     }
     return(new None <Array>());
 }
 /// <summary>
 /// Creates a new feature vector from the tracking result.
 /// </summary>
 /// <param name="result"></param>
 /// <returns>An option of newly created Single array.</returns>
 public Option <Array> Compute(TrackingResult result)
 {
     Single[] feature = null;
     if (result.RightHandRelPos.IsSome && result.DepthBoundingBoxes.Count > 0)
     {
         var pos = result.RightHandRelPos.Value;
         var ptr = ComputeFeature(pos, result.DepthImage, result.DepthBoundingBoxes.Last(),
                                  result.ColorImage, result.ColorBoundingBoxes.LastOrDefault());
         if (!ptr.Equals(IntPtr.Zero))
         {
             feature = new Single[FeatureLength];
             Marshal.Copy(ptr, feature, 0, FeatureLength);
             return(new Some <Array>(feature));
         }
     }
     return(new None <Array>());
 }
 /// <summary>
 /// Creates a new feature array.
 /// </summary>
 /// <param name="result"></param>
 /// <returns></returns>
 public Option <Array> Compute(TrackingResult result)
 {
     if (result.RightHandRelPos.IsSome)
     {
         var colorBb       = result.ColorBoundingBoxes.Last();
         var descriptorLen = colorBb.Width * colorBb.Height;
         var feature       = new float[MotionFeatureLength + descriptorLen + 2];
         var relPos        = result.RightHandRelPos.Value;
         feature[0] = (float)relPos.X;
         feature[1] = (float)relPos.Y;
         feature[2] = (float)relPos.Z;
         feature[3] = colorBb.Width;
         feature[4] = colorBb.Height;
         AddImageFeature(result.ColorImage, colorBb, feature, MotionFeatureLength + 2);
         return(new Some <Array>(feature));
     }
     return(new None <Array>());
 }
Beispiel #7
0
    void UpdateDisplay(TrackingResult result) {
      colorCanvas.Children.Clear();
      depthCanvas.Children.Clear();
      if (result.DepthBoundingBoxes.Count > 0) {
        VisualUtil.DrawRectangle(depthCanvas, result.DepthBoundingBoxes.Last(), Brushes.Red,
                    (float)depthCanvas.ActualWidth / HandInputParams.DepthWidth);
      }
      if (handTracker != null) {
        if (handTracker is SalienceHandTracker)
          UpdateSalienceHandTrackerDisplay();
        else if (handTracker is StipHandTracker)
          UpdateStipHandTrackerDisplay();
        else if (handTracker is SimpleSkeletonHandTracker) {
          UpdateSimpleHandTrackerDisplay();
        }
      }
      if (displayDebug) {
        if (result.DepthImage != null)
          debugDepthDisplayManager.UpdateBitmap(result.DepthImage.Bytes);

        if (result.ColorImage != null)
          debugColorDisplayManager.UpdateBitmap(result.ColorImage.Bytes);
      }
    }
 /// <summary>
 /// Synchronized method. Updates gesture recognition with the current input.
 /// </summary>
 /// <param name="result"></param>
 /// <param name="visualize"></param>
 /// <returns></returns>
 public String Update(TrackingResult result, bool visualize = false)
 {
     String gesture = "";
       if (result.RightHandRelPos.IsSome && result.DepthBoundingBoxes.Count > 0) {
     var pos = result.RightHandRelPos.Value;
     var image = result.DepthImage;
     var skin = result.ColorImage;
     image.ROI = result.DepthBoundingBoxes.Last();
     lock (this) {
       gesture = processor.Update((float)pos.X, (float)pos.Y, (float)pos.Z, image.Ptr,
                               skin.Ptr, visualize);
       reset = false;
     }
     image.ROI = Rectangle.Empty;
       } else {
     // No hand detected (hand may be out of field of view).
     if (!reset) {
       reset = true;
       lock (this) {
     processor.Reset();
       }
     }
       }
       return gesture;
 }