Mirage
 
Mirage
jpeg-c++
Source Segmentation
FFT tools
Cepstral analysis
MLS and FHT
On-line Pen-Input recognition
 
 
Items
The mirage library
Demo
Mirage and GStreamer (tutorial)
 
  
> MALIS Home > Software > Our softs > Signal processing > Mirage > Mirage and GStreamer (tutorial)

MAchine Learning and Interactive Systems

Mirage and GStreamer (tutorial)
 
  by Frezza-Buet Herve, Gutzwiller Jean-Louis, J-Baptiste Tavernier
 
 

This short tutorial shows how you can use mirage in order to define your own gstreamer plugin.

Installation

Download somewhere the file psychedelic-sources.tar.gz. Then

tar zxvf psychedelic-sources.tar.gz
cd psychedelic-sources

For root users :

Now, check the LIB_DIR and PLUGINS_DIR variable at the beginning of the Makefile. The default value may be Ok for a standard install. Compile and install the plugin

make install

The psychedelic filter is now available for gstreamer.

For non root users :

Create a directory for the local installation. Let us name "/home/me/lib" this directory in the following.

mkdir /home/me/lib
mkdir /home/me/lib/gstreamer-0.10

We have to set environment variables :

export LD_LIBRARY_PATH=/home/me/lib
export GST_PLUGIN_PATH=/home/me/lib/gstreamer-0.10

Now, edit the makefile and modify the

LIB_DIR=/home/me/lib

and compile

make install

The psychedelic filter is now available for gstreamer. You can put the LD_LIBRARY_PATH and GST_PLUGIN_PATH in your .bashrc and/or .profile for having those settings permanent.

Test

As a normal user, you can launch the filter, using your webcam as the source.

gst-launch v4l2src device=/dev/video0 ! video/x-raw-yuv,width=320,height=240,framerate=30/1 ! 
ffmpegcolorspace ! psychedelic w=30 h=30 width=120 height=80 bicubic=false ! ximagesink

In order to illustrate the communication between plugins by the use of events, the psychedelic package provides a psycontrol plugin. It communicate with the psychedelic plugin to change randomly its zooming area. Just add psycontrol in the pipeline. It cann be added before or after psychedelic, this do not matter.

gst-launch v4l2src device=/dev/video0 ! psycontrol ! video/x-raw-yuv,width=320,height=240,framerate=30/1 ! 
ffmpegcolorspace ! psychedelic w=30 h=30 width=120 height=80 bicubic=false ! ximagesink

How does-it work

The code is divided in three parts. The first part is psychedelicGStreamer.* files, that build the psychedelic plugin. You should read that first.

The second part concerns the standardization of psychedelic events. This is a library, since both psychedelic and psycontrol have to share those features.

The third part is another plugin, very straightforward, that just sends events to the psychedelic plugins available in the stream.

The psychedelic plugin is made from a code template given by gstreamer documentation. This corresponds to files psychedelicGStreamer.* in the tutorial. The function that deals with the filter processing itself is gst_psychedelic_chain.

In the psychedelicGStreamer.cc file, we define buffers for which we control the memory. The input buffer (sink) bytes are accessed and given to mirage (see psychedelic ::StaticStuff ::wrap_input). Once the output image is computed, the output buffer of gstreamer deals with our image buffer (see psychedelic ::StaticStuff ::output_realloc_needed()). This is how our buffers are wrapped, and the method can be reused for non mirage applications.

The psychedelicMirageWrapper.* files concern the interface between mirage and the gstreamer buffers.

Last, the psychedelicProcess.* files define the actual filter processing, that is a FFT in our example.