diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 17:06:10 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 17:06:10 +0200 |
commit | b85255a2b51a601b4819b150ade9b16887a06c23 (patch) | |
tree | c1e89e787e83dd91251040fa5aabe34e3eea0939 | |
parent | 6c0869b16849ac665c49a055ae48985485b9fa04 (diff) | |
download | libuca-b85255a2b51a601b4819b150ade9b16887a06c23.tar.gz libuca-b85255a2b51a601b4819b150ade9b16887a06c23.tar.bz2 libuca-b85255a2b51a601b4819b150ade9b16887a06c23.tar.xz libuca-b85255a2b51a601b4819b150ade9b16887a06c23.zip |
Print the current frame as feed-back
-rw-r--r-- | src/cameras/uca-mock-camera.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/cameras/uca-mock-camera.c b/src/cameras/uca-mock-camera.c index da186a8..d27423e 100644 --- a/src/cameras/uca-mock-camera.c +++ b/src/cameras/uca-mock-camera.c @@ -71,6 +71,7 @@ struct _UcaMockCameraPrivate { gfloat frame_rate; gfloat max_frame_rate; guint8 *dummy_data; + guint current_frame; gboolean thread_running; @@ -78,6 +79,94 @@ struct _UcaMockCameraPrivate { GValueArray *binnings; }; +static const char g_digits[10][20] = { + /* 0 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 1 */ + { 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0x00, 0xff, 0x00 }, + /* 2 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff }, + /* 3 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 4 */ + { 0xff, 0x00, 0x00, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff }, + /* 5 */ + { 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0x00 }, + /* 6 */ + { 0x00, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 7 */ + { 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0xff, 0x00, + 0x00, 0xff, 0x00, 0x00, + 0xff, 0x00, 0x00, 0x00 }, + /* 8 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0x00 }, + /* 9 */ + { 0x00, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x00, 0xff, + 0x00, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0x00 } +}; + +const guint DIGIT_WIDTH = 4; +const guint DIGIT_HEIGHT = 5; + +static void print_number(gchar *buffer, guint number, guint x, guint y, guint width) +{ + for (int i = 0; i < DIGIT_WIDTH; i++) { + for (int j = 0; j < DIGIT_HEIGHT; j++) { + buffer[(y+j)*width + (x+i)] = g_digits[number][j*DIGIT_WIDTH+i]; + } + } +} + +static void print_current_frame(UcaMockCameraPrivate *priv, gchar *buffer) +{ + guint number = priv->current_frame; + guint divisor = 100000000; + int x = 10; + while (divisor > 1) { + print_number(buffer, number / divisor, x, 10, priv->width); + number = number % divisor; + divisor = divisor / 10; + x += DIGIT_WIDTH + 1; + } +} + /** * uca_mock_camera_new: * @error: Location for error @@ -163,6 +252,8 @@ static void uca_mock_camera_grab(UcaCamera *camera, gpointer *data, GError **err *data = g_malloc0(priv->width * priv->height); g_memmove(*data, priv->dummy_data, priv->width * priv->height); + print_current_frame(priv, *data); + priv->current_frame++; } static void uca_mock_camera_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) @@ -290,6 +381,7 @@ static void uca_mock_camera_init(UcaMockCamera *self) self->priv->frame_rate = self->priv->max_frame_rate = 100000.0f; self->priv->dummy_data = (guint8 *) g_malloc0(self->priv->width * self->priv->height); self->priv->grab_thread = NULL; + self->priv->current_frame = 0; self->priv->binnings = g_value_array_new(1); GValue val = {0}; |