Skip to content

Commit

Permalink
benchmark alignment time
Browse files Browse the repository at this point in the history
- simple measurment
- to get idea about alignment time and total frame processing time

Related to #18
  • Loading branch information
bmegli committed Jun 9, 2020
1 parent 214ad1f commit 307d8a9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rnhve_depth_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <iostream>
#include <math.h>

//benchmark related
#include <time.h> //clock_gettime

using namespace std;

int hint_user_on_failure(char *argv[]);
Expand Down Expand Up @@ -91,10 +94,15 @@ bool main_loop(const input_args& input, rs2::pipeline& realsense, nhve *streamer

rs2::align aligner( (input.align_to == Color) ? RS2_STREAM_COLOR : RS2_STREAM_DEPTH);

struct timespec start, end, end_all;

for(f = 0; f < frames; ++f)
{
rs2::frameset frameset = realsense.wait_for_frames();
clock_gettime(CLOCK_MONOTONIC_RAW, &start);
frameset = aligner.process(frameset);
clock_gettime(CLOCK_MONOTONIC_RAW, &end);


rs2::depth_frame depth = frameset.get_depth_frame();
rs2::video_frame color = frameset.get_color_frame();
Expand Down Expand Up @@ -125,6 +133,12 @@ bool main_loop(const input_args& input, rs2::pipeline& realsense, nhve *streamer
cerr << "failed to send" << endl;
break;
}

clock_gettime(CLOCK_MONOTONIC_RAW, &end_all);
double align_ms = (end.tv_nsec - start.tv_nsec) / 1000000.0;
double all_ms = (end_all.tv_nsec - start.tv_nsec) / 1000000.0;

cout << "aligned in " << align_ms << " ms" << " align + encode + send in " << all_ms << endl;
}

//flush the streamer by sending NULL frame
Expand Down

0 comments on commit 307d8a9

Please sign in to comment.