Python Video

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.


6 responses to “Python Video

  1. I use the libfg library in lti-civil and FMJ for capture device support. I get a lot of requests for V4L2 support, if you could post your code, that would be great!

  2. I would love to resurrect this library, but for right now and for the next month, I am heads down on a project.

    BTW…I’d like to get access to and host the code here:

    Attempts to contact Michael Dove a few months back failed.

  3. Looking for it!
    Would it be possible to get a “pre-release” of the code? There is still nothing on google code 😦

  4. Cedric — thank you for your interest.

    The fact is that the Linux kernel has changed, and it has been over a year since I last compiled or tested the code. In fact, the actual machine I used to write and test the code does not have a capture card installed.

    I would want to get the machine set back up, at least compile and test the code still works with the latest kernel and then publish it. I have this in mind this year, no promises, but I will see what I can do.

  5. Hello Mark,

    i’d also love to see your code. Would be so helpful to use python with v4l2 devices!


  6. You can post your code even not working, we will fix it for you.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s