Skip to content

Commit

Permalink
Merge pull request #86 from orbbec/release/1.10.3
Browse files Browse the repository at this point in the history
Release/1.10.3
  • Loading branch information
zzuliys authored Aug 13, 2024
2 parents fcf0726 + e1cea9a commit f2e9360
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 19 deletions.
15 changes: 15 additions & 0 deletions include/k4a/k4a.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ extern "C" {
* @{
*/

/** get device pid
*
* \remarks This API is currently mainly used to get device pid
*
* \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 int k4a_device_get_pid(k4a_device_t device);


/** get device sync mode
*
* \remarks This API is currently mainly used to get device sync mode
Expand Down
4 changes: 4 additions & 0 deletions include/k4a/k4a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,10 @@ class device
return k4a_device_get_wired_sync_mode(m_handle);
}

int get_pid(){
return k4a_device_get_pid(m_handle);
}

private:
k4a_device_t m_handle;
};
Expand Down
39 changes: 26 additions & 13 deletions src/orbbec/ob_k4a_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ char K4A_ENV_VAR_LOG_TO_A_FILE[] = K4A_ENABLE_LOG_TO_A_FILE;
#define UNREFERENCED_VALUE(P) ((void)P)

#define MAX_JSON_FILE_SIZE 1024 * 10
#define ORBBEC_MEGA_PID 0x0669
#define ORBBEC_BOLT_PID 0x066B
#define MAX_DELAY_TIME 33333
#define MIN_DELAY_TIME -33333

Expand Down Expand Up @@ -192,6 +190,14 @@ K4A_DECLARE_CONTEXT(k4a_depthengine_t, k4a_depthengine_instance_helper_t);
case fps: \
return #fps

int k4a_device_get_pid(k4a_device_t device_handle){
ob_error *ob_err = NULL;
k4a_device_context_t *device_ctx = k4a_device_t_get_context(device_handle);
ob_device_info *dev_info = ob_device_get_device_info(device_ctx->device, &ob_err);
int pid = ob_device_info_pid(dev_info, &ob_err);
return pid;
}

k4a_wired_sync_mode_t k4a_device_get_wired_sync_mode(k4a_device_t device_handle){
k4a_device_context_t *device_ctx = k4a_device_t_get_context(device_handle);
OB_DEVICE_SYNC_CONFIG ob_config;
Expand Down Expand Up @@ -908,6 +914,9 @@ k4a_result_t k4a_device_start_imu(k4a_device_t device_handle)
return K4A_RESULT_FAILED;
}

ob_device_set_bool_property(device_ctx->device, OB_PROP_SDK_ACCEL_FRAME_TRANSFORMED_BOOL, true, &ob_err);
ob_device_set_bool_property(device_ctx->device, OB_PROP_SDK_GYRO_FRAME_TRANSFORMED_BOOL, true, &ob_err);

if(!device_ctx->is_camera_streaming && device_ctx->current_device_clock_sync_mode == K4A_DEVICE_CLOCK_SYNC_MODE_RESET){
OB_DEVICE_SYNC_CONFIG ob_sync_config;
memset(&ob_sync_config, 0, sizeof(OB_DEVICE_SYNC_CONFIG));
Expand Down Expand Up @@ -2752,17 +2761,21 @@ k4a_result_t k4a_device_get_color_control_capabilities(k4a_device_t device_handl
}
break;
case K4A_COLOR_CONTROL_HDR:{
ob_bool_property_range colorParamRange = ob_device_get_bool_property_range(obDevice,
OB_PROP_COLOR_HDR_BOOL,
&ob_err);
CHECK_OB_ERROR_RETURN_K4A_RESULT(&ob_err);
ob_device_info *dev_info = ob_device_get_device_info(device_ctx->device, &ob_err);
int pid = ob_device_info_pid(dev_info, &ob_err);
if(pid == ORBBEC_BOLT_PID){
ob_bool_property_range colorParamRange = ob_device_get_bool_property_range(obDevice,
OB_PROP_COLOR_HDR_BOOL,
&ob_err);
CHECK_OB_ERROR_RETURN_K4A_RESULT(&ob_err);

*supports_auto = false;
*min_value = colorParamRange.min;
*max_value = colorParamRange.max;
*step_value = colorParamRange.step;
*default_value = colorParamRange.def;
*default_mode = K4A_COLOR_CONTROL_MODE_MANUAL;
*supports_auto = false;
*min_value = colorParamRange.min;
*max_value = colorParamRange.max;
*step_value = colorParamRange.step;
*default_value = colorParamRange.def;
*default_mode = K4A_COLOR_CONTROL_MODE_MANUAL;
}
result = K4A_RESULT_SUCCEEDED;
}
break;
Expand Down Expand Up @@ -3648,7 +3661,7 @@ k4a_result_t k4a_device_get_calibration(k4a_device_t device_handle,
CHECK_OB_ERROR_RETURN_K4A_RESULT(&ob_err);
ob_delete_device_info(dev_info, &ob_err);
CHECK_OB_ERROR_RETURN_K4A_RESULT(&ob_err);
if (pid == ORBBEC_MEGA_PID || pid == ORBBEC_BOLT_PID)
if (pid == ORBBEC_MEGA_PID || pid == ORBBEC_BOLT_PID || pid == ORBBEC_MEGA_I_PID)
{
return k4a_device_get_calibration_from_json(device_handle, depth_mode, color_resolution, calibration);
}
Expand Down
4 changes: 2 additions & 2 deletions src/orbbec/record/sdk/playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ k4a_result_t k4a_playback_open(const char *path, k4a_playback_t *playback_handle
context = k4a_playback_t_create(playback_handle);
result = K4A_RESULT_FROM_BOOL(context != NULL);

ob_error *error;
ob_error *error = NULL;
context->ob_ctx = ob_create_context(&error);
check_error(error);

Expand Down Expand Up @@ -685,7 +685,7 @@ void k4a_playback_close(const k4a_playback_t playback_handle)

context->file_closing = true;

ob_error *error;
ob_error *error = NULL;
ob_delete_context(context->ob_ctx, &error);
check_error(error);
try
Expand Down
18 changes: 14 additions & 4 deletions tools/k4aviewer/k4adevicedockcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

using namespace k4aviewer;

#define ORBBEC_MEGA_PID 0x0669
#define ORBBEC_BOLT_PID 0x066B
#define ORBBEC_MEGA_I_PID 0x06C0

namespace
{
constexpr std::chrono::milliseconds CameraPollingTimeout(3000);
Expand Down Expand Up @@ -442,6 +446,12 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
bool colorResolutionUpdated = colorEnableStateChanged;
if (ImGui::TreeNode("Color Configuration"))
{
bool isMegaI = false;
int pid = m_device.get_pid();
if(pid == ORBBEC_MEGA_I_PID){
isMegaI = true;
}

const bool colorSettingsEditable = !deviceIsStarted && m_config.EnableColorCamera;

bool colorFormatUpdated = false;
Expand All @@ -455,10 +465,10 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
ImGui::SameLine();
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("NV12", pColorFormat, K4A_IMAGE_FORMAT_COLOR_NV12,
colorSettingsEditable);
colorSettingsEditable && !isMegaI);
ImGui::SameLine();
colorFormatUpdated |=
ImGuiExtensions::K4ARadioButton("YUY2", pColorFormat, K4A_IMAGE_FORMAT_COLOR_YUY2, colorSettingsEditable);
ImGuiExtensions::K4ARadioButton("YUY2", pColorFormat, K4A_IMAGE_FORMAT_COLOR_YUY2, colorSettingsEditable && !isMegaI);

// Uncompressed formats are only supported at 720p.
//
Expand Down Expand Up @@ -498,14 +508,14 @@ K4ADockControlStatus K4ADeviceDockControl::Show()
pColorResolution,
K4A_COLOR_RESOLUTION_1440P,
colorSettingsEditable &&
imageFormatSupportsHighResolution&&!(m_config.ColorFormat == K4A_IMAGE_FORMAT_COLOR_YUY2));
imageFormatSupportsHighResolution&&!(m_config.ColorFormat == K4A_IMAGE_FORMAT_COLOR_YUY2) &&!isMegaI);
ImGuiExtensions::K4AShowTooltip(imageFormatHelpMessage, !imageFormatSupportsHighResolution);
ImGui::SameLine();
colorResolutionUpdated |= ImGuiExtensions::K4ARadioButton("2160p",
pColorResolution,
K4A_COLOR_RESOLUTION_2160P,
colorSettingsEditable &&
imageFormatSupportsHighResolution&&!(m_config.ColorFormat == K4A_IMAGE_FORMAT_COLOR_YUY2));
imageFormatSupportsHighResolution&&!(m_config.ColorFormat == K4A_IMAGE_FORMAT_COLOR_YUY2) &&!isMegaI);
ImGuiExtensions::K4AShowTooltip(imageFormatHelpMessage, !imageFormatSupportsHighResolution);
ImGui::Unindent();
ImGui::Text("4:3");
Expand Down

0 comments on commit f2e9360

Please sign in to comment.