What is a recommendable alternative for a program that captures images from a V4L2 UVC webcam that serves JPEG images (here: Creative Live!Cam Optia)?

April 14th, 2008 by matthias

Working alternative

The only working alternative is, for now, to use gstreamer (to show the stream) and a screenshot tool. You cannot use all video sinks, as some are not accessible to the screenshot tools.

Here, the following did show up a green area when the screen was captured:

  • autovideosink
  • dfbvideosink
  • glimagesink
  • xvimagesink

And the following did not work at all:

  • sdlvideosink
  • gconfvideosink

What can be captured by screenshot tools is “ximagesink”, as can be shown thus:

gst-launch videotestsrc ! queue ! ximagesink
# and in another terminal create a screenshot by saying "scrot"

This also works (the “ffmpegcolorspace” is important!):

gst-launch v4l2src ! jpegdec ! ffmpegcolorspace ! ximagesink
# and in another terminal create a screenshot by saying "scrot"

You may now write a script that gets a screenshot and uploads it to a server.

Many very good snippets for all these are here: http://wiki.laptop.org/go/GStreamer

There are many ways how to get a screenshot of a linux screen: http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux

Perhaps working alternatives

fswebcam

It is possible to use fswebcam (http://www.firestorm.cx/fswebcam).

Take screenshots with gstreamer

You may use gstreamer to take the screenshots. A webcam that serves JPEG images just serves JPEG images one after the other. The following worked to view the first captured image from a file that contains JPEG after JPEG:

gst-launch v4l2src ! filesink location=file.jpg
kuickshow file.jpg

This is even a very promising path, as you can combine some JPGs to reduce the noise.

Use gstreamer to pipe to vlc

You may use gstreamer with a filesink and then pipe that to vlc. The following created basic screen output here:

gst-launch v4l2src ! jpegdec ! autovideosink

The following recorded and played an avi video:

gst-launch v4l2src ! avimux ! filesink location=video.avi
xine video.avi

(Perhaps you need instead something like this or similar, but VLC cannot play this, saying: “avi demuxer error: avi module discarded (invalid file)”:)

gst-launch v4l2src device=/dev/video0 ! avimux ! filesink location=video.avi

The following recorded and played an avi video, using forwarding to stdout:

gst-launch v4l2src ! avimux ! fdsink | cat > video.avi
xine video.avi

(This however makes xine not recognize the format.)

And now, piping to vlc media player is possible by:

gst-launch v4l2src ! avimux ! fdsink | vlc -

(But this is not possible yet.) (You may need the “ffmpegcolorspace” element, it’s important.) (See here for the documentation: http://wiki.videolan.org/Uncommon_uses.)

Something comparable should be possible with xine:

gst-launch v4l2src ! avimux ! fdsink | xine stdin://

(However, xine does not recognize the file format and there’s yet a way to find
how to tell it explicitly about that. See here for that:
http://dvd.sourceforge.net/xine-howto/en_GB/html/howto.html#toc10.17 )

Non-working alternatives

ffmpeg to capture and convert

It is also possible to use ffmpeg to capture and transcode the stream from a V4L2 device. The command would be something like:

ffmpeg -v 100 -f video4linux2 -s 320x240 -i /dev/video0 -f audio_device -i /dev/dsp2 -f m4v test.m4v

This however leads to an error:

[video4linux2 @ 0xb7f64610]Cannot find a proper format.

Which might mean that the camera uses a compressed format. See this mailinglist contribution.

See for that and a discussion of alternatives: http://lists.berlios.de/pipermail/linux-uvc-devel/2007-September/002164.html

You may then pipe the ouput to vlc.

transcode to capture and convert

It is possible to use transcode and and pipe it’s output to VLC (as seen here:
http://wiki.videolan.org/Uncommon_uses ) and stream it from there.

On the transcode side something like:

transcode -x v4l2,null -g 640x480 -i /dev/video0 -w 4000 -y ffmpeg -F mjpeg -o test.avi

This leads however to this error:

[import_v4l2.so]: no usable pixel format supported by card

As also documented here: http://lists.berlios.de/pipermail/linux-uvc-devel/2007-September/002164.html

gstreamer

gstreamer is no alternative as it was impossible to create a network stream from it.

uvc-streamer

It is possible to use UVC-Streamer ( naaa.de/uvc_streamer.htm ), which works for V4L2 devices; however there were compilation errors.

mjpeg-streamer

It is possible to use MJPEG-Streamer, which is the successor to UVC-Streamer; however, compile errors happened in both the 35 and 51 revisions.

uvccapture

It is possible to use uvccapture; however, this is rather a hack and has errors when compiling.

MPEG4IP

MPEG4IP might be a possibility, but their tarball is corrupt and their development stopped.

ucview

You may try ucview (an application based on the unicap framework). There are .debs available; however, I wasn’t able to get an image (though it supports MJPEG); it would be the most comfortable software for capturing selected frames.

luvcview

You may try luvcview.

Posted in Graphikbearbeitung, Sprache: Englisch, Videobearbeitung | No Comments »

Wie ist besserer Foto-Ausdruck mit ghostscript möglich?

April 7th, 2008 by matthias

Zur Erzielung eines besseren FotoAusdrucks mit ghostscript: Statt der normalen 74lpi-Rasterung kann mit ghostscript auch ErrorDiffusionRaster in 300dpi gedruckt werden, wenn dieses Raster selbst in einer s/w-Datei vorliegt (also keine Graustufen!) und diese mit 300dpi lineart über ghostscript ausgedruckt wird. Dazu muss ein entsprechendes Programm zur Konvertierung von Bildern vorhanden sein.

Posted in Graphikbearbeitung, Linux | No Comments »

Wie kann ich Moire-Muster aus gescannten Bildern entfernen?

April 7th, 2008 by matthias

Manchmal gibt es in solchen Bildern Strukturen, die nur bei Maßstäben kleiner 1:n, n>1 als Moire-Muster sichtbar werden. Dieser Effekt kann mit dem »Gaußschen Weichzeichner (RLE)« in GIMP behoben werden, angewandt für Felder mit einer Seitenlänge die der »Periodendauer« des Rasters des Bildes entspricht. Alternativ kann man den »Gaußschen Weichzeichner (RLE)« für Felder von 2×2 (oder 1×1?) Pixeln so oft anwenden bis gerade alle Moire-Muster in allen Zoom-Maßstäben verschwunden sind (auch komfortabel möglich indem man den Effekt mehrfach anwendet und Anwendungen wieder rückgängig macht). Dieses zweite Verfahren ist besser für die Bildschärfe, jedoch nicht wie das erste Verfahren dazu geeignet ein Druckraster nahezu restlos zu entfernen.

Posted in Graphikbearbeitung | No Comments »

Welches Dateiformat verwendet man am besten für schwarzweiße Bilder, die mit 300dpi gescannt wurden?

April 7th, 2008 by matthias

Man konvertiere in GIMP mit »Bild | Modus | Indiziert …« in ein schwarzweißes Bild und sichere dann als PNG-Datei mit maximaler Kompression. Ohne die vorherige Beschränkung der Farbtiefe dauert das Speichern wesentlich länger und eine Testdatei wurde 137kB statt 74kB groß. Derart gespeicherte PNG-Grafiken sind sogar kleiner als entsprechende GIF-Grafiken (Beispiel: 54kB statt 90kB). TIFF und GIF sollte man wegen patentrechtlicher Problemen ohnehin vermeiden.
Die hier beschriebene Art von PNG-Bildern wird durch xsane erstellt, wenn man »Strichzeichnung« und »Typ PNG« einstellt. Einziges Problem: xsane speichert als Graustufenbilder ab, die Kompression entspricht jedoch der von Schwarzweißbildern, d.h. ist maximal.

Posted in Graphikbearbeitung | No Comments »

Wie kann ich die Dateigröße von PNG-Bildern reduzieren?

April 7th, 2008 by matthias

Man verwende bei Bildern mit wenigen Farben (technische Zeichnungen usw., auch mit Antialisasing) stets eine indizierte Farbpalette. In GIMP: »Bild | Modus | erstelle optimale Palette«. Bei Antialiasing keine Farbrasterung verwenden lassen! So sinkt die Dateigröße auf etwa 35-40%.

Posted in Graphikbearbeitung | No Comments »

Wie exportiere ich am besten Pixelgrafiken aus xfig?

April 7th, 2008 by matthias

Für einfache Zwecke genügt ein Export als GIF mit der Option »Smooth« (einfaches Antialisaing). Das GIF-Bild kann dann mit GIMP in ein beliebiges anderes Format umgewandelt werden. Wenn gutes Antialisaing gefordert ist, so gibt es zwei Möglichkeiten:

  • als EPS exportieren, dieses mit epstopdf in eine PDF-Datei umwandeln (denn der direkte Export als PDF führt zu Ausschnitten von viel zu großen Grafiken), in Acrobat auf die richtige Größe zoomen, davon mit GIMP einen scrrenshot machen und daraus den gewünschten Ausschnitt im gewünschten Format abspeichern. Hier ist das Antialiasing bei manchen Elementen besser (Postcsript-Füllmuster, Schrift), jedoch findet bei manchen Postscript-Elementen (Kreisbögen, Linien, Pfeilspitzen) überhaupt kein Antialisaing statt.
  • noch bessere Resultate erhält man, wenn man als eps exportiert, dieses in kghostview öffnet (denn es kommt mit den PDF-Dateien, die aber Acrobat lesen kann, nicht zurecht) und davon einen screenshot macht und bearbeitet. Hier werden alle Elemente mit Antialiasing dargestellt.

Posted in Graphikbearbeitung | No Comments »

Wie kann ich wirklich vektororientierte gif-Dateien erstellen?

April 7th, 2008 by matthias

Es gibt keine vektororientierten GIF-Dateien, denn GIF ist ein pixelbasiertes Format, das mit verlustfreier LZW-Kompression arbeitet. Besonders Bilder aus wenigen Farben und Farbflächen können so trotz hoher Auflösung sehr klein sein, was den Eindruck erweckt, es handle sich hier um vektororientierte Bilder. GIFs eignen sich aufgrund der indizierten Palette besonders für Bilder und Zeichnungen aus wenigen Farbflächen - JPGs eignen sich dafür weniger, denn die Farbflächen werden bei Verringerung der Qualität uneinheitlich und Details veschwinden. Die Verwendung von Antialiasing (beim GIF-Export in xfig: smooth einschalten) macht GIF-Dateien nur um ca. 5% größer.

Posted in Graphikbearbeitung | No Comments »

How to create resized versions of the images in a whole directory?

April 6th, 2008 by matthias

for file in *.jpg; do \
  convert -size 1024x768 -scale 1024x768  -quality 75 $file ${file/.jpg/.web.jpg};
  mv ${file/.jpg/.web.jpg} $file;
done;

Posted in Graphikbearbeitung, ImageMagick, Sprache: Englisch, alle Artikel | No Comments »