23 #ifndef _ARMARX_COMPONENT_VisionX_CoFusionProcessor_H
24 #define _ARMARX_COMPONENT_VisionX_CoFusionProcessor_H
27 #include <pcl/point_cloud.h>
28 #include <pcl/point_types.h>
34 #include <VisionX/interface/components/CoFusionProcessor.h>
37 #include <RobotAPI/interface/core/RobotState.h>
41 #include <Core/Callbacks.h>
42 #include <Core/PoseMatch.h>
43 #include <Core/Utils/Intrinsics.h>
62 defineOptionalProperty<std::string>(
"RobotStateComponentName",
63 "RobotStateComponent",
64 "Name of the RobotState of the Robot");
67 defineOptionalProperty<float>(
"framerate", 30.0f,
"framerate for the point clouds")
70 defineOptionalProperty<bool>(
71 "isEnabled",
true,
"enable the capturing process immediately");
73 defineOptionalProperty<std::string>(
74 "ImageProviderName",
"ImageProvider",
"Name of the input image provider.");
77 defineOptionalProperty<int>(
78 "FramesBetweenUpdates", 1,
"Number of frames between two point cloud updates.");
80 defineOptionalProperty<visionx::ImageSyncMode>(
82 visionx::eCaptureSynchronization,
83 "The point cloud sync mode ('capture' (default) or 'fps').")
84 .map(
"capture", visionx::eCaptureSynchronization)
85 .map(
"fps", visionx::eFpsSynchronization);
87 defineOptionalProperty<float>(
88 "DownsamplingLeafSize",
90 "If > 0, the result point cloud will be downsampled with the given leaf size.");
92 defineOptionalProperty<bool>(
95 "If true, an execution time report is logged periodically.");
97 defineOptionalProperty<std::string>(
98 "ReferenceFrameName",
"DepthCamera",
"reference frame name.");
101 defineOptionalProperty<int>(
"cofusion.TimeDelta", 200,
"The CoFusion time delta.");
102 defineOptionalProperty<int>(
103 "cofusion.CountThresh", 35000,
"The CoFusion count thresh.");
104 defineOptionalProperty<float>(
"cofusion.ErrThresh", 5e-05,
"The CoFusion err thresh.");
105 defineOptionalProperty<float>(
"cofusion.CovThresh", 1e-05,
"The CoFusion cov thresh.");
106 defineOptionalProperty<bool>(
"cofusion.CloseLoops",
false,
"The CoFusion close loops.");
107 defineOptionalProperty<bool>(
"cofusion.Iclnuim",
false,
"The CoFusion iclnuim.");
108 defineOptionalProperty<bool>(
"cofusion.Reloc",
false,
"The CoFusion reloc.");
109 defineOptionalProperty<float>(
110 "cofusion.PhotoThresh", 115,
"The CoFusion photo thresh.");
111 defineOptionalProperty<float>(
112 "cofusion.InitConfidenceGlobal", 4,
"The CoFusion init confidence global.");
113 defineOptionalProperty<float>(
114 "cofusion.InitConfidenceObject", 2,
"The CoFusion init confidence object.");
115 defineOptionalProperty<float>(
"cofusion.DepthCut", 3,
"The CoFusion depth cut.");
116 defineOptionalProperty<float>(
"cofusion.IcpThresh", 10,
"The CoFusion icp thresh.");
117 defineOptionalProperty<bool>(
"cofusion.FastOdom",
false,
"The CoFusion fast odom.");
118 defineOptionalProperty<float>(
119 "cofusion.FernThresh", 0.3095,
"The CoFusion fern thresh.");
120 defineOptionalProperty<bool>(
"cofusion.So3",
true,
"The CoFusion so3.");
121 defineOptionalProperty<bool>(
122 "cofusion.FrameToFrameRGB",
false,
"The CoFusion frame to frame r g b.");
123 defineOptionalProperty<unsigned>(
124 "cofusion.ModelSpawnOffset", 20,
"The CoFusion model spawn offset.");
125 defineOptionalProperty<Model::MatchingType>(
126 "cofusion.MatchingType", Model::MatchingType::Drost,
"The CoFusion matching type.");
127 defineOptionalProperty<std::string>(
128 "cofusion.ExportDirectory",
"",
"The CoFusion export directory.");
129 defineOptionalProperty<bool>(
"cofusion.ExportSegmentationResults",
131 "The CoFusion export segmentation results.");
133 #if USE_MASKFUSION == 1
134 defineOptionalProperty<bool>(
"cofusion.UsePrecomputedMasksOnly",
false,
"");
135 defineOptionalProperty<int>(
136 "cofusion.FrameQueueSize", 5,
"Set size of frame-queue manually");
137 defineOptionalProperty<int>(
138 "cofusion.DeviceMaskRCNN", -1,
"Select GPU (device ID) which is running MaskRCNN.");
140 defineOptionalProperty<int>(
"cofusion.PreallocatedModelsCount",
142 " Preallocate memory for a number of models, which can "
143 "increase performance (default: 0)");
162 virtual public visionx::CoFusionProcessorInterface
171 return "CoFusionProcessor";
176 const Ice::Current&
c = Ice::emptyCurrent)
override;
197 virtual void process()
override;
218 void onNewModel(std::shared_ptr<Model> model);
228 using OutPointT = pcl::PointXYZRGBL;
235 void initializeCoFusion();
244 void updateSurfelMaps();
250 void reconstructResultPointCloud();
253 void reportStopwatchStats();
256 std::string imageProviderName;
257 visionx::ImageProviderInterfacePrx imageProvider;
263 #if USE_MASKFUSION == 1
264 std::unique_ptr<MaskFusion> cofusion;
266 std::unique_ptr<CoFusion> cofusion;
272 std::mutex imagesMutex;
279 CByteImage* images[2];
283 std::size_t framesBetweenUpdates;
285 std::size_t framesSinceLastUpdate = 0;
290 std::mutex surfelMapMutex;
293 std::map<unsigned int, Model::SurfelMap> surfelMaps;
295 pcl::PointCloud<OutPointT>::Ptr resultPointCloud;
298 float downsamplingLeafSize = 0.f;
307 std::string referenceFrameName;
309 std::atomic<bool> newFrameAvailable =
false;