reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-01-17 f7c4a3cfd07adede3308f8d9d3d7315427d90a7c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
 
// This code is also subject to the license terms in the LICENSE_KinectFusion.md file found in this module's directory
 
#ifndef __OPENCV_RGBD_KINFU_HPP__
#define __OPENCV_RGBD_KINFU_HPP__
 
#include "opencv2/core.hpp"
#include "opencv2/core/affine.hpp"
 
namespace cv {
namespace kinfu {
//! @addtogroup kinect_fusion
//! @{
 
struct CV_EXPORTS_W Params
{
    /** @brief Default parameters
    A set of parameters which provides better model quality, can be very slow.
    */
    CV_WRAP static Ptr<Params> defaultParams();
 
    /** @brief Coarse parameters
    A set of parameters which provides better speed, can fail to match frames
    in case of rapid sensor motion.
    */
    CV_WRAP static Ptr<Params> coarseParams();
 
    /** @brief frame size in pixels */
    CV_PROP_RW Size frameSize;
 
    /** @brief camera intrinsics */
    CV_PROP Matx33f intr;
 
    /** @brief pre-scale per 1 meter for input values
 
    Typical values are:
         * 5000 per 1 meter for the 16-bit PNG files of TUM database
         * 1000 per 1 meter for Kinect 2 device
         * 1 per 1 meter for the 32-bit float images in the ROS bag files
    */
    CV_PROP_RW float depthFactor;
 
    /** @brief Depth sigma in meters for bilateral smooth */
    CV_PROP_RW float bilateral_sigma_depth;
    /** @brief Spatial sigma in pixels for bilateral smooth */
    CV_PROP_RW float bilateral_sigma_spatial;
    /** @brief Kernel size in pixels for bilateral smooth */
    CV_PROP_RW int   bilateral_kernel_size;
 
    /** @brief Number of pyramid levels for ICP */
    CV_PROP_RW int pyramidLevels;
 
    /** @brief Resolution of voxel space
 
    Number of voxels in each dimension.
    */
    CV_PROP_RW Vec3i volumeDims;
    /** @brief Size of voxel in meters */
    CV_PROP_RW float voxelSize;
 
    /** @brief Minimal camera movement in meters
 
    Integrate new depth frame only if camera movement exceeds this value.
    */
    CV_PROP_RW float tsdf_min_camera_movement;
 
    /** @brief initial volume pose in meters */
    Affine3f volumePose;
 
    /** @brief distance to truncate in meters
 
    Distances to surface that exceed this value will be truncated to 1.0.
    */
    CV_PROP_RW float tsdf_trunc_dist;
 
    /** @brief max number of frames per voxel
 
    Each voxel keeps running average of distances no longer than this value.
    */
    CV_PROP_RW int tsdf_max_weight;
 
    /** @brief A length of one raycast step
 
    How much voxel sizes we skip each raycast step
    */
    CV_PROP_RW float raycast_step_factor;
 
    // gradient delta in voxel sizes
    // fixed at 1.0f
    // float gradient_delta_factor;
 
    /** @brief light pose for rendering in meters */
    CV_PROP Vec3f lightPose;
 
    /** @brief distance theshold for ICP in meters */
    CV_PROP_RW float icpDistThresh;
    /** angle threshold for ICP in radians */
    CV_PROP_RW float icpAngleThresh;
    /** number of ICP iterations for each pyramid level */
    CV_PROP std::vector<int> icpIterations;
 
    // depth truncation is not used by default
    // float icp_truncate_depth_dist; //meters
};
 
/** @brief KinectFusion implementation
 
  This class implements a 3d reconstruction algorithm described in
  @cite kinectfusion paper.
 
  It takes a sequence of depth images taken from depth sensor
  (or any depth images source such as stereo camera matching algorithm or even raymarching renderer).
  The output can be obtained as a vector of points and their normals
  or can be Phong-rendered from given camera pose.
 
  An internal representation of a model is a voxel cuboid that keeps TSDF values
  which are a sort of distances to the surface (for details read the @cite kinectfusion article about TSDF).
  There is no interface to that representation yet.
 
  KinFu uses OpenCL acceleration automatically if available.
  To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL().
 
  This implementation is based on [kinfu-remake](https://github.com/Nerei/kinfu_remake).
 
  Note that the KinectFusion algorithm was patented and its use may be restricted by
  the list of patents mentioned in README.md file in this module directory.
 
  That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use KinectFusion.
*/
class CV_EXPORTS_W KinFu
{
public:
    CV_WRAP static Ptr<KinFu> create(const Ptr<Params>& _params);
    virtual ~KinFu();
 
    /** @brief Get current parameters */
    virtual const Params& getParams() const = 0;
 
    /** @brief Renders a volume into an image
 
      Renders a 0-surface of TSDF using Phong shading into a CV_8UC4 Mat.
      Light pose is fixed in KinFu params.
 
        @param image resulting image
        @param cameraPose pose of camera to render from. If empty then render from current pose
        which is a last frame camera pose.
    */
 
    CV_WRAP virtual void render(OutputArray image, const Matx44f& cameraPose = Matx44f::eye()) const = 0;
 
    /** @brief Gets points and normals of current 3d mesh
 
      The order of normals corresponds to order of points.
      The order of points is undefined.
 
        @param points vector of points which are 4-float vectors
        @param normals vector of normals which are 4-float vectors
     */
    CV_WRAP virtual void getCloud(OutputArray points, OutputArray normals) const = 0;
 
    /** @brief Gets points of current 3d mesh
 
     The order of points is undefined.
 
        @param points vector of points which are 4-float vectors
     */
    CV_WRAP virtual void getPoints(OutputArray points) const = 0;
 
    /** @brief Calculates normals for given points
        @param points input vector of points which are 4-float vectors
        @param normals output vector of corresponding normals which are 4-float vectors
     */
    CV_WRAP virtual  void getNormals(InputArray points, OutputArray normals) const = 0;
 
    /** @brief Resets the algorithm
 
    Clears current model and resets a pose.
    */
    CV_WRAP virtual void reset() = 0;
 
    /** @brief Get current pose in voxel space */
    virtual const Affine3f getPose() const = 0;
 
    /** @brief Process next depth frame
 
      Integrates depth into voxel space with respect to its ICP-calculated pose.
      Input image is converted to CV_32F internally if has another type.
 
    @param depth one-channel image which size and depth scale is described in algorithm's parameters
    @return true if succeded to align new frame with current scene, false if opposite
    */
    CV_WRAP virtual bool update(InputArray depth) = 0;
};
 
//! @}
}
}
#endif