@@ -15,109 +15,6 @@ namespace cv
15
15
{
16
16
namespace kinfu
17
17
{
18
- template <typename Derived>
19
- class HashTSDFVolume : public Volume
20
- {
21
- public:
22
- virtual ~HashTSDFVolume () = default ;
23
-
24
- virtual void reset () override
25
- {
26
- Derived* derived = static_cast <Derived*>(this );
27
- derived->reset_ ();
28
- }
29
-
30
- virtual void integrate (InputArray _depth, float depthFactor, const Matx44f& cameraPose, const kinfu::Intr& intrinsics,
31
- const int frameId = 0 ) override
32
- {
33
- Derived* derived = static_cast <Derived*>(this );
34
- derived->integrate_ (_depth, depthFactor, cameraPose, intrinsics, frameId);
35
- }
36
- virtual void raycast (const Matx44f& cameraPose, const kinfu::Intr& intrinsics, const Size & frameSize, OutputArray points,
37
- OutputArray normals) const override
38
- {
39
- const Derived* derived = static_cast <const Derived*>(this );
40
- derived->raycast_ (cameraPose, intrinsics, frameSize, points, normals);
41
- }
42
- virtual void fetchNormals (InputArray points, OutputArray _normals) const override
43
- {
44
- const Derived* derived = static_cast <const Derived*>(this );
45
- derived->fetchNormals_ (points, _normals);
46
- }
47
- virtual void fetchPointsNormals (OutputArray points, OutputArray normals) const override
48
- {
49
- const Derived* derived = static_cast <const Derived*>(this );
50
- derived->fetchPointsNormals_ (points, normals);
51
- }
52
- inline size_t getTotalVolumeUnits () const { return static_cast <const Derived*>(this )->getTotalVolumeUnits_ (); }
53
- inline int getVisibleBlocks (int currFrameId, int frameThreshold) const
54
- {
55
- return static_cast <const Derived*>(this )->getVisibleBlocks_ (currFrameId, frameThreshold);
56
- }
57
-
58
- inline TsdfVoxel at (const Vec3i& volumeIdx) const
59
- {
60
- const Derived* derived = static_cast <const Derived*>(this );
61
- return derived->at_ (volumeIdx);
62
- }
63
- // ! Return the voxel given the point in volume coordinate system i.e., (metric scale 1 unit =
64
- // ! 1m)
65
- inline TsdfVoxel at (const Point3f& point) const
66
- {
67
- const Derived* derived = static_cast <const Derived*>(this );
68
- return derived->at_ (point);
69
- }
70
-
71
- inline float interpolateVoxelPoint (const Point3f& point) const
72
- {
73
- const Derived* derived = static_cast <const Derived*>(this );
74
- return derived->interpolateVoxelPoint_ (point);
75
- }
76
-
77
- inline float interpolateVoxel_ (const cv::Point3f& point) const
78
- {
79
- const Derived* derived = static_cast <const Derived*>(this );
80
- return derived->interpolateVoxel_ (point);
81
- }
82
- inline Point3f getNormalVoxel (const Point3f& point) const
83
- {
84
- const Derived* derived = static_cast <const Derived*>(this );
85
- return derived->getNormalVoxel_ (point);
86
- }
87
-
88
- // ! Utility functions for coordinate transformations
89
- inline Vec3i volumeToVolumeUnitIdx (const Point3f& point) const
90
- {
91
- return static_cast <const Derived*>(this )->volumeToVolumeUnitIdx_ (point);
92
- }
93
- inline Point3f volumeUnitIdxToVolume (const Vec3i& volumeUnitIdx) const
94
- {
95
- return static_cast <const Derived*>(this )->volumeUnitIdxToVolume_ (volumeUnitIdx);
96
- }
97
-
98
- inline Point3f voxelCoordToVolume (const Vec3i& voxelIdx) const
99
- {
100
- return static_cast <const Derived*>(this )->voxelCoordToVolume_ (voxelIdx);
101
- }
102
- inline Vec3i volumeToVoxelCoord (const Point3f& point) const { return static_cast <const Derived*>(this )->volumeToVoxelCoord_ (point); }
103
-
104
- public:
105
- int maxWeight;
106
- float truncDist;
107
- float truncateThreshold;
108
- int volumeUnitResolution;
109
- float volumeUnitSize;
110
- bool zFirstMemOrder;
111
-
112
- protected:
113
- // ! dimension in voxels, size in meters
114
- // ! Use fixed volume cuboid
115
- // ! Can be only called by derived class
116
- HashTSDFVolume (float _voxelSize, Matx44f _pose, float _raycastStepFactor, float _truncDist, int _maxWeight,
117
- float _truncateThreshold, int _volumeUnitRes, bool zFirstMemOrder = true );
118
- friend Derived;
119
- };
120
-
121
18
struct VolumeUnit
122
19
{
123
20
VolumeUnit () : pVolume(nullptr ){};
@@ -146,60 +43,79 @@ struct tsdf_hash
146
43
typedef std::unordered_set<Vec3i, tsdf_hash> VolumeUnitIndexSet;
147
44
typedef std::unordered_map<Vec3i, VolumeUnit, tsdf_hash> VolumeUnitMap;
148
45
149
- class HashTSDFVolumeCPU : public HashTSDFVolume <HashTSDFVolumeCPU>
46
+ class HashTSDFVolume : public Volume
47
+ {
48
+ public:
49
+ // dimension in voxels, size in meters
50
+ // ! Use fixed volume cuboid
51
+ HashTSDFVolume (float _voxelSize, const Matx44f& _pose, float _raycastStepFactor, float _truncDist,
52
+ int _maxWeight, float _truncateThreshold, int _volumeUnitRes,
53
+ bool zFirstMemOrder = true );
54
+
55
+ virtual ~HashTSDFVolume () = default ;
56
+
57
+ public:
58
+ int maxWeight;
59
+ float truncDist;
60
+ float truncateThreshold;
61
+ int volumeUnitResolution;
62
+ float volumeUnitSize;
63
+ bool zFirstMemOrder;
64
+ };
65
+
66
+ class HashTSDFVolumeCPU : public HashTSDFVolume
150
67
{
151
- typedef HashTSDFVolume<HashTSDFVolumeCPU> Base;
152
68
153
69
public:
154
70
// dimension in voxels, size in meters
155
- HashTSDFVolumeCPU (float _voxelSize, Matx44f _pose, float _raycastStepFactor, float _truncDist, int _maxWeight,
71
+ HashTSDFVolumeCPU (float _voxelSize, const Matx44f& _pose, float _raycastStepFactor, float _truncDist, int _maxWeight,
156
72
float _truncateThreshold, int _volumeUnitRes, bool zFirstMemOrder = true );
157
73
158
74
HashTSDFVolumeCPU (const VolumeParams& _volumeParams, bool zFirstMemOrder = true );
159
75
160
- void integrate_ (InputArray _depth, float depthFactor, const Matx44f& cameraPose, const kinfu::Intr& intrinsics,
161
- const int frameId = 0 );
162
- void raycast_ (const Matx44f& cameraPose, const kinfu::Intr& intrinsics, const Size & frameSize, OutputArray points,
163
- OutputArray normals) const ;
76
+ void integrate (InputArray _depth, float depthFactor, const Matx44f& cameraPose, const kinfu::Intr& intrinsics,
77
+ const int frameId = 0 ) override ;
78
+ void raycast (const Matx44f& cameraPose, const kinfu::Intr& intrinsics, const Size & frameSize, OutputArray points,
79
+ OutputArray normals) const override ;
164
80
165
- void fetchNormals_ (InputArray points, OutputArray _normals) const ;
166
- void fetchPointsNormals_ (OutputArray points, OutputArray normals) const ;
81
+ void fetchNormals (InputArray points, OutputArray _normals) const override ;
82
+ void fetchPointsNormals (OutputArray points, OutputArray normals) const override ;
167
83
168
- void reset_ () ;
169
- size_t getTotalVolumeUnits_ () const { return volumeUnits.size (); }
170
- int getVisibleBlocks_ (int currFrameId, int frameThreshold) const ;
84
+ void reset () override ;
85
+ size_t getTotalVolumeUnits () const { return volumeUnits.size (); }
86
+ int getVisibleBlocks (int currFrameId, int frameThreshold) const ;
171
87
172
88
// ! Return the voxel given the voxel index in the universal volume (1 unit = 1 voxel_length)
173
- TsdfVoxel at_ (const Vec3i& volumeIdx) const ;
89
+ TsdfVoxel at (const Vec3i& volumeIdx) const ;
174
90
175
91
// ! Return the voxel given the point in volume coordinate system i.e., (metric scale 1 unit =
176
92
// ! 1m)
177
- TsdfVoxel at_ (const Point3f& point) const ;
93
+ TsdfVoxel at (const Point3f& point) const ;
178
94
179
- float interpolateVoxelPoint_ (const Point3f& point) const ;
180
- float interpolateVoxel_ (const cv::Point3f& point) const ;
181
- Point3f getNormalVoxel_ (const cv::Point3f& p) const ;
95
+ float interpolateVoxelPoint (const Point3f& point) const ;
96
+ float interpolateVoxel (const cv::Point3f& point) const ;
97
+ Point3f getNormalVoxel (const cv::Point3f& p) const ;
182
98
183
99
// ! Utility functions for coordinate transformations
184
- Vec3i volumeToVolumeUnitIdx_ (const Point3f& point) const ;
185
- Point3f volumeUnitIdxToVolume_ (const Vec3i& volumeUnitIdx) const ;
100
+ Vec3i volumeToVolumeUnitIdx (const Point3f& point) const ;
101
+ Point3f volumeUnitIdxToVolume (const Vec3i& volumeUnitIdx) const ;
186
102
187
- Point3f voxelCoordToVolume_ (const Vec3i& voxelIdx) const ;
188
- Vec3i volumeToVoxelCoord_ (const Point3f& point) const ;
103
+ Point3f voxelCoordToVolume (const Vec3i& voxelIdx) const ;
104
+ Vec3i volumeToVoxelCoord (const Point3f& point) const ;
189
105
190
106
public:
191
107
// ! Hashtable of individual smaller volume units
192
108
VolumeUnitMap volumeUnits;
193
109
};
194
110
195
111
template <typename T>
196
- Ptr <HashTSDFVolume<T> > makeHashTSDFVolume (const VolumeParams& _volumeParams)
112
+ Ptr <HashTSDFVolume> makeHashTSDFVolume (const VolumeParams& _volumeParams)
197
113
{
198
114
return makePtr<T>(_volumeParams);
199
115
}
200
116
201
117
template <typename T>
202
- Ptr <HashTSDFVolume<T> > makeHashTSDFVolume (float _voxelSize, Matx44f _pose, float _raycastStepFactor, float _truncDist,
118
+ Ptr <HashTSDFVolume> makeHashTSDFVolume (float _voxelSize, Matx44f _pose, float _raycastStepFactor, float _truncDist,
203
119
int _maxWeight, float truncateThreshold, int volumeUnitResolution = 16 )
204
120
{
205
121
return makePtr<T>(_voxelSize, _pose, _raycastStepFactor, _truncDist, _maxWeight, truncateThreshold,
0 commit comments