I have been working on the video for Linux v2 (V4L2) lately. From time to time I pause and search for something specific I am looking for. At this time I began tossing around the idea that if there was another Python library out there already utilizing V4L2, I could use that to begin playing with the algorithms I needed.
I found some interesting Python and webcam examples. The Python webcam fun is actually quite impressive, where using motion detection the author was able to fill in two red squares by passing his hand over the area (coordinates) that were occupied by the red squares. Did you take notice to the very little code he actually had to write to accomplish so much?
Then there is motion capture in Python, where in under 150 lines of code, this author ( Janto Dreijer) was able to track objects with red or a reddish tint on it.
So while I was working on my project at home, I began to take notice to the libraries available on Linux for video capture. One such library I found and was quite impressed with was libfg, by Gavin Baker. It is a C library with a Python wrapper. The library was written for V4L (version 1), so I began hacking away at the library to not remove but compliment the original code with new code that would allow the library to support V4L2 (video for Linux version 2).
The great news is I have it working, and am going back through to clean up areas and nitpick at the placement of code (reduce any redundancy) and ensure it is just as readable as it was when I found it. Gavin takes great pride in the presentation of his source code, you can tell he spent the extra time.
I’m not sure how this will end up yet, on one hand I can see a library that incorporates both versions together, or two libraries and old and a new.