Skip to content

Commit

Permalink
Switching to the version 1.9.2 of OrbbecSDK K4A Wrapper. Support for …
Browse files Browse the repository at this point in the history
…new API in this wrapper
  • Loading branch information
bibigone committed Mar 10, 2024
1 parent 54a3ac3 commit 9353597
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 3 deletions.
42 changes: 41 additions & 1 deletion K4AdotNet/Sensor/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,49 @@ public void GetCalibration(DepthMode depthMode, ColorResolution colorResolution,
}

/// <summary>Convenient string representation of object.</summary>
/// <returns><c>Azure Kinect #{SerialNumber}</c></returns>
/// <returns><c>Azure Kinect #{SerialNumber}</c> or <c>"Orbbec Femto #{SerialNumber}</c>.</returns>
public override string ToString()
#if ORBBECSDK_K4A_WRAPPER
=> "Orbbec Femto #" + SerialNumber;
#else
=> "Azure Kinect #" + SerialNumber;
#endif

#if ORBBECSDK_K4A_WRAPPER
/// <summary>Switches device clock sync mode (OrbbecSDK-K4A-Wrapper only).</summary>
/// <param name="timestampMode">Device clock synchronization mode</param>
/// <param name="interval">
/// If <paramref name="timestampMode"/> is <see cref="DeviceClockSyncMode.Reset"/>: The delay time of executing the timestamp reset function after receiving the command or signal in microseconds.
/// If <paramref name="timestampMode"/> is <see cref="DeviceClockSyncMode.Sync"/>: The interval for auto-repeated synchronization, in microseconds. If the value is <see cref="Microseconds32.Zero"/>, synchronization is performed only once.
/// </param>
/// <remarks>
/// This API is used for device clock synchronization mode switching.
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="interval"/> cannot be negative.</exception>
/// <exception cref="ObjectDisposedException">This method cannot be called for disposed object.</exception>
/// <exception cref="DeviceConnectionLostException">Connection with the device has been lost.</exception>
public void SwitchDeviceClockSyncMode(DeviceClockSyncMode timestampMode, Microseconds32 interval)
{
if (interval.ValueUsec < 0)
throw new ArgumentOutOfRangeException(nameof(interval));
CheckResult(NativeApi.DeviceSwitchDeviceClockSyncMode(handle.ValueNotDisposed, timestampMode, (uint)interval.ValueUsec));
}

/// <summary>Enables/disables soft filter for depth camera (OrbbecSDK-K4A-Wrapper only).</summary>
/// <param name="filterSwitch">Device software filtering switch: <see langword="true"/> - enable software filtering; <see langword="false"/> - disable software filtering.</param>
/// <exception cref="ObjectDisposedException">This method cannot be called for disposed object.</exception>
/// <exception cref="DeviceConnectionLostException">Connection with the device has been lost.</exception>
public void SetSoftFilter(bool filterSwitch)
=> CheckResult(NativeApi.DeviceEnableSoftFilter(handle.ValueNotDisposed, filterSwitch ? (byte)1 : (byte)0));

/// <summary>Gets device sync mode (OrbbecSDK-K4A-Wrapper only).</summary>
/// <remarks>The device synchronization mode will change according to the mode configured in the <see cref="StartCameras(DeviceConfiguration)"/> method.</remarks>
/// <exception cref="ObjectDisposedException">This property cannot be called for disposed object.</exception>
/// <seealso cref="DeviceConfiguration.WiredSyncMode"/>
/// <seealso cref="StartCameras(DeviceConfiguration)"/>
public WiredSyncMode WiredSyncMode
=> NativeApi.DeviceGetWiredSyncMode(handle.ValueNotDisposed);
#endif

private void CheckResult(NativeCallResults.Result result, string? invalidOperationMessage = null)
{
Expand Down
18 changes: 18 additions & 0 deletions K4AdotNet/Sensor/DeviceClockSyncMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace K4AdotNet.Sensor
{
#if ORBBECSDK_K4A_WRAPPER
// typedef enum {
// K4A_DEVICE_CLOCK_SYNC_MODE_RESET = 0,
// K4A_DEVICE_CLOCK_SYNC_MODE_SYNC
// } k4a_device_clock_sync_mode_t;
/// <summary>Device clock synchronization mode type. Only for Orbbec-K4A-Wrapper.</summary>
public enum DeviceClockSyncMode : int
{
/// <summary>device clock sync mode is reset</summary>
Reset = 0,

/// <summary>device clock sync mode is asynchronous timing</summary>
Sync,
}
#endif
}
37 changes: 36 additions & 1 deletion K4AdotNet/Sensor/NativeApi.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;

namespace K4AdotNet.Sensor
Expand Down Expand Up @@ -1132,13 +1131,49 @@ public static extern NativeCallResults.Result TransformationDepthImageToPointClo
NativeHandles.ImageHandle xyzImage);

#if ORBBECSDK_K4A_WRAPPER

// K4A_EXPORT k4a_result_t k4a_depth_engine_helper_create(k4a_depthengine_t* handle);
/// <summary>Create depthengine helper (OrbbecSDK-K4A-Wrapper only).</summary>
/// <param name="depthEngineHandle"></param>
/// <returns></returns>
/// <remarks>This API is currently mainly used to initialize depthengine, This function only needs to be called when on the Linux platform</remarks>
[DllImport(Sdk.SENSOR_DLL_NAME, EntryPoint = "k4a_depth_engine_helper_create", CallingConvention = CallingConvention.Cdecl)]
public static extern NativeCallResults.Result DepthEngineHelperCreate(out NativeHandles.DepthEngineHandle depthEngineHandle);

// K4A_EXPORT k4a_wired_sync_mode_t k4a_device_get_wired_sync_mode(k4a_device_t device);
/// <summary>get device sync mode (OrbbecSDK-K4A-Wrapper only)</summary>
/// <param name="device">Device handle</param>
/// <returns>Current sync mode</returns>
/// <remarks>
/// This API is currently mainly used to get device sync mode.
/// The device synchronization mode will change according to the mode configured in the start_cameras function.
/// </remarks>
[DllImport(Sdk.SENSOR_DLL_NAME, EntryPoint = "k4a_device_get_wired_sync_mode", CallingConvention = CallingConvention.Cdecl)]
public static extern WiredSyncMode DeviceGetWiredSyncMode(NativeHandles.DeviceHandle device);

// K4A_EXPORT k4a_result_t k4a_device_enable_soft_filter(k4a_device_t device_handle, bool enable);
/// <summary>enable/disable soft filter for depth camera (OrbbecSDK-K4A-Wrapper only)</summary>
/// <param name="deviceHandle">Device handle</param>
/// <param name="enable">Device software filtering switch</param>
/// <returns></returns>
/// <remarks>This API is used to set filtering.</remarks>
[DllImport(Sdk.SENSOR_DLL_NAME, EntryPoint = "k4a_device_enable_soft_filter", CallingConvention = CallingConvention.Cdecl)]
public static extern NativeCallResults.Result DeviceEnableSoftFilter(NativeHandles.DeviceHandle deviceHandle, byte enable);

// K4A_EXPORT k4a_result_t k4a_device_switch_device_clock_sync_mode(k4a_device_t device_handle, k4a_device_clock_sync_mode_t timestamp_mode, uint32_t param);
/// <summary>switch device clock sync mode (OrbbecSDK-K4A-Wrapper only)</summary>
/// <param name="deviceHandle">Device handle</param>
/// <param name="timestampMode">Device clock synchronization mode</param>
/// <param name="param">
/// If <paramref name="timestampMode"/> is <see cref="DeviceClockSyncMode.Reset"/>: The delay time of executing the timestamp reset function after receiving the command or signal in microseconds.
/// If <paramref name="timestampMode"/> is <see cref="DeviceClockSyncMode.Sync"/>: The interval for auto-repeated synchronization, in microseconds. If the value is 0, synchronization is performed only once.
/// </param>
/// <remarks>
/// This API is used for device clock synchronization mode switching.
/// </remarks>
[DllImport(Sdk.SENSOR_DLL_NAME, EntryPoint = "k4a_device_switch_device_clock_sync_mode", CallingConvention = CallingConvention.Cdecl)]
public static extern NativeCallResults.Result DeviceSwitchDeviceClockSyncMode(NativeHandles.DeviceHandle deviceHandle, DeviceClockSyncMode timestampMode, uint param);

#endif
}
}
62 changes: 61 additions & 1 deletion externals/OrbbecSDK-K4A-Wrapper/include/k4a/k4a.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {

#define WRAPPER_VERSION_MAJOR 1
#define WRAPPER_VERSION_MINOR 9
#define WRAPPER_VERSION_PATCH 1
#define WRAPPER_VERSION_PATCH 2

/**
* \defgroup Functions Functions
Expand All @@ -33,6 +33,66 @@ extern "C" {
* @{
*/

/** get device sync mode
*
* \remarks This API is currently mainly used to get device sync mode
*
* \remarks The device synchronization mode will change according to the mode configured in the start_cameras function
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_wired_sync_mode_t k4a_device_get_wired_sync_mode(k4a_device_t device);

/** enable/disable soft filter for depth camera
*
* \param device_handle
* Output parameter which on success will return a handle to the device.
*
* \param enable
* Device software filtering switch
*
* \remarks This API is used to set filtering.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_device_enable_soft_filter(k4a_device_t device_handle, bool enable);

/** switch device clock sync mode
*
* \param device_handle
* Output parameter which on success will return a handle to the device.
*
* \param timestamp_mode
* Device clock synchronization mode
*
* \param param
* If timestamp_mode is K4A_DEVICE_CLOCK_SYNC_MODE_RESET: The delay time of executing the timestamp reset function after receiving the command or signal in microseconds.
* If timestamp_mode is K4A_DEVICE_CLOCK_SYNC_MODE_SYNC: The interval for auto-repeated synchronization, in microseconds. If the value is 0, synchronization is performed only once.
*
* \remarks This API is used for device clock synchronization mode switching.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4a.h (include k4a/k4a.h)</requirement>
* <requirement name="Library">k4a.lib</requirement>
* <requirement name="DLL">k4a.dll</requirement>
* </requirements>
* \endxmlonly
*/
K4A_EXPORT k4a_result_t k4a_device_switch_device_clock_sync_mode(k4a_device_t device_handle, k4a_device_clock_sync_mode_t timestamp_mode, uint32_t param);

/** create depthengine helper
*
* \remarks This API is currently mainly used to initialize depthengine, This function only needs to be called when on the Linux platform
Expand Down
20 changes: 20 additions & 0 deletions externals/OrbbecSDK-K4A-Wrapper/include/k4a/k4a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,6 +1523,26 @@ class device
{
return k4a_device_get_installed_count();
}
/**
* @brief switch the device clock sync mode object
*
* \sa k4a_device_switch_device_clock_sync_mode
*/
void switch_device_clock_sync_mode(k4a_device_clock_sync_mode_t timestamp_mode, int param){
k4a_result_t result = k4a_device_switch_device_clock_sync_mode(m_handle, timestamp_mode, param);
if (K4A_RESULT_SUCCEEDED != result)
{
throw error("Failed to switch device clock sync mode!");
}
}

void set_soft_filter(bool filter_switch){
k4a_device_enable_soft_filter(m_handle, filter_switch);
}

k4a_wired_sync_mode_t get_wired_sync_mode(){
return k4a_device_get_wired_sync_mode(m_handle);
}

private:
k4a_device_t m_handle;
Expand Down
14 changes: 14 additions & 0 deletions externals/OrbbecSDK-K4A-Wrapper/include/k4a/k4atypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ K4A_DECLARE_HANDLE(k4a_transformation_t);
* @{
*/

/** Device clock synchronization mode type.
*
* \xmlonly
* <requirements>
* <requirement name="Header">k4atypes.h (include k4a/k4a.h)</requirement>
* </requirements>
* \endxmlonly
*/
typedef enum
{
K4A_DEVICE_CLOCK_SYNC_MODE_RESET = 0, /**< device clock sync mode is reset */
K4A_DEVICE_CLOCK_SYNC_MODE_SYNC /**< device clock sync mode is asynchronous timinng */
} k4a_device_clock_sync_mode_t;

/** Result code returned by Azure Kinect APIs.
*
* \xmlonly
Expand Down
Binary file modified externals/OrbbecSDK-K4A-Wrapper/win-x64/OrbbecSDK.dll
Binary file not shown.
Binary file modified externals/OrbbecSDK-K4A-Wrapper/win-x64/k4a.dll
Binary file not shown.
Binary file modified externals/OrbbecSDK-K4A-Wrapper/win-x64/k4arecord.dll
Binary file not shown.

0 comments on commit 9353597

Please sign in to comment.