aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Roth <roth@stettbacher.ch>2021-06-21 09:49:33 +0200
committerPatrick Roth <roth@stettbacher.ch>2021-06-21 09:49:33 +0200
commit5102ecddb720c9b14c27fe07e909d43cad69c584 (patch)
tree111dba49aebf6328d4e7354cd31534bc51aa37ee
parentdistinguish between 32 or 64 bit compiler version (diff)
downloado3000-color-pipe-5102ecddb720c9b14c27fe07e909d43cad69c584.tar.gz
o3000-color-pipe-5102ecddb720c9b14c27fe07e909d43cad69c584.zip
debug processing time
-rw-r--r--color_pipe.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/color_pipe.c b/color_pipe.c
index 0f7ae32..0b77c61 100644
--- a/color_pipe.c
+++ b/color_pipe.c
@@ -27,6 +27,15 @@
*/
+/**
+ * Uncomment to analyze image processing time
+ */
+// #define DEBUG_PROC_TIME
+
+#ifdef DEBUG_PROC_TIME
+#include <sys/time.h>
+#endif // DEBUG_PROC_TIME
+
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@@ -325,6 +334,25 @@ static const float ccm_presets[][3][3] = {
+#ifdef DEBUG_PROC_TIME
+/**
+ * Return timestamp in milliseconds.
+ * The actual time the Epoch in milliseconds is returned.
+ */
+uint64_t get_ts(void) {
+ struct timeval tv;
+ uint64_t ts;
+
+ if(gettimeofday(&tv, NULL)) {
+ printf("%s: %s\n", __func__, strerror(errno));
+ return 0;
+ }
+
+ ts = (uint64_t)tv.tv_sec * 1e3 + (uint64_t)tv.tv_usec/1000;
+ return ts;
+}
+#endif // DEBUG_PROC_TIME
+
/**
* Initialize pipeline with reasonable default value.
@@ -427,7 +455,11 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
void *img_out;
enum o3000_lenses_t lens_type;
enum ccm_preset_t ccm_type;
-
+
+#ifdef DEBUG_PROC_TIME
+ uint64_t ts_start = get_ts();
+ uint64_t ts_debayer, ts_awb, ts_calib, ts_ccm, ts_sharp, ts_gamma;
+#endif // DEBUG_PROC_TIME
/*
* Extract image header information.
@@ -470,6 +502,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
img_out = color_pipe->debayer_data.img_rgb;
}
+#ifdef DEBUG_PROC_TIME
+ ts_debayer = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -504,6 +539,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
color_pipe->awb_data.gain_red = 1;
color_pipe->awb_data.gain_blue = 1;
}
+#ifdef DEBUG_PROC_TIME
+ ts_awb = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -561,6 +599,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
img_out = color_pipe->cam_calib_data.img_calib;
}
+#ifdef DEBUG_PROC_TIME
+ ts_calib = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -583,6 +624,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
img_out = color_pipe->color_calib_data.img_calib;
}
+#ifdef DEBUG_PROC_TIME
+ ts_ccm = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -604,6 +648,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
img_out = color_pipe->sharp_data.img_sharp;
}
+#ifdef DEBUG_PROC_TIME
+ ts_sharp = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -623,6 +670,9 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
img_out = color_pipe->gamma_data.img_gamma;
}
+#ifdef DEBUG_PROC_TIME
+ ts_gamma = get_ts();
+#endif // DEBUG_PROC_TIME
/*
@@ -633,6 +683,16 @@ void __stdcall color_pipe_process(struct color_pipe_t *__restrict__ color_pipe,
color_pipe->bit_channel = bit_channel;
color_pipe->width = width;
color_pipe->height = height;
+
+
+#ifdef DEBUG_PROC_TIME
+ printf(" debayer: %lld msec\n", ts_debayer - ts_start);
+ printf(" awb: %lld msec\n", ts_awb - ts_debayer);
+ printf(" camera calib: %lld msec\n", ts_calib - ts_awb);
+ printf(" color correction: %lld msec\n", ts_ccm - ts_calib);
+ printf(" sharpening: %lld msec\n", ts_sharp - ts_ccm);
+ printf(" gamma: %lld msec\n", ts_gamma - ts_sharp);
+#endif // DEBUG_PROC_TIME
}