Exemple #1
0
 public ImageData(Image.CameraType camera, LEAP_IMAGE image, DistortionData distortionData)
 {
     this.camera              = camera;
     this._properties         = image.properties;
     this.DistortionMatrixKey = image.matrix_version;
     this.DistortionData      = distortionData;
     this._object             = MemoryManager.GetPinnedObject(image.data);
     this.byteOffset          = image.offset;
 }
 public Vector RectilinearToPixel(Image.CameraType camera, Vector ray) {
   LEAP_VECTOR rayStruct = new LEAP_VECTOR(ray);
   LEAP_VECTOR pixel = LeapC.LeapRectilinearToPixel(_leapConnection,
          (camera == Image.CameraType.LEFT ?
          eLeapPerspectiveType.eLeapPerspectiveType_stereo_left :
          eLeapPerspectiveType.eLeapPerspectiveType_stereo_right),
          rayStruct);
   return new Vector(pixel.x, pixel.y, pixel.z);
 }
 public Vector PixelToRectilinear(Image.CameraType camera, Vector pixel) {
   LEAP_VECTOR pixelStruct = new LEAP_VECTOR(pixel);
   LEAP_VECTOR ray = LeapC.LeapPixelToRectilinear(_leapConnection,
          (camera == Image.CameraType.LEFT ?
          eLeapPerspectiveType.eLeapPerspectiveType_stereo_left :
          eLeapPerspectiveType.eLeapPerspectiveType_stereo_right),
          pixelStruct);
   return new Vector(ray.x, ray.y, ray.z);
 }
    private DistortionData createDistortionData(LEAP_IMAGE image, Image.CameraType camera) {
      DistortionData distortionData = new DistortionData();
      distortionData.Version = image.matrix_version;
      distortionData.Width = LeapC.DistortionSize; //fixed value for now
      distortionData.Height = LeapC.DistortionSize; //fixed value for now

      //Visit LeapC.h for more details.  We need to marshal the float data manually
      //since the distortion struct cannot be represented safely in c#
      distortionData.Data = new float[(int)(distortionData.Width * distortionData.Height * 2)]; //2 float values per map point
      Marshal.Copy(image.distortionMatrix, distortionData.Data, 0, distortionData.Data.Length);

      if (LeapDistortionChange != null) {
        LeapDistortionChange.DispatchOnContext(this, EventContext, new DistortionEventArgs(distortionData, camera));
      }
      return distortionData;
    }
        private DistortionData createDistortionData(LEAP_IMAGE image, Image.CameraType camera)
        {
            DistortionData distortionData = new DistortionData();

            distortionData.Version = image.matrix_version;
            distortionData.Width   = LeapC.DistortionSize;                                               //fixed value for now
            distortionData.Height  = LeapC.DistortionSize;                                               //fixed value for now
            distortionData.Data    = new float[(int)(distortionData.Width * distortionData.Height * 2)]; //2 float values per map point
            LEAP_DISTORTION_MATRIX matrix;

            StructMarshal <LEAP_DISTORTION_MATRIX> .PtrToStruct(image.distortionMatrix, out matrix);

            Array.Copy(matrix.matrix_data, distortionData.Data, matrix.matrix_data.Length);

            if (LeapDistortionChange != null)
            {
                LeapDistortionChange.DispatchOnContext <DistortionEventArgs>(this, EventContext, new DistortionEventArgs(distortionData, camera));
            }
            return(distortionData);
        }
 public DistortionEventArgs(DistortionData distortion, Image.CameraType camera) : base(LeapEvent.EVENT_DISTORTION_CHANGE)
 {
     this.distortion = distortion;
     this.camera     = camera;
 }
Exemple #7
0
        public void UpdateDistMap(DX11RenderContext context, DX11Resource <DX11DynamicTexture2D> texture, Image.CameraType side)
        {
            if (FInvalidate || !texture.Contains(context))
            {
                var fmt = SlimDX.DXGI.Format.R32G32_Float;

                if (texture.Contains(context))
                {
                    var imgdesc = texture[context].Resource.Description;

                    if (imgdesc.Width != ValidImage.DistortionWidth / 2 || imgdesc.Height != ValidImage.DistortionHeight || imgdesc.Format != fmt)
                    {
                        texture.Dispose(context);
                        texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
                    }
                }
                else
                {
                    texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
#if DEBUG
                    texture[context].Resource.DebugName = "DynamicTexture";
#endif
                }

                texture[context].WriteData(ValidImage.Distortion(side), 2);
            }
        }