Chose promise, chose due

April 3rd, 2010 by emmanuel

Here’s an example of the use of the ArvCamera API of Aravis:

#include <arv.h>
#include <stdlib.h>

static gboolean cancel = FALSE;

static void
set_cancel (int signal)
{
	cancel = TRUE;
}

static char *arv_option_camera_name = NULL;
static char *arv_option_debug_domains = NULL;
static gboolean arv_option_snaphot = FALSE;
static gboolean arv_option_auto_buffer = FALSE;
static int arv_option_width = -1;
static int arv_option_height = -1;
static int arv_option_horizontal_binning = -1;
static int arv_option_vertical_binning = -1;

static const GOptionEntry arv_option_entries[] =
{
	{ "name",		'n', 0, G_OPTION_ARG_STRING,
		&arv_option_camera_name,"Camera name", NULL},
	{ "snapshot",		's', 0, G_OPTION_ARG_NONE,
		&arv_option_snaphot,	"Snapshot", NULL},
	{ "auto",		'a', 0, G_OPTION_ARG_NONE,
		&arv_option_auto_buffer,	"AutoBufferSize", NULL},
	{ "width", 		'w', 0, G_OPTION_ARG_INT,
		&arv_option_width,		"Width", NULL },
	{ "height", 		'h', 0, G_OPTION_ARG_INT,
		&arv_option_height, 		"Height", NULL },
	{ "h-binning", 		'\0', 0, G_OPTION_ARG_INT,
		&arv_option_horizontal_binning,"Horizontal binning", NULL },
	{ "v-binning", 		'\0', 0, G_OPTION_ARG_INT,
		&arv_option_vertical_binning, 	"Vertical binning", NULL },
	{ "debug", 		'd', 0, G_OPTION_ARG_STRING,
		&arv_option_debug_domains, 	"Debug mode", NULL },
	{ NULL }
};

int
main (int argc, char **argv)
{
	ArvCamera *camera;
	ArvStream *stream;
	ArvBuffer *buffer;
	GOptionContext *context;
	GError *error = NULL;
	int i;

	g_thread_init (NULL);
	g_type_init ();

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, arv_option_entries, NULL);

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_option_context_free (context);
		g_print ("Option parsing failed: %s\n", error->message);
		g_error_free (error);
		return EXIT_FAILURE;
	}

	g_option_context_free (context);

	arv_debug_enable (arv_option_debug_domains);

	if (arv_option_camera_name == NULL)
		g_print ("Looking for the first available camera\n");
	else
		g_print ("Looking for camera '%s'\n", arv_option_camera_name);

	camera = arv_camera_new (arv_option_camera_name);
	if (camera != NULL) {
		gint payload;
		gint x, y, width, height;
		gint dx, dy;
		double exposure;
		guint64 n_processed_buffers;
		guint64 n_failures;
		guint64 n_underruns;

		arv_camera_set_region (camera, 0, 0, arv_option_width, arv_option_height);
		arv_camera_set_binning (camera, arv_option_horizontal_binning, arv_option_vertical_binning);

		arv_camera_get_region (camera, &x, &y, &width, &height);
		arv_camera_get_binning (camera, &dx, &dy);
		exposure = arv_camera_get_exposure_time (camera);
		payload = arv_camera_get_payload (camera);

		g_print ("image width         = %d\n", width);
		g_print ("image height        = %d\n", height);
		g_print ("horizontal binning  = %d\n", dx);
		g_print ("vertical binning    = %d\n", dy);
		g_print ("exposure            = %g ┬Ás\n", exposure);

		stream = arv_camera_new_stream (camera);
		if (arv_option_auto_buffer)
			arv_gv_stream_set_option (ARV_GV_STREAM (stream),
						  ARV_GV_STREAM_OPTION_SOCKET_BUFFER_AUTO,
						  0);

		for (i = 0; i < 30; i++)
			arv_stream_push_buffer (stream, arv_buffer_new (payload, NULL));

		arv_camera_start_acquisition (camera);

		signal (SIGINT, set_cancel);

		do {
			g_usleep (100000);

			do  {
				buffer = arv_stream_pop_buffer (stream);
				if (buffer != NULL) {
					/* Image processing here */
					arv_stream_push_buffer (stream, buffer);
				}
			} while (buffer != NULL);
		} while (!cancel);

		arv_stream_get_statistics (stream, &n_processed_buffers, &n_failures, &n_underruns);

		g_print ("Processed buffers = %Ld\n", n_processed_buffers);
		g_print ("Failures          = %Ld\n", n_failures);
		g_print ("Underruns         = %Ld\n", n_underruns);

		arv_camera_stop_acquisition (camera);

		g_object_unref (stream);
		g_object_unref (camera);
	} else
		g_print ("No camera found\n");

	return 0;
}

A direct use of the Genicam API is shown in the arv-test.c file in the git repository:
http://git.gnome.org/browse/aravis/tree/src/arvtest.c

Aravis, a vision library

April 1st, 2010 by emmanuel

I’ve just pushed the Aravis source code to git.gnome.org.

http://git.gnome.org/browse/aravis/

Aravis is a glib/gobject based library implementing a Genicam interface, which can be used for the acquisition of video streams coming from either ethernet, firewire or USB cameras. It currently only implements an ethernet camera protocol used for industrial cameras.

Aravis is released under the LGPL v2+.

http://www.genicam.org/

Most features of the Genicam standard are implemented, with the notable exception of the Enumeration and Boolean interfaces. It’s already possible to take the control of a camera, to start and stop the acquisition, and to get the images from the data stream.

There’s no documentation, but most of the code can be understood by reading the Genicam standard. I’ll post an example showing a basic use of the Aravis library.

The current roadmap is:

  • Finish the implementation of the Genicam interface
  • Implement the packet resend feature for ethernet cameras
  • Add a gstreamer source for broadcast of the video stream
  • Work on firewire camera support

FTP and Bugzilla for Lasem

May 3rd, 2009 by emmanuel

With the help of Chritian Rose and Christian Kirbach, Lasem now has its tarballs published on ftp.gnome.org:

http://ftp.gnome.org/pub/GNOME/sources/lasem/

And a bugzilla product:

http://bugzilla.gnome.org/enter_bug.cgi?product=lasem

Lasem git repository

April 23rd, 2009 by emmanuel

Since gnome has finished its SVN to git conversion, I’ve created a repository for lasem on git.gnome.org.

Here’s the direct link:

http://git.gnome.org/cgit/lasem/

I still have to ask for a mailing list and a bugzilla product…

GMathml is dead, long live Lasem

April 11th, 2009 by emmanuel

Since GMathml is no longer only a MathML library, but can also render SVG now, I have renamed it to Lasem. The name comes from the city of Lasem, known for its batik manufactures. It could be the acronym for “Library for Awesome SVG and Exceptional MathML”. But to be honest, it’s more an acronym for “Library for Awful SVG and Eccentric MathML”.

Only a really small subset of SVG 1.1 is supported for now. Here’s some samples of what can do Lasem:

paths-data-02-t

paths-data-02-t

pservers-grad-06-b

pservers-grad-06-b

coords-trans-01-b

coords-trans-01-b

Equations in gnumeric

December 9th, 2008 by emmanuel

The last few days, I’ve added a preliminary support for equations in the goffice charting engine. I’ve made a little screencast showing the new equation object in action:


Gnumeric equation in action from Emmanuel Pacaud on Vimeo.

GMathml

December 9th, 2008 by emmanuel

For some months (actually almost one year), I’m working on a mathml renderer based on gobject and cairo, with a DOM like interface. It has started as a vala experiment, but after a few weeks, after being blocked in my work by some bugs or missing features, I came back to raw gobject programming. Most of the vala bugs I’ve encountered are probably fixed by now, so it’s possible I’ll try to get back to vala one day.

The git repository is here:

http://cgit.freedesktop.org/~emmanuel/gmathml/

which can be cloned using the following command:


git clone git://anongit.freedesktop.org/~emmanuel/gmathml

It consists in a library, libgmathml, and a small rendering application, gmathmlrender, which is able to output to either PNG, PDF or SVG. In addition to mathml, gmathml also understand itex, by the mean of itex2mml (http://golem.ph.utexas.edu/~distler/blog/itex2MML.html).

For example, the following equation:


\left\langle {a + a \over x - a} | \epsilon_\Xi(a) \right\rangle = \left\{ \frac{1}{N} \sum_{i=0}^N \frac{x^i}{i!} + \Xi \int_0^x \epsilon_0(at) \, dt \right\}

Gives:

Sample PNG output

Sample PNG output

The same using the PDF output.

Here’s the reference image, produced by latex:

Reference image

Reference image

The project is far from finished, but it’s almost in a usable state, so I’ll probably do a release soon.

New graphing features of goffice 0.6

February 24th, 2008 by emmanuel

The last stable version of gnumeric, released a few months ago, uses goffice 0.6, which has seen a lot of improvements since goffice 0.2 used previously by gnumeric 1.6.x.

First of all, we have ditched the multi-backend renderer and now we use cairo as our rendering abstraction layer. That means less code on our side, a nice API to use (no more libart…) and we have now a direct support of PDF/PS export.

Here’s the output of a sample graph, exported as PNG:

sample-01.png

And the same graph as PDF and SVG.

The graph legend has a better layout, and a its swatches are more close to what’s actually drawn in the chart area.

legend-01.png

legend-02.png

legend-04.png

legend-04.png

legend-05.png

There’s some new number formats for better display of log axis labels and of polar axis labels when using a radian unit. Polar plots can be rotated, and it’s possible to choose the start/end angle. In addition to chart grid, we have now stripes.

polar-stripe-radian.png

XY and polar plots fully support filled area and the different interpolation types (linear, spline, step).

xy-fill-interpolation.png

polar-fill-interpolation.png

There’s more line styles:

line-style.png

We have a support for regression curves, with a display of the calculated cofficients.

fit-ln.png

moving-average.png