Python & PIL: Difference between revisions
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
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 | I wrote two python programs for: | ||
* Controlling ffmpeg to batch process the ripped VOB fiels into jpgs [ | * Controlling ffmpeg to batch process the ripped VOB fiels into jpgs [http://www.sfu.ca/~bbogart/csi/vob2frame.py src] | ||
* Image Processing [ | * Image Processing [http://www.sfu.ca/~bbogart/csi/processFrames-PIL.py src] |
Latest revision as of 21:22, 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:
- Opens an image file.
- Opens the previous file in the sequence.
- Removes the colour data from the images
- Subtracts the two frames to get the difference
- Writes the mean value of the pixels in the image to a logfile.
I wrote two python programs for:
- Controlling ffmpeg to batch process the ripped VOB fiels into jpgs src
- Image Processing src