Skip to content

Commit d3b9d8f

Browse files
committed
add apply method
1 parent b89583f commit d3b9d8f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

examples/protonect/include/libfreenect2/registration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class LIBFREENECT2_API Registration
3939
public:
4040
Registration(protocol::DepthCameraParamsResponse *depth_p, protocol::RgbCameraParamsResponse *rgb_p);
4141

42+
void apply( int dx, int dy, float dz, float& cx, float &cy);
43+
4244
private:
4345
void undistort_depth(float dx, float dy, float& mx, float& my);
4446
void depth_to_color(float mx, float my, float& rx, float& ry);

examples/protonect/src/registration.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@ void Registration::depth_to_color(float mx, float my, float& rx, float& ry)
7171
rx = wx / (color->color_f * color_q);
7272
ry = wy / (color->color_f * color_q);
7373
}
74-
/*
75-
rx += (depth->shift_m / z) - (depth->shift_m / depth->shift_d);
7674

77-
rx = rx * color->fx + color_cx;
78-
ry = ry * color->fy + color_cy;
79-
}*/
75+
void Registration::apply( int dx, int dy, float dz, float& cx, float &cy)
76+
{
77+
float rx = depth_to_color_map[dx][dy][0];
78+
float ry = depth_to_color_map[dx][dy][1];
79+
80+
rx += (color->shift_m / dz) - (color->shift_m / color->shift_d);
81+
82+
cx = rx * color->color_f + color->color_cx;
83+
cy = ry * color->color_f + color->color_cy;
84+
}
8085

8186
Registration::Registration(protocol::DepthCameraParamsResponse *depth_p, protocol::RgbCameraParamsResponse *rgb_p):
8287
depth(depth_p), color(rgb_p)

0 commit comments

Comments
 (0)