CamUnits plugins for EMC2
If you hardly read english docs there is russian version of this page. However it contains less info.


There is obvious need in integrating video support into EMC [emc]. From simple live video window for manual adjusting to full fledged CV implementations for computer aided marker tracking.

First attemtps were documented on EMC forum [emc-forum-video]. Proposed solution was to patch gqcam, small and simple V4L application. While this solution is very simple it’s hard to add CV algorithms into it. So after some investigations on the topic choices were limited to two frameworks: GStreamer and CamUnits [camunits]. Second framework looks more reasonable for EMC since it was created for CV tasks and has very clean codebase. It’s main concept is Unit — stream processing unit which may perform some image conversion.

After choosing CamUnits as base framework there was some work going into patching camview tool from it to allow embedding in Axis window via XEmbed protocol. But soon it comes obvious that using stock camview is not wise for EMC for several reasons:

  • controls are eating too much space when embeded in Axis;

  • needed controls are hard to find;

  • user have to create chain even in simple cases.

For camview clone hard way was choosen — create python bidings [pycamunits] and then write simple python script. Since CamUnits is GLib based and GUI part is using Gtk it was not that hard. But after creating python bindings simple camview replacement (without manager/control widgets) may be written in ~30 lines of code!.

How to get it?

If you are using EMC2 packages for Ubuntu (10.04 or 8.04) it’s simple — add repository as described in

Then install package camview-emc. If you need extra functionality like DRO install camunits-plugins-emc. It’s not available for Ubuntu 8.04 though.

Also you may grab sources and build them yourself. But that’s not recommended since there are lot of dependencies and possible issues with plugin locations.

Not all features from theese packages are included into upstream source. Don’t grab sources from camunits website.

How to use it?

Usual way is to use embeded tabs in Axis or Touchy and place camview-emc there like in [fig:camview-emc-axis].

Figure 1. Axis with CamView window embeded.
[Image by Slavko Kocjancic]

How to extend it?

camview-emc is easily expandable by user with embeded GladeVcp [gladevcp] panels. You may notice such panel in the image [fig:camview-emc-axis] near bottom right corner of video widget.

GladeVcp is available starting with EMC 2.5! You won’t be able to add panels in with older versions.


If you see just black window or garbage like thin vertical stripes in camview instead of normal image something went wrong :) Possible cases are:

  • broken input driver;

  • plugin conflicts caused by another installation from source;

  • non-working OpenGL renderer.

First check that there are no plugins in /usr/local/lib/camunits and libraries in /usr/local/lib. If you’ve first downloaded camunits source and installed it with make install then it’s your case. Remove everything in theese paths


and process to next step.

To find out if OpenGL renderer is ok you have two options: use example input or vivi V4L2 input module. To use example input just run camview and compose chain with it and renderer. If you see moving square then renderer is working. Second option is to use vivi input module — virtual video driver for testing V4L2 applications. Just run

# modprobe vivi

And you’ll get another video device. Select it in camview and add renderer unit. You’ll see moving colored stripes.

In both cases if you see result then OpenGL renderer is ok and something bad is in your camera capture. If you get black square then problem is in renderer.

One known workaround is to install libgl-mesa-swx11 package — software implementation of OpenGL. RTAI kernel is known to have issues with graphics drivers so this may help (see EMC2 wiki).

List of plugins

There are several plugins shipping along with camview-emc. Here is list of plugins packaged into camunits-plugins-emc-misc:

  • input.image: Use image as input. Generates new frame at requested rate. Targeted for testing different processing algorithms. More simple solution then input.log plugin. Based on FreeImage library [freeimage].

  • convert.flip: Flip image in horozontal or/and vertical direction. Not very useful for V4L2 cameras since there is one in libv4l2. Vertical flip is very efficient and horizontal is pretty fast on RGB, BGR, … images with 24 bits per pixel. Horizontal flip is slow on Gray images (with 8 bpp).

  • emc.crosshair: Draw crosshair on image. Corrently supports simple crosshair and additional circle with adjustable radius. May be drawn in simple or in XOR mode (which gives good effect only for white).

  • filter.pip: Draw image in small area in left bottom corner (0.25 of main image size). Useful for debugging and tuning different conversion algorithms.

  • detect.hough: Perform Hough circles detection on image. Only 8 bit grayscale images are accepted as input. Rectangles are drawn around all detected circles and first one is added to frame metadata under names marker.x, marker.y, marker.z.

Additional plugins that may be useful but not packaged yet: