From 80a0a60b0ce5f57f3b6b891a8a4dbb9b6804c7b0 Mon Sep 17 00:00:00 2001 From: Brendan Burkhart Date: Mon, 15 Jul 2024 17:24:48 -0400 Subject: [PATCH 1/2] Image, camera calibration, and depth map types --- cisstCommon/cmnDataFunctionsJSON.h | 5 ++ cisstParameterTypes/code/CMakeLists.txt | 3 + cisstParameterTypes/code/prmClassServices.cpp | 9 +++ cisstParameterTypes/prmCameraInfo.cdg | 65 +++++++++++++++++++ cisstParameterTypes/prmDepthMap.cdg | 60 +++++++++++++++++ cisstParameterTypes/prmImageFrame.cdg | 56 ++++++++++++++++ 6 files changed, 198 insertions(+) create mode 100644 cisstParameterTypes/prmCameraInfo.cdg create mode 100644 cisstParameterTypes/prmDepthMap.cdg create mode 100644 cisstParameterTypes/prmImageFrame.cdg diff --git a/cisstCommon/cmnDataFunctionsJSON.h b/cisstCommon/cmnDataFunctionsJSON.h index 90accc29a..5e2e0568a 100644 --- a/cisstCommon/cmnDataFunctionsJSON.h +++ b/cisstCommon/cmnDataFunctionsJSON.h @@ -69,6 +69,11 @@ void CISST_EXPORT cmnDataJSON::SerializeText(const DataType & data template <> void CISST_EXPORT cmnDataJSON::DeSerializeText(DataType & data, const Json::Value & jsonValue) CISST_THROW(std::runtime_error); +template <> +void CISST_EXPORT cmnDataJSON::SerializeText(const DataType & data, Json::Value & jsonValue); +template <> +void CISST_EXPORT cmnDataJSON::DeSerializeText(DataType & data, const Json::Value & jsonValue) CISST_THROW(std::runtime_error); + template <> void CISST_EXPORT cmnDataJSON::SerializeText(const DataType & data, Json::Value & jsonValue); template <> diff --git a/cisstParameterTypes/code/CMakeLists.txt b/cisstParameterTypes/code/CMakeLists.txt index 265cbdb56..f41770718 100644 --- a/cisstParameterTypes/code/CMakeLists.txt +++ b/cisstParameterTypes/code/CMakeLists.txt @@ -30,6 +30,9 @@ cisst_data_generator (cisstParameterTypes ../prmInputData.cdg ../prmKeyValue.cdg ../prmOperatingState.cdg + ../prmImageFrame.cdg + ../prmCameraInfo.cdg + ../prmDepthMap.cdg ../prmForwardKinematicsRequest.cdg ../prmForwardKinematicsResponse.cdg ../prmInverseKinematicsRequest.cdg diff --git a/cisstParameterTypes/code/prmClassServices.cpp b/cisstParameterTypes/code/prmClassServices.cpp index 98be7ef80..dcc01bcf3 100644 --- a/cisstParameterTypes/code/prmClassServices.cpp +++ b/cisstParameterTypes/code/prmClassServices.cpp @@ -99,6 +99,15 @@ CMN_IMPLEMENT_SERVICES(prmInputData); #include CMN_IMPLEMENT_SERVICES(prmOperatingState); +#include +CMN_IMPLEMENT_SERVICES(prmImageFrame); + +#include +CMN_IMPLEMENT_SERVICES(prmCameraInfo); + +#include +CMN_IMPLEMENT_SERVICES(prmDepthMap); + #include CMN_IMPLEMENT_SERVICES(prmForwardKinematicsRequest); diff --git a/cisstParameterTypes/prmCameraInfo.cdg b/cisstParameterTypes/prmCameraInfo.cdg new file mode 100644 index 000000000..ade0ae45e --- /dev/null +++ b/cisstParameterTypes/prmCameraInfo.cdg @@ -0,0 +1,65 @@ +// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: + +inline-header { +#include +#include +#include +// Always include last +#include +} + +class { + name prmCameraInfo; + + attribute CISST_EXPORT; + + base-class { + type mtsGenericObject; + is-data true; + } + + member { + name Width; + type size_t; + default 0; + } + + member { + name Height; + type size_t; + default 0; + } + + member { + name DistortionParameters; + type vctDoubleVec; + } + + member { + name Intrinsic; + type vct3x3; + } + + member { + name Rectification; + type vctRot3; + } + + member { + name Projection; + type vct3x4; + } + + inline-header { + public: + + private: + CMN_DECLARE_SERVICES(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT); + } +} + + +inline-header { +CMN_DECLARE_SERVICES_INSTANTIATION(prmCameraInfo); +} diff --git a/cisstParameterTypes/prmDepthMap.cdg b/cisstParameterTypes/prmDepthMap.cdg new file mode 100644 index 000000000..76b51db11 --- /dev/null +++ b/cisstParameterTypes/prmDepthMap.cdg @@ -0,0 +1,60 @@ +// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: + +inline-header { +#include +#include +#include +// Always include last +#include +} + +class { + name prmDepthMap; + + attribute CISST_EXPORT; + + base-class { + type mtsGenericObject; + is-data true; + } + + member { + name Width; + type size_t; + default 0; + } + + member { + name Height; + type size_t; + default 0; + } + + member { + name Points; + type vctDynamicVector; + } + + member { + name Color; + type vctDynamicVector; + } + + member { + name ReferenceFrame; + type std::string; + } + + inline-header { + public: + + private: + CMN_DECLARE_SERVICES(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT); + } +} + + +inline-header { +CMN_DECLARE_SERVICES_INSTANTIATION(prmDepthMap); +} diff --git a/cisstParameterTypes/prmImageFrame.cdg b/cisstParameterTypes/prmImageFrame.cdg new file mode 100644 index 000000000..b73b73afe --- /dev/null +++ b/cisstParameterTypes/prmImageFrame.cdg @@ -0,0 +1,56 @@ +// -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: + +inline-header { +#include +#include +#include +// Always include last +#include +} + +class { + name prmImageFrame; + + attribute CISST_EXPORT; + + base-class { + type mtsGenericObject; + is-data true; + } + + member { + name Width; + type size_t; + default 0; + } + + member { + name Height; + type size_t; + default 0; + } + + member { + name Channels; + type size_t; + default 3; + } + + member { + name Data; + type vctDynamicVector; + } + + inline-header { + public: + + private: + CMN_DECLARE_SERVICES(CMN_DYNAMIC_CREATION, CMN_LOG_ALLOW_DEFAULT); + } +} + + +inline-header { +CMN_DECLARE_SERVICES_INSTANTIATION(prmImageFrame); +} From c0801af0700ece564e62dcb5d2f354197343dbe7 Mon Sep 17 00:00:00 2001 From: Brendan Burkhart Date: Fri, 19 Jul 2024 17:39:17 -0400 Subject: [PATCH 2/2] Mark return object as valid to prevent warnings Under some situations, TriggerFinishedEventIfNeeded wil issue a warning because the return object from AddObserverList has Valid() = false --- cisstMultiTask/code/mtsInterfaceRequired.cpp | 2 ++ cisstMultiTask/code/mtsMailBox.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cisstMultiTask/code/mtsInterfaceRequired.cpp b/cisstMultiTask/code/mtsInterfaceRequired.cpp index 1ca499119..2dfd3df4a 100644 --- a/cisstMultiTask/code/mtsInterfaceRequired.cpp +++ b/cisstMultiTask/code/mtsInterfaceRequired.cpp @@ -787,6 +787,8 @@ void mtsInterfaceRequired::GetEventList(mtsEventHandlerList & eventList) iterEventWrite->second, MTS_OPTIONAL)); } + + eventList.SetValid(true); } diff --git a/cisstMultiTask/code/mtsMailBox.cpp b/cisstMultiTask/code/mtsMailBox.cpp index 8abd14af4..a53197a27 100644 --- a/cisstMultiTask/code/mtsMailBox.cpp +++ b/cisstMultiTask/code/mtsMailBox.cpp @@ -222,7 +222,9 @@ void mtsMailBox::TriggerFinishedEventIfNeeded(const std::string &commandName, mt if (resultPointer->Valid() != result.IsOK()) { CMN_LOG_RUN_WARNING << "TriggerFinishedEventIfNeeded: result valid = " << resultPointer->Valid() << ", result OK = " << result.IsOK() - << ", msg = " << mtsExecutionResult::ToString(result.Value()) << std::endl; + << ", msg = " << mtsExecutionResult::ToString(result.Value()) + << ", msg type = " << resultPointer->Services()->GetName() + << ", command name = " << commandName << std::endl; } resultPointer->SetValid(result.IsOK()); // Set data valid flag based on execution result evt_result = finishedEvent->Execute(*resultPointer, MTS_NOT_BLOCKING);