32 mat[0] = -(1 - 2 *
q.y*
q.y - 2 *
q.z*
q.z); mat[4] = 2 *
q.
x*
q.y - 2 *
q.z*
q.w; mat[8] = -(2 *
q.x*
q.z + 2 *
q.y*
q.w); mat[12] =
t.x;
33 mat[1] = -(2 *
q.x*
q.y + 2 *
q.z*
q.w); mat[5] = 1 - 2 *
q.x*
q.x - 2 *
q.z*
q.z; mat[9] = -(2 *
q.y*
q.z - 2 *
q.x*
q.w); mat[13] =
t.y;
34 mat[2] = -(2 *
q.x*
q.z - 2 *
q.y*
q.w); mat[6] = 2 *
q.y*
q.z + 2 *
q.x*
q.w; mat[10] = -(1 - 2 *
q.x*
q.x - 2 *
q.y*
q.y); mat[14] =
t.z;
35 mat[3] = 0.0f; mat[7] = 0.0f; mat[11] = 0.0f; mat[15] = 1.0f;
41 max_coord.x = std::max(max_coord.x, point.
x);
42 max_coord.y = std::max(max_coord.y, point.
y);
43 max_coord.z = std::max(max_coord.z, point.
z);
44 min_coord.x =
std::min(min_coord.x, point.
x);
45 min_coord.y =
std::min(min_coord.y, point.
y);
46 min_coord.z =
std::min(min_coord.z, point.
z);
53 if (trajectory.size() == 0)
55 trajectory.push_back(p);
64 if (sqrt(pow((curr.
x - prev.
x), 2) + pow((curr.
y - prev.
y), 2) + pow((curr.
z - prev.
z), 2)) < 0.001)
67 if (p.
confidence > trajectory.back().confidence)
69 trajectory.back() =
p;
70 update_min_max(p.
point);
76 trajectory.push_back(p);
77 update_min_max(p.
point);
94 for (
auto&&
v : trajectory)
141 for (
auto&
i : indexes)
153 std::vector<float3> positions, normals;
154 std::vector<short3> indexes;
163 for (
int i = 0;
i <= 8;
i++)
182 gluPerspective(60.0, 4 / 3, 0.5, 100);
188 gluLookAt(1, -1, 4, 0, 1, 0, 0, 0, 1);
216 float bar_width = 0.1f;
218 float bar_scale = bar_width / scale_factor;
223 bar_scale = floor(bar_scale);
227 int diff = 5 - int(bar_scale) % 5;
228 bar_scale = bar_scale + diff;
231 bar_width = scale_factor * bar_scale;
234 std::stringstream ss;
235 ss << bar_scale <<
" m";
238 ss.clear(); ss.str(
"");
259 : width(width), height(height), aspect (height / width),
t(tracker), renderer(r) { }
276 glOrtho(-1.0, 1.0, -1.0 * aspect, 1.0 * aspect, -100.0, 100.0);
304 renderer.render_camera();
320 :
view(width, height, tracker, renderer), a(a), b(b), c(c), lookat_eye(lookat_eye), window_borders{ 1, aspect }
327 float bar_width =
display_scale(scale_factor, scale_pos.
x, scale_pos.
y);
333 load_matrices(pos, width, height);
341 gluLookAt(lookat_eye.x, lookat_eye.y, lookat_eye.z, 0, 0, 0, 0, 1, 0);
345 glScalef(scale_factor, scale_factor, scale_factor);
352 window_borders.x = window_borders.x * 2;
353 window_borders.y = window_borders.y * 2;
356 draw_cam_trajectory(180, { 0, 1, 0 },
r);
362 float scale_factor = 1.0;
372 :
view(width, height, tracker, renderer) { }
377 load_matrices(pos, app_width, app_height);
381 draw_cam_trajectory(90, { 1, 0, 0 },
r);
392 :
top(app_width, app_height, tracker, renderer,
rs2_vector{ 0, 10, -(1
e-3
f) }, &
rs2_vector::x, &
rs2_vector::z, &
rs2_vector::y),
393 front(app_width, app_height,
tracker, renderer,
rs2_vector{ 0, 0, -10 }, &
rs2_vector::x, &
rs2_vector::y, &
rs2_vector::z),
394 side(app_width, app_height,
tracker, renderer,
rs2_vector{ 10, 0, 0 }, &
rs2_vector::z, &
rs2_vector::y, &
rs2_vector::x),
395 three_dim(app_width, app_height,
tracker, renderer)
405 top.draw_view({ 0, app_height / 2 }, app_width, app_height,
float2{ float(0.457) * app_width, float(0.49) * app_height },
r);
407 front.draw_view({ 0, 0 }, app_width, app_height,
float2{ float(0.457) * app_width, float(0.99) * app_height },
r);
409 side.draw_view({ app_width / 2, 0 }, app_width, app_height,
float2{ float(0.957) * app_width, float(0.99) * app_height },
r);
411 three_dim.draw_view({ app_width / 2, app_height / 2 }, app_width, app_height, app_state,
r);
415 draw_text(
int(0.005
f * app_width),
int(0.02
f * app_height),
"TOP");
416 draw_text(
int(0.005
f * app_width),
int(0.52
f * app_height),
"FRONT");
417 draw_text(
int(0.505
f * app_width),
int(0.52
f * app_height),
"SIDE");
418 draw_text(
int(0.505
f * app_width),
int(0.02
f * app_height),
"3D");
422 draw_text(
int(0.494
f * app_width),
int(0.261
f * app_height),
"x");
423 draw_text(
int(0.494
f * app_width),
int(0.761
f * app_height),
"x");
425 draw_text(
int(0.245
f * app_width),
int(0.01
f * app_height),
"z");
426 draw_text(
int(0.503
f * app_width),
int(0.761
f * app_height),
"z");
428 draw_text(
int(0.245
f * app_width),
int(0.995
f * app_height),
"y");
429 draw_text(
int(0.745
f * app_width),
int(0.995
f * app_height),
"y");
440 int main(
int argc,
char * argv[])
try 443 window app(1280, 720,
"RealSense Trajectory Example");
469 auto frames = pipe.wait_for_frames();
484 screen_renderer.draw_windows(app.
width(), app.
height(), app_state,
r);
494 catch (
const std::exception& e)
GLboolean GLboolean GLboolean b
void draw_view(float2 pos, float width, float height, float2 scale_pos, float r[16])
void draw_cam_trajectory(float angle, float3 axes, float r[16])
GLdouble GLdouble GLdouble top
def axes(out, pos, rotation=np.eye(3), size=0.075, thickness=2)
rs2_vector get_max_coord()
std::vector< tracked_point > trajectory
int main(int argc, char *argv[])
void load_matrices(float2 pos, float app_width, float app_height)
GLboolean GLboolean GLboolean GLboolean a
const std::string & get_failed_args() const
camera_renderer & renderer
void render_scene(glfw_state app_state)
split_screen_renderer(float app_width, float app_height, tracker &tracker, camera_renderer &renderer)
rs2_vector get_min_coord()
#define GL_COLOR_BUFFER_BIT
GLint GLsizei GLsizei height
void uncompress_t265_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
view_2d(float width, float height, tracker &tracker, camera_renderer &renderer, rs2_vector lookat_eye, pos a, pos b, pos c)
view_3d(float width, float height, tracker &tracker, camera_renderer &renderer)
void enable_stream(rs2_stream stream_type, int stream_index, int width, int height, rs2_format format=RS2_FORMAT_ANY, int framerate=0)
#define GL_DEPTH_BUFFER_BIT
void draw_view(float2 pos, float app_width, float app_height, glfw_state app_state, float r[16])
3D vector in Euclidean coordinate space
GLdouble GLdouble GLdouble q
void draw_text(int x, int y, const char *text)
view(float width, float height, tracker &tracker, camera_renderer &r)
void add_to_trajectory(tracked_point &p)
void calc_transform(rs2_pose &pose_data, float mat[16])
void register_glfw_callbacks(window &app, glfw_state &app_state)
float display_scale(float scale_factor, float x_pos, float y_pos)
const std::string & get_failed_function() const
void draw_windows(float app_width, float app_height, glfw_state app_state, float r[16])
void update_min_max(rs2_vector point)