From 20f5737433ad5d523b918b3ef4b3776b428ac16c Mon Sep 17 00:00:00 2001 From: daiyin Date: Thu, 8 Aug 2024 17:48:52 +0800 Subject: [PATCH 1/3] [fix]: fix mega-i param error --- src/orbbec/ob_k4a_impl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/orbbec/ob_k4a_impl.cpp b/src/orbbec/ob_k4a_impl.cpp index 817f3cc7e..549e82a2f 100644 --- a/src/orbbec/ob_k4a_impl.cpp +++ b/src/orbbec/ob_k4a_impl.cpp @@ -3648,7 +3648,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); } From 45b992f20bdc66da935395a80410b906c4c5d24a Mon Sep 17 00:00:00 2001 From: daiyin Date: Fri, 9 Aug 2024 17:07:33 +0800 Subject: [PATCH 2/3] [feat]: add get pid interface --- include/k4a/k4a.h | 15 +++++++++++++++ include/k4a/k4a.hpp | 4 ++++ src/orbbec/ob_k4a_impl.cpp | 34 ++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/include/k4a/k4a.h b/include/k4a/k4a.h index e25b41f2a..bcbdda2d7 100644 --- a/include/k4a/k4a.h +++ b/include/k4a/k4a.h @@ -33,6 +33,21 @@ extern "C" { * @{ */ +/** get device pid + * + * \remarks This API is currently mainly used to get device pid + * + * \xmlonly + * + * k4a.h (include k4a/k4a.h) + * k4a.lib + * k4a.dll + * + * \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 diff --git a/include/k4a/k4a.hpp b/include/k4a/k4a.hpp index 26a7a11f3..13bdd702f 100644 --- a/include/k4a/k4a.hpp +++ b/include/k4a/k4a.hpp @@ -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; }; diff --git a/src/orbbec/ob_k4a_impl.cpp b/src/orbbec/ob_k4a_impl.cpp index 549e82a2f..bd89cd927 100644 --- a/src/orbbec/ob_k4a_impl.cpp +++ b/src/orbbec/ob_k4a_impl.cpp @@ -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 @@ -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; @@ -2752,17 +2758,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; From 9d5761310bfa48a6c2d36340efea6be4ab4b036e Mon Sep 17 00:00:00 2001 From: daiyin Date: Fri, 9 Aug 2024 17:09:22 +0800 Subject: [PATCH 3/3] [fix]: k4aviewer adapt to mega-i resolution display --- tools/k4aviewer/k4adevicedockcontrol.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/k4aviewer/k4adevicedockcontrol.cpp b/tools/k4aviewer/k4adevicedockcontrol.cpp index 1d07aeacf..2532ebe3a 100644 --- a/tools/k4aviewer/k4adevicedockcontrol.cpp +++ b/tools/k4aviewer/k4adevicedockcontrol.cpp @@ -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); @@ -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; @@ -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. // @@ -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");