public void GetInterpolatedFrameFromTime(Frame toFill, Int64 time, Int64 sourceTime) {
   UInt64 size = GetInterpolatedFrameSize(time);
   IntPtr trackingBuffer = Marshal.AllocHGlobal((Int32)size);
   eLeapRS result = LeapC.InterpolateFrameFromTime(_leapConnection, time, sourceTime, trackingBuffer, size);
   reportAbnormalResults("LeapC get interpolated frame from time call was ", result);
   if (result == eLeapRS.eLeapRS_Success) {
     LEAP_TRACKING_EVENT tracking_evt;
     StructMarshal<LEAP_TRACKING_EVENT>.PtrToStruct(trackingBuffer, out tracking_evt);
     toFill.CopyFrom(ref tracking_evt);
   }
   Marshal.FreeHGlobal(trackingBuffer);
 }
Exemplo n.º 2
0
        public void GetInterpolatedLeftRightTransform(Int64 time,
                                                      Int64 sourceTime,
                                                      Int64 leftId,
                                                      Int64 rightId,
                                                      out LeapTransform leftTransform,
                                                      out LeapTransform rightTransform)
        {
            leftTransform  = LeapTransform.Identity;
            rightTransform = LeapTransform.Identity;

            UInt64  size           = GetInterpolatedFrameSize(time);
            IntPtr  trackingBuffer = Marshal.AllocHGlobal((Int32)size);
            eLeapRS result         = LeapC.InterpolateFrameFromTime(_leapConnection, time, sourceTime, trackingBuffer, size);

            reportAbnormalResults("LeapC get interpolated frame from time call was ", result);

            if (result == eLeapRS.eLeapRS_Success)
            {
                LEAP_TRACKING_EVENT tracking_evt;
                StructMarshal <LEAP_TRACKING_EVENT> .PtrToStruct(trackingBuffer, out tracking_evt);

                int             id;
                LEAP_VECTOR     position;
                LEAP_QUATERNION orientation;

                long handPtr = tracking_evt.pHands.ToInt64();
                long idPtr   = handPtr + _handIdOffset;
                long posPtr  = handPtr + _handPositionOffset;
                long rotPtr  = handPtr + _handOrientationOffset;
                int  stride  = StructMarshal <LEAP_HAND> .Size;

                for (uint i = tracking_evt.nHands; i-- != 0; idPtr += stride, posPtr += stride, rotPtr += stride)
                {
                    id = Marshal.ReadInt32(new IntPtr(idPtr));
                    StructMarshal <LEAP_VECTOR> .PtrToStruct(new IntPtr(posPtr), out position);

                    StructMarshal <LEAP_QUATERNION> .PtrToStruct(new IntPtr(rotPtr), out orientation);

                    LeapTransform transform = new LeapTransform(position.ToLeapVector(), orientation.ToLeapQuaternion());
                    if (id == leftId)
                    {
                        leftTransform = transform;
                    }
                    else if (id == rightId)
                    {
                        rightTransform = transform;
                    }
                }
            }

            Marshal.FreeHGlobal(trackingBuffer);
        }
Exemplo n.º 3
0
        public void GetInterpolatedFrameFromTime(Frame toFill, long time, long sourceTime)
        {
            ulong   interpolatedFrameSize = this.GetInterpolatedFrameSize(time);
            IntPtr  pEvent = Marshal.AllocHGlobal((int)interpolatedFrameSize);
            eLeapRS result = LeapC.InterpolateFrameFromTime(this._leapConnection, time, sourceTime, pEvent, interpolatedFrameSize);

            this.reportAbnormalResults("LeapC get interpolated frame from time call was ", result);
            if (result == eLeapRS.eLeapRS_Success)
            {
                LEAP_TRACKING_EVENT leap_tracking_event;
                StructMarshal <LEAP_TRACKING_EVENT> .PtrToStruct(pEvent, out leap_tracking_event);

                toFill.CopyFrom(ref leap_tracking_event);
            }
            Marshal.FreeHGlobal(pEvent);
        }
Exemplo n.º 4
0
        public void GetInterpolatedLeftRightTransform(long time, long sourceTime, long leftId, long rightId, out LeapTransform leftTransform, out LeapTransform rightTransform)
        {
            leftTransform  = LeapTransform.Identity;
            rightTransform = LeapTransform.Identity;
            ulong   interpolatedFrameSize = this.GetInterpolatedFrameSize(time);
            IntPtr  pEvent = Marshal.AllocHGlobal((int)interpolatedFrameSize);
            eLeapRS result = LeapC.InterpolateFrameFromTime(this._leapConnection, time, sourceTime, pEvent, interpolatedFrameSize);

            this.reportAbnormalResults("LeapC get interpolated frame from time call was ", result);
            if (result == eLeapRS.eLeapRS_Success)
            {
                LEAP_TRACKING_EVENT leap_tracking_event;
                StructMarshal <LEAP_TRACKING_EVENT> .PtrToStruct(pEvent, out leap_tracking_event);

                int  num3   = leap_tracking_event.pHands.ToInt32();
                int  num4   = num3 + _handIdOffset;
                int  num5   = num3 + _handPositionOffset;
                int  num6   = num3 + _handOrientationOffset;
                int  size   = StructMarshal <LEAP_HAND> .Size;
                uint nHands = leap_tracking_event.nHands;
                while (nHands-- != 0)
                {
                    LEAP_VECTOR     leap_vector;
                    LEAP_QUATERNION leap_quaternion;
                    int             num2 = Marshal.ReadInt32(new IntPtr(num4));
                    StructMarshal <LEAP_VECTOR> .PtrToStruct(new IntPtr(num5), out leap_vector);

                    StructMarshal <LEAP_QUATERNION> .PtrToStruct(new IntPtr(num6), out leap_quaternion);

                    LeapTransform transform = new LeapTransform(leap_vector.ToLeapVector(), leap_quaternion.ToLeapQuaternion());
                    if (num2 == leftId)
                    {
                        leftTransform = transform;
                    }
                    else if (num2 == rightId)
                    {
                        rightTransform = transform;
                    }
                    num4 += size;
                    num5 += size;
                    num6 += size;
                }
            }
            Marshal.FreeHGlobal(pEvent);
        }