@@ -27,7 +27,7 @@ Ptr<Params> Params::defaultParams()
2727
2828 p.frameSize = Size (640 , 480 );
2929
30- p.volumeKind = VolumeParams::VolumeKind ::TSDF;
30+ p.volumeKind = VolumeType ::TSDF;
3131
3232 float fx, fy, cx, cy;
3333 fx = fy = 525 .f ;
@@ -110,7 +110,7 @@ Ptr<Params> Params::hashTSDFParams(bool isCoarse)
110110 p = coarseParams ();
111111 else
112112 p = defaultParams ();
113- p->volumeKind = VolumeParams::VolumeKind::HASHTSDF ;
113+ p->volumeKind = VolumeType::HashTSDF ;
114114 p->truncateThreshold = 4 .f ;
115115 return p;
116116}
@@ -122,7 +122,7 @@ Ptr<Params> Params::coloredTSDFParams(bool isCoarse)
122122 p = coarseParams ();
123123 else
124124 p = defaultParams ();
125- p->volumeKind = VolumeParams::VolumeKind::COLOREDTSDF ;
125+ p->volumeKind = VolumeType::ColorTSDF ;
126126
127127 return p;
128128}
@@ -135,6 +135,7 @@ class ColoredKinFuImpl : public ColoredKinFu
135135 ColoredKinFuImpl (const Params& _params);
136136 virtual ~ColoredKinFuImpl ();
137137
138+ static VolumeSettings paramsToSettings (const Params& params);
138139 const Params& getParams () const CV_OVERRIDE;
139140
140141 void render (OutputArray image) const CV_OVERRIDE;
@@ -154,25 +155,40 @@ class ColoredKinFuImpl : public ColoredKinFu
154155
155156private:
156157 Params params;
158+ VolumeSettings settings;
157159
158160 Odometry icp;
159- cv::Ptr< Volume> volume;
161+ Volume volume;
160162
161163 int frameCounter;
162164 Matx44f pose;
163165 OdometryFrame renderFrame;
164166 OdometryFrame prevFrame;
165167};
166168
169+ template < typename MatType >
170+ VolumeSettings ColoredKinFuImpl<MatType>::paramsToSettings(const Params& params)
171+ {
172+ VolumeSettings vs (VolumeType::TSDF);
173+ vs.setVoxelSize (params.voxelSize );
174+ vs.setVolumePose (params.volumePose );
175+ vs.setRaycastStepFactor (params.raycast_step_factor );
176+ vs.setTsdfTruncateDistance (params.tsdf_trunc_dist );
177+ vs.setMaxWeight (params.tsdf_max_weight );
178+ vs.setMaxDepth (params.truncateThreshold );
179+ vs.setCameraIntegrateIntrinsics (params.intr );
180+ vs.setDepthFactor (params.depthFactor );
181+ vs.setVolumeResolution (params.volumeDims );
182+
183+ return vs;
184+ }
167185
168186template < typename MatType >
169187ColoredKinFuImpl<MatType>::ColoredKinFuImpl(const Params &_params) :
170- params (_params)
188+ params (_params),
189+ settings(paramsToSettings(params)),
190+ volume(VolumeType::ColorTSDF, settings)
171191{
172- volume = makeVolume (params.volumeKind , params.voxelSize , params.volumePose , params.raycast_step_factor ,
173- params.tsdf_trunc_dist , params.tsdf_max_weight , params.truncateThreshold ,
174- params.volumeDims [0 ], params.volumeDims [1 ], params.volumeDims [2 ]);
175-
176192 OdometrySettings ods;
177193 ods.setCameraMatrix (Mat (params.intr ));
178194 ods.setMaxRotation (30 .f );
@@ -189,7 +205,7 @@ void ColoredKinFuImpl<MatType >::reset()
189205{
190206 frameCounter = 0 ;
191207 pose = Affine3f::Identity ().matrix ;
192- volume-> reset ();
208+ volume. reset ();
193209}
194210
195211template < typename MatType >
@@ -283,7 +299,7 @@ bool ColoredKinFuImpl<MatType>::updateT(const MatType& _depth, const MatType& _r
283299 icp.prepareFrame (newFrame);
284300
285301 // use depth instead of distance
286- volume-> integrate (depth, rgb, params. depthFactor , pose, params. intr , params. rgb_intr );
302+ volume. integrate (depth, rgb, pose);
287303 // TODO: try to move setPyramidLevel from kinfu to volume
288304 newFrame.setPyramidLevel (params.icpIterations .size (), OdometryFramePyramidType::PYR_IMAGE);
289305 newFrame.setPyramidAt (rgb, OdometryFramePyramidType::PYR_IMAGE, 0 );
@@ -307,7 +323,7 @@ bool ColoredKinFuImpl<MatType>::updateT(const MatType& _depth, const MatType& _r
307323 if ((rnorm + tnorm)/2 >= params.tsdf_min_camera_movement )
308324 {
309325 // use depth instead of distance
310- volume-> integrate (depth, rgb, params. depthFactor , pose, params. intr , params. rgb_intr );
326+ volume. integrate (depth, rgb, pose);
311327 newFrame.setPyramidLevel (params.icpIterations .size (), OdometryFramePyramidType::PYR_IMAGE);
312328 newFrame.setPyramidAt (rgb, OdometryFramePyramidType::PYR_IMAGE, 0 );
313329 }
@@ -316,7 +332,7 @@ bool ColoredKinFuImpl<MatType>::updateT(const MatType& _depth, const MatType& _r
316332 newFrame.getPyramidAt (normals, OdometryFramePyramidType::PYR_NORM, 0 );
317333 newFrame.getPyramidAt (colors, OdometryFramePyramidType::PYR_IMAGE, 0 );
318334
319- volume-> raycast (pose, params. intr , params. frameSize , points, normals, colors);
335+ volume. raycast (pose, points, normals, colors);
320336
321337 newFrame.setPyramidAt (points, OdometryFramePyramidType::PYR_CLOUD, 0 );
322338 newFrame.setPyramidAt (normals, OdometryFramePyramidType::PYR_NORM, 0 );
@@ -350,29 +366,29 @@ void ColoredKinFuImpl<MatType>::render(OutputArray image, const Matx44f& _camera
350366
351367 Affine3f cameraPose (_cameraPose);
352368 MatType points, normals, colors;
353- volume-> raycast (_cameraPose, params. intr , params. frameSize , points, normals, colors);
369+ volume. raycast (_cameraPose, points, normals, colors);
354370 detail::renderPointsNormalsColors (points, normals, colors, image);
355371}
356372
357373
358374template < typename MatType >
359375void ColoredKinFuImpl<MatType>::getCloud(OutputArray p, OutputArray n) const
360376{
361- volume-> fetchPointsNormals (p, n);
377+ volume. fetchPointsNormals (p, n);
362378}
363379
364380
365381template < typename MatType >
366382void ColoredKinFuImpl<MatType>::getPoints(OutputArray points) const
367383{
368- volume-> fetchPointsNormals (points, noArray ());
384+ volume. fetchPointsNormals (points, noArray ());
369385}
370386
371387
372388template < typename MatType >
373389void ColoredKinFuImpl<MatType>::getNormals(InputArray points, OutputArray normals) const
374390{
375- volume-> fetchNormals (points, normals);
391+ volume. fetchNormals (points, normals);
376392}
377393
378394// importing class
0 commit comments