/// <summary>
        /// Add a k4a sensor capture to the tracker input queue to generate its body tracking result asynchronously.
        /// </summary>
        /// <param name="capture">sensor capture returned by <see cref="Device.GetCapture(TimeSpan)"/>() from k4a SDK. It should contain the depth data for this function to work.Otherwise the function will return failure.</param>
        /// <param name="timeout">
        /// Specifies the time the function should block waiting to add the sensor capture to the tracker
        /// process queue. 0 is a check of the status without blocking. Passing a value of TimeSpan.FromMilliseconds(-1) will block
        /// indefinitely until the capture is added to the process queue.
        /// </param>
        /// <remarks>
        /// <para>
        /// Add a k4a capture to the tracker input queue so that it can be processed asynchronously to generate the body tracking
        /// result. The processed results will be added to an output queue maintained by k4abt_tracker_t instance. Call
        /// <see cref="PopResult(TimeSpan)"/> to get the result and pop it from the output queue.
        /// If the input queue or output queue is full, this function will block up until the timeout is reached.
        /// Once body_frame data is read, the user must call <see cref="Frame.Dispose()"/>() to return the allocated memory to the SDK</para>
        /// <para>
        /// Upon successfully insert a sensor capture to the input queue this function will return success.
        /// </para>
        /// <para>
        /// This function returns ::K4A_WAIT_RESULT_FAILED when either the tracker is shut down by k4abt_tracker_shutdown() API,
        /// or an internal problem is encountered before adding to the input queue: such as low memory condition,
        /// sensor_capture_handle not containing the depth data, or other unexpected issues.
        /// </para>
        /// </remarks>
        /// <seealso cref="Tracker"/>
        public void EnqueueCapture(Capture capture, TimeSpan timeout)
        {
            SafeHandleZeroOrMinusOneIsInvalid captureHandle = (SafeHandleZeroOrMinusOneIsInvalid)typeof(Capture).GetField("handle", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(capture);

            NativeMethods.k4a_wait_result_t result = NativeMethods.k4abt_tracker_enqueue_capture(this.handle.DangerousGetHandle(), captureHandle.DangerousGetHandle(), (int)timeout.TotalMilliseconds);
            if (result == NativeMethods.k4a_wait_result_t.K4A_WAIT_RESULT_TIMEOUT)
            {
                throw new TimeoutException();
            }
            else if (result == NativeMethods.k4a_wait_result_t.K4A_WAIT_RESULT_FAILED)
            {
                throw new AzureKinectException();
            }
        }
 static extern UInt32 WaitForSingleObject(SafeHandleZeroOrMinusOneIsInvalid hHandle, UInt32 dwMilliseconds);
 static extern int TerminateProcess(SafeHandleZeroOrMinusOneIsInvalid hProcess, uint uExitCode);
 extern static Boolean SetStdHandle(Int32 nStdHandle, SafeHandleZeroOrMinusOneIsInvalid handle);
Beispiel #5
0
 /// <summary>
 /// This method checks if the handle is invalid then it throws error
 /// </summary>
 /// <param name="handle">Accepts handle</param>
 internal static void VerifyValidHandle(SafeHandleZeroOrMinusOneIsInvalid handle)
 {
     if (handle.IsInvalid)
     {
         throw new CryptographicException(SR.Format(SR.Cryptography_OpenInvalidHandle, "Handle"));
     }
 }
Beispiel #6
0
 /// <summary>
 /// This method checks if the handle is invalid then it throws error
 /// </summary>
 /// <param name="handle">Accepts handle</param>
 internal static void VerifyValidHandle(SafeHandleZeroOrMinusOneIsInvalid handle)
 {
     if (handle.IsInvalid)
     {
         //ToDO : Log error. This will be helpful in debugging.
         throw new CryptographicException(SR.Format(SR.Cryptography_OpenInvalidHandle, "Handle"));
     }
 }