Python & PIL: Difference between revisions

From Research
Jump to navigation Jump to search
Bbogart (talk | contribs)
No edit summary
 
Bbogart (talk | contribs)
No edit summary
Line 9: Line 9:
# Writes the mean value of the pixels in the image to a logfile.
# Writes the mean value of the pixels in the image to a logfile.


I solved two problems in python:
I wrote two python programs for:


* Controlling ffmpeg to batch process the ripped VOB fiels into jpgs [[Media:Example.ogg] source]
* Controlling ffmpeg to batch process the ripped VOB fiels into jpgs [[Media:Example.ogg]]


* Image Processing [[Media:Example.ogg] source]
* Image Processing [[Media:Example.ogg]]

Revision as of 21:19, 6 December 2006

I had planned to do the computer vision aspect of this project with python-opencv (The python hooks into the Open Computer Vision library). I ended up abadoning this method because OpenCV does not have any simple tracking (center of gravity of moved pixels in the frame) only complex tracking. I looked at CAMShift and MHI algorithms. The CAMShift tracking the colour mean of an image, MHI is a motion history image that calculates vectors of motion in the image based on a gradient from old to new frames. Both these methods (and opencv in general) work best with static cameras, so these methods get total lost when there is a scene cut.

In order to get data more quickly after a month of work on opencv I decided to look at the Python Imaging Library (PIL) which gives you a nice number of functions for working with image files. This is not a real-time image processing library, though it is quite fast considering. PIL has not computer vision facilities built in. I ended up doing a very simple process where the program:

  1. Opens an image file.
  2. Opens the previous file in the sequence.
  3. Removes the colour data from the images
  4. Subtracts the two frames to get the difference
  5. Writes the mean value of the pixels in the image to a logfile.

I wrote two python programs for: