/// <summary> /// Throws an <see cref="AzureKinectException"/> if the result is not <see cref="NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED"/>. /// </summary> /// <param name="result">The result to check.</param> internal static void ThrowIfNotSuccess(NativeMethods.k4a_result_t result) { if (result != NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED) { throw new AzureKinectException($"result = {result}"); } }
/// <summary> /// Initializes a new instance of the <see cref="Tracker"/> class. /// </summary> /// <param name="calibration"></param> /// <param name="configuration"></param> public Tracker(Calibration calibration, TrackerConfiguration configuration) { NativeMethods.k4a_result_t result = NativeMethods.k4abt_tracker_create(ref calibration, configuration, out this.handle); if (result == NativeMethods.k4a_result_t.K4A_RESULT_FAILED) { throw new AzureKinectException("Couldn't create tracker"); } }
private static void CurrentDomain_Exit(object sender, EventArgs e) { NativeMethods.k4a_result_t result = NativeMethods.k4a_set_debug_message_handler(null, IntPtr.Zero, LogLevel.Off); if (result != NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED) { Trace.WriteLine("Failed to close the debug message handler"); } }
/// <summary> /// Initializes the <see cref="Logger"/> class to begin receiving messages from the Azure Kinect Sensor SDK. /// </summary> public static void Initialize() { lock (SyncRoot) { if (Logger.isInitialized) { return; } AppDomain.CurrentDomain.ProcessExit += CurrentDomain_Exit; AppDomain.CurrentDomain.DomainUnload += CurrentDomain_Exit; NativeMethods.k4a_result_t result = NativeMethods.k4a_set_debug_message_handler(DebugMessageHandler, IntPtr.Zero, LogLevel.Trace); if (result != NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED) { throw new AzureKinectException("Failed to set the Debug Message Handler"); } Logger.isInitialized = true; } }
/// <summary> /// Get the joint information for a particular person index from the frame /// </summary> /// <param name="index">The index of the body of which the joint information is queried.</param> /// <returns>If successful this contains the body skeleton information.</returns> public Skeleton GetBodySkeleton(uint index) { NativeMethods.k4a_result_t result = NativeMethods.k4abt_frame_get_body_skeleton(this.handle, (UIntPtr)index, out Skeleton skeleton); return(result == NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED ? skeleton : (default));
/// <summary> /// Determines if the <see cref="NativeMethods.k4a_result_t"/> is a success. /// </summary> /// <param name="result">The result to check if it is a success.</param> /// <returns><c>True</c> if the result is a success;otherwise <c>false</c>.</returns> internal static bool IsSuccess(NativeMethods.k4a_result_t result) { return(result == NativeMethods.k4a_result_t.K4A_RESULT_SUCCEEDED); }