2012-07-09

Creating Timelapse Videos with a Webcam

Last week I had some fun creating timelapse videos using just an inexpensive webcam and a laptop. Timelapse videos are a nice way to visualize processes which are otherwise to slow to observe directly (eg. the movement of clouds or the growth of plants). Technically the the solution to all the world's problems seem to be little Python scripts, which can be downloaded here. ;)
For simplicity a lot of things are hardcoded in these scripts, so you most certainly have to make changes. The scripts should be easy to understand, as they are quite short and simple. However if anything is unclear, just drop me a comment.

timelapse.py, timelapse_copy.py

timelapse.py uses ffmpeg for capturing images from the webcam (support for v4l assumed). You do not need this script, if you have any other means of acquiring the individual frames. The filenames of the acquired images contain a consecutive nr. and the time and date when the image was taken. Unfortunately it turned out later that times and dates in the filename confuse ffmpeg and have to stripped away to join the individual frames to a single video file. Besides the nr. needs to have leading zeros. The timelapse_copy.py script was made to compensate for that.


timelapse_filter.py

As mentioned before, an inexpensive webcam was used for simplicity. Therefore a Gimp plugin is used to sharpen and denoise the pictures a little. The script uses Gimp and the package gimp-plugin-registry (for the wavelet denoise). You can skip this step if you have a good camera or are not willing to wait, because the filtering can take quite some time, depending on which filtering operations you want to run on the individual frames. Do not forget to copy this script to ~/.gimp-2.6/plug-ins and to make it executable.

timelapse_ffmpeg.py

A third script creates a video from the filtered images again using ffmpeg.

2012-07-04

Überweisungsträger bedrucken (German)

Die Großmutter bedruckt nach Großmutters Art Überweisungsträger mit dem PC. Dabei nutzt sie (leider) folgende Vordrucke+Software: Avery Zweckform 2816
Die zugehörige Software hat die Qualität, die man von einem Etikettenhersteller erwarten kann (Vorlage für Microsoft Word mit Makro). Da der Firma offenbar schon bewusst ist, dass ihre Software teilweise nur "eingeschränkt" funktioniert, (kleiner Tipp: Die Schrift ist auf dem Formular verschoben, wenn man die Schriftgröße bei Windows auf 125% stellt.) gibt es noch eine Webapplikation. Diese unterstützt allerdings nicht das Formular 2816.

Hier ein kleines Python Skript, dass die gleiche Funktionalität für das 2816 Formular erfüllt. Ich hoffe, dass ich damit auch anderen weiter helfen kann, die sonst auf die Avery Software angewiesen wären.


Das Programm füllt eine HTML Vorlage aus und konvertiert diese mittels wkhtmltopdf (muss installiert sein, z.B unter Ubuntu mit sudo apt-get install wkhtmltopdf) in ein Pdf, dass man leicht ausdrucken kann. Für die Justierung kann man leicht in der Konfigurationsdatei die beiden Offset-Parameter umstellen und evt. auch die Ausrichtung für die einzelnen Textfelder verbessern bzw. das Programm für eine andere Vorlage umschreiben. Wer die Justierung ganz perfekt machen will, sollte mit der justierten Avery Software einen Überweisungsträger bedrucken und dann nochmal mit diesem Programm auf die gleiche Seite. Danach kann man mit dem Lineal die Abweichungen ausmessen und in der Konfigurationsdatei entsprechend korrigieren. Nach der Installation und Justierung sind aber zur reinen Benutzung der Software keine tiefergehenden technischen Kenntnisse erforderlich.

Das Programm wurde unter Ubuntu getestet. Falls notwendig, sollte eine Portierung auf andere Platformen aber nicht zu schwierig sein. Im Gegensatz zur Originalsoftware von Avery kommt man ohne den Kauf von Microsoft Office aus. Die kleine Tkinter-GUI zeigt nur die Elemente, die für die reine Nutzanwendung notwendig sind und sollen so weniger erfahrene Computernutzer nicht überfordern.

Das erzeugte Pdf wird jeweils unter ~/Dokumente/btof/ mit Datum im Dateinamen abgelegt. Dadurch werden die Überweisungen leicht nachvollziehbar archiviert, ohne dass sich der Nutzer über ein besonderes Ordnungsprinzip bzw. Dateien und Dateinamen überhaupt Gedanken machen muss.

Hier nochmal der Link zum Download

2012-05-20

Checking Opto-Fibers with a Smartphone

Todays discovery is simple, but nevertheless practical. Do you need the check optical fibers (e.g. from SFPs or AVAGOs) from time to time? It's sometimes hard to see if they are on, plus you probably do not want to direct a small laser right into your eye.
The solution is to use the camera of a smartphone, webcam, etc. This approach is especially useful, if the frequency is infrared or close to it, because the CMOS sensor is more sensitive in this frequency range.

2012-03-18

Using Latex to create a Bibliography with different categories

Have you ever tried to create a Latex bibliography with different categories, e.g. textbooks, internal documents, WWW? Fortunately the multibib package allows us to do so.



If your document class is book, scrbook or something similar, you will probably not going to be very delighted about the result. multibib does not much more than creating a new bibliography for each category. But in the document classes mentioned above, bibliographies are regarded as chapters, which have page breaks and an empty page after them.

To fix this, the definition of the bibliography command of your document class needs to be renewed to declare bibliographies as sections instead of chapters. If you happen to use scrbook, these style files might be helpful.

2011-12-18

A Scanner Darkly

I have always assumed that my scanner (an Epson Perfection V200) has construction flaws. An examples of this is, that it does not work with USB ports that are not directly connected to the motherboard.

Today I found out about another shortcoming. The waste heat of the scanner sled does not get transported away properly, which leads to permanent traces on the scanner glas. Fortunately the effect is not yet visible in everyday scans, but this situation might get worse.

To visualize the effect, scans were taken with open cover in a dark room. I combined the results from different scans in multiple layers (GIMP) with different opacities to diminish the influence of little dust particles. It would have been ideal to use this, which I could not get to work unfortunately.

To highlight the structures in the picture, Gimp's
Retinex filter was used, which performs quite well on this task. The result can be seen in the picture below.



The scanner's sled moves to a rest position away from the edge of the scanner, if not used for a while. This is where the sled cools down and the traces emerge.

SEL: These traces are from the PCB, which is attached to the sled.

SPL: Below this dot lies a small cut-out in the sled. It transports heat from the power lines of the lamp to the glas.

SLI: This horizontal stripes lies above the lamp, that illuminates what is to be scanned.

SSCR: Some scratches produced by the sled. Maybe there was something to heavy on the glas?

F: Probably finger prints that arose while cleaning the edges ;)

SCR: other scratches?

The picture below shows the same kind of image, this time produced with a Canon CanoScan LiDE 35. Even though this scanner not being the most recent model, the qualitative difference is clearly visible:



I wonder if it might be possible to augment this technique to identify which scanner model a document has been scanned with? Comments and suggestions are welcome as usually.

2011-10-04

lirc bug

Do you happen to have such a thing in your laptop?



It's an infrared remote control. In my case it's an RC811. If you also happen to have abadoned Windows from your machine, you might regard this solely as a place holder to prevent dust from entering the chassis of your computer, as it is a bit tricky to get it to function with lirc.

Today I finally stumbled upon the solution how to get it to work under Ubuntu, which consists of 3 steps. 2 are specific to the RC811 remote control, but one should be interesting to a wider circle of people.

0. Upon package installation "ITE8709 CIR port" is the appropriate type of remote control (at least for my laptop).

1. A remote control definition file is needed. In my case the correct one could be found here

2. The lirc version included in the repositories (v.0.8.7 at the time of this writing) has a bug. Referencing it in /etc/lirc/hardware.conf does not work. For example this means, that the following line would not have the desired effect:
REMOTE_LIRCD_CONF="/usr/share/lirc/remotes/generic/RC811"

Therefore the content of the definition file needs to be pasted in /etc/lirc/lircd.conf.

You can assume that this bug is present, if you have the following symptoms:
0. mode2 does work, but irw does not.

1. if the lirc daemon is started with the -n option, the following error message is displayed:
"config file contains no valid remote control definition"

If you want to control your mouse using the remote control, this /etc/lircrc might be helpful.

2011-08-23

Mnemosyne Print Flash Cards on Dead Wood

Do you know Mnemosyne? It's an excellent tool for learning flash cards. The only problem is that the computer is an evil distraction machine. So you might decide one day, that you want you print your flashcards to learn them the old school way, which means double sided printing questions and answers out on paper.

Unfortunately Mnemosyne does not have the ability to print flash cards with the question on the front and the answer on the back in double sided print. However flash cards can be exported to xml which can be converted to printable html with the following script. The Python script is a bit shaky and you might have to adapt it for your own needs, but it did the job for me.