diff --git a/SolARFramework.pri b/SolARFramework.pri index 13d1e997..e5298afd 100644 --- a/SolARFramework.pri +++ b/SolARFramework.pri @@ -50,6 +50,7 @@ interfaces/api/input/devices/IDevice.h \ interfaces/api/input/devices/IIMU.h \ interfaces/api/input/devices/IRGBDCamera.h \ interfaces/api/input/devices/IStereoCameraCalibration.h \ +interfaces/api/input/files/IKeyframeLoader.h \ interfaces/api/input/files/IMapLoader.h \ interfaces/api/input/files/IMeshLoader.h \ interfaces/api/input/files/IPointCloudLoader.h \ @@ -71,6 +72,8 @@ interfaces/api/pipeline/IMapProcessingPipeline.h \ interfaces/api/pipeline/IRelocalizationTrackablePipeline.h \ interfaces/api/pointCloud/IPCFilter.h \ interfaces/api/pointCloud/IPCFilterCentroid.h \ +interfaces/api/pointCloud/IPCProjectOntoImage.h \ +interfaces/api/pointCloud/IPCSemanticFrom2D.h \ interfaces/api/reloc/IKeyframeRetriever.h \ interfaces/api/reloc/IRelocalizer.h \ interfaces/api/reloc/IRegression.h \ diff --git a/interfaces/api/input/files/IKeyframeLoader.h b/interfaces/api/input/files/IKeyframeLoader.h new file mode 100644 index 00000000..21975853 --- /dev/null +++ b/interfaces/api/input/files/IKeyframeLoader.h @@ -0,0 +1,68 @@ +/** + * @copyright Copyright (c) 2026 B-com http://www.b-com.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SOLAR_IKEYFRAMELOADER_H +#define SOLAR_IKEYFRAMELOADER_H + +#include "datastructure/CameraParametersCollection.h" +#include "datastructure/KeyframeCollection.h" +#include +#include + +namespace SolAR { +namespace api { +namespace input { +namespace files { + +/** + * @class IKeyframeLoader + * @brief Load a keyframe collection from file. + * UUID: 2d1d125c-6bd2-4e2c-af76-f58910cb7791 + * + */ +class XPCF_IGNORE IKeyframeLoader : virtual public org::bcom::xpcf::IComponentIntrospect { +public: + /// @brief default constructor + IKeyframeLoader() = default; + + /// @brief default destructor + virtual ~IKeyframeLoader() = default; + + /// @brief Load a keyframe collection from file + /// @param[out] keyframeCollection the loaded keyframe collection (camera ID is set to 0) + /// @return FrameworkReturnCode::_SUCCESS if load succeeded, else FrameworkReturnCode::_ERROR_ + virtual FrameworkReturnCode load(SRef& keyframeCollection) = 0; + + /// @brief Load a keyframe collection and a camera parameters collection from file + /// @param[out] keyframeCollection the loaded keyframe collection + /// @param[out] cameraParametersCollection the loaded camera parameters collection + /// @return FrameworkReturnCode::_SUCCESS if load succeeded, else FrameworkReturnCode::_ERROR_ + virtual FrameworkReturnCode load(SRef& keyframeCollection, + SRef& cameraParametersCollection) = 0; +}; + +} +} +} +} + +XPCF_DEFINE_INTERFACE_TRAITS(SolAR::api::input::files::IKeyframeLoader, + "2d1d125c-6bd2-4e2c-af76-f58910cb7791", + "IKeyframeLoader", + "Load a keyframe collection from file"); + + +#endif // SOLAR_IKEYFRAMELOADER_H diff --git a/interfaces/api/input/files/IMapLoader.h b/interfaces/api/input/files/IMapLoader.h index b792f7f4..7c673113 100644 --- a/interfaces/api/input/files/IMapLoader.h +++ b/interfaces/api/input/files/IMapLoader.h @@ -1,58 +1,58 @@ -/** - * @copyright Copyright (c) 2024 B-com http://www.b-com.com/ - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SOLAR_IPOINTCLOUDLOADER_H -#define SOLAR_IPOINTCLOUDLOADER_H - -#include -#include -#include "core/Messages.h" -#include "datastructure/Map.h" - -namespace SolAR { -namespace api { -namespace input { -namespace files { -/** - * @class IMapLoader - * @brief Loads a map from a file. - * UUID: 84dbbc4f-cc65-40ff-946d-7ed4999fb3a5 - * - */ -class XPCF_IGNORE IMapLoader : - virtual public org::bcom::xpcf::IComponentIntrospect { -public: - IMapLoader() = default; - virtual ~IMapLoader() = default; - - /// @brief Load a Map from a filepath - /// @param[out] map the loaded map - /// @return FrameworkReturnCode::_SUCCESS if load succeed, else FrameworkReturnCode::_ERROR_ - virtual FrameworkReturnCode load(SRef & map) = 0; -}; - -} -} -} -} - -XPCF_DEFINE_INTERFACE_TRAITS(SolAR::api::input::files::IMapLoader, - "84dbbc4f-cc65-40ff-946d-7ed4999fb3a5", - "IMapLoader", - "Load a map from a file"); - - -#endif // SOLAR_IPOINTCLOUDLOADER_H +/** + * @copyright Copyright (c) 2024 B-com http://www.b-com.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SOLAR_IMAPLOADER_H +#define SOLAR_IMAPLOADER_H + +#include +#include +#include "core/Messages.h" +#include "datastructure/Map.h" + +namespace SolAR { +namespace api { +namespace input { +namespace files { +/** + * @class IMapLoader + * @brief Loads a map from a file. + * UUID: 84dbbc4f-cc65-40ff-946d-7ed4999fb3a5 + * + */ +class XPCF_IGNORE IMapLoader : + virtual public org::bcom::xpcf::IComponentIntrospect { +public: + IMapLoader() = default; + virtual ~IMapLoader() = default; + + /// @brief Load a Map from a filepath + /// @param[out] map the loaded map + /// @return FrameworkReturnCode::_SUCCESS if load succeed, else FrameworkReturnCode::_ERROR_ + virtual FrameworkReturnCode load(SRef & map) = 0; +}; + +} +} +} +} + +XPCF_DEFINE_INTERFACE_TRAITS(SolAR::api::input::files::IMapLoader, + "84dbbc4f-cc65-40ff-946d-7ed4999fb3a5", + "IMapLoader", + "Load a map from a file"); + + +#endif // SOLAR_IMAPLOADER_H diff --git a/interfaces/api/pointCloud/IPCProjectOntoImage.h b/interfaces/api/pointCloud/IPCProjectOntoImage.h new file mode 100644 index 00000000..2fb984b8 --- /dev/null +++ b/interfaces/api/pointCloud/IPCProjectOntoImage.h @@ -0,0 +1,66 @@ +/** + * @copyright Copyright (c) 2026 B-com http://www.b-com.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SOLAR_IPCPROJECTONTOIMAGE_H +#define SOLAR_IPCPROJECTONTOIMAGE_H + +#include "datastructure/CameraDefinitions.h" +#include "datastructure/Image.h" +#include "datastructure/PointCloud.h" +#include +#include + +namespace SolAR { +namespace api { +namespace pointCloud { + +/** + * @class IPCProjectOntoImage + * @brief Project a point cloud onto image. + * UUId: 3700812e-0af5-4968-b972-4fdc6d3d7371 + */ + +class XPCF_IGNORE IPCProjectOntoImage : virtual public org::bcom::xpcf::IComponentIntrospect { +public: + /// @brief IPCProjectOntoImage default constructor + IPCProjectOntoImage() = default; + + /// @brief IPCProjectOntoImage default destructor + virtual ~IPCProjectOntoImage() = default; + + /// @brief Project a point cloud onto an image plane + /// @param[in] pointCloud the point cloud + /// @param[in] cameraParameters the camera parameters + /// @param[in] pose the camera pose + /// @param[out] image output image created from the point cloud + /// @return FrameworkReturnCode::_SUCCESS (pointcloud projected onto image successfully) otherwise FrameworkReturnCode::_ERROR_ (failure) + virtual FrameworkReturnCode project(SRef pointCloud, + SRef cameraParameters, + const SolAR::datastructure::Transform3Df& pose, + SRef& image) const = 0; + +}; +} +} +} // end of namespace Solar + +XPCF_DEFINE_INTERFACE_TRAITS(SolAR::api::pointCloud::IPCProjectOntoImage, + "3700812e-0af5-4968-b972-4fdc6d3d7371", + "IPCProjectOntoImage", + "Interface for projecting a point cloud onto image"); + + +#endif // SOLAR_IPCPROJECTONTOIMAGE_H diff --git a/interfaces/api/pointCloud/IPCSemanticFrom2D.h b/interfaces/api/pointCloud/IPCSemanticFrom2D.h new file mode 100644 index 00000000..37cbafd3 --- /dev/null +++ b/interfaces/api/pointCloud/IPCSemanticFrom2D.h @@ -0,0 +1,68 @@ +/** + * @copyright Copyright (c) 2026 B-com http://www.b-com.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SOLAR_IPCSEMANTICFROM2D_H +#define SOLAR_IPCSEMANTICFROM2D_H + +#include "core/Messages.h" +#include "datastructure/CameraParametersCollection.h" +#include "datastructure/KeyframeCollection.h" +#include "datastructure/Mask2DCollection.h" +#include "datastructure/PointCloud.h" +#include +#include + +namespace SolAR { +namespace api { +namespace pointCloud { + +/** + * @class IPCSemanticFrom2D + * @brief Estimate semantic Ids of cloud points from 2D information. + * UUId: e7f67167-1512-4c1c-808a-adcfb606030e + */ + +class XPCF_IGNORE IPCSemanticFrom2D : virtual public org::bcom::xpcf::IComponentIntrospect { +public: + /// @brief IPCSemanticFrom2D default constructor + IPCSemanticFrom2D() = default; + + /// @brief IPCSemanticFrom2D default destructor + virtual ~IPCSemanticFrom2D() = default; + + /// @brief Estimate point cloud semantic Ids from a keyframe collection and a mask collection + /// @param[in,out] pointCloud the point cloud for which semantic Ids will be estimated + /// @param[in] keyframeCollection input list of keyframes + /// @param[in] cameraParametersCollection input list of camera parameters + /// @param[in] maskCollection input list of masks + /// @return FrameworkReturnCode::_SUCCESS (semantic id estimated successfully) otherwise FrameworkReturnCode::_ERROR_ (failure) + virtual FrameworkReturnCode estimate(SRef pointCloud, + SRef keyframeCollection, + SRef cameraParametersCollection, + SRef maskCollection) const = 0; + +}; +} +} +} // end of namespace Solar + +XPCF_DEFINE_INTERFACE_TRAITS(SolAR::api::pointCloud::IPCSemanticFrom2D, + "e7f67167-1512-4c1c-808a-adcfb606030e", + "IPCSemanticFrom2D", + "Interface for estimating semantic Ids of cloud points from 2D information"); + + +#endif // SOLAR_IPCSEMANTICFROM2D_H diff --git a/interfaces/datastructure/KeyframeCollection.h b/interfaces/datastructure/KeyframeCollection.h index 5ed37fd2..1488b4ca 100644 --- a/interfaces/datastructure/KeyframeCollection.h +++ b/interfaces/datastructure/KeyframeCollection.h @@ -105,6 +105,10 @@ class SOLARFRAMEWORK_API KeyframeCollection : public Lockable { /// @return The number of keyframes int getNbKeyframes() const; + /// @brief This method allows to get the number of keyframes having image data + /// @return The number of keyframes having image data + uint32_t getNbKeyframesHavingImage() const; + private: /// @brief This method allows to make reference keyframes consistent /// (e.g. this method can be called after having loaded a keyframe collection which may contain inconsistent ref keyframes) diff --git a/interfaces/datastructure/Map.h b/interfaces/datastructure/Map.h index a136cb87..8c7d7fa4 100644 --- a/interfaces/datastructure/Map.h +++ b/interfaces/datastructure/Map.h @@ -299,7 +299,7 @@ class SOLARFRAMEWORK_API Map : public Trackable { SRef m_cameraParametersCollection = org::bcom::xpcf::utils::make_shared(); std::string m_version = SolAR::VERSION; // Version of the map (for compatibility) - datastructure::DescriptorType m_descriptorType = DescriptorType::AKAZE; // Type of descriptor used for the map + datastructure::DescriptorType m_descriptorType = DescriptorType::UNDEFINED; // Type of descriptor used for the map datastructure::GlobalDescriptorType m_globalDescriptorType = GlobalDescriptorType::UNDEFINED; // Type of global descriptor used for the map bool m_embedKeyframeImages = false; // Indicate if keyframe images must be embedded in datastructure }; diff --git a/src/datastructure/KeyframeCollection.cpp b/src/datastructure/KeyframeCollection.cpp index d236139f..c433a1ba 100644 --- a/src/datastructure/KeyframeCollection.cpp +++ b/src/datastructure/KeyframeCollection.cpp @@ -188,6 +188,17 @@ int KeyframeCollection::getNbKeyframes() const return static_cast(m_keyframes.size()); } +uint32_t KeyframeCollection::getNbKeyframesHavingImage() const +{ + uint32_t n = 0; + for (const auto& [id, keyframe] : m_keyframes) { + if (keyframe && keyframe->getView()) { + n++; + } + } + return n; +} + void KeyframeCollection::nextSerializationWithoutKeyframeImages() { for (const auto& [id, kf]: m_keyframes) { diff --git a/src/datastructure/Map.cpp b/src/datastructure/Map.cpp index 87ee6625..26626bcc 100644 --- a/src/datastructure/Map.cpp +++ b/src/datastructure/Map.cpp @@ -98,6 +98,12 @@ void Map::setKeyframeCollection(const SRef keyframeCollectio // we use m_keyframesManager to access the keyframes and optimize their poses // the modifs on keyframes' poses will not be applied to the keyframe collection of m_map m_keyframeCollection = keyframeCollection; + if (!m_keyframeCollection) { + m_embedKeyframeImages = false; + } + else { + m_embedKeyframeImages = m_keyframeCollection->getNbKeyframesHavingImage() > 0; + } } const SRef Map::getConstCovisibilityGraph() const