1

Are there more efficient ways (e.g. using functions already implemented at a faster/lower level) to do this other than the obvious way of creating a new image, going through each frame of the movie using a for loop, and with each iteration going through each pixel in the frame, updating the image at the corresponding pixel value if it is larger than current value.

I can indeed access individual pixels in a frame using cv.Get2D, so that's fine and dandy. I'm just wondering if I can take advantage of a faster or more hardware optimized way of doing this, as I will be doing this on many many gigabytes of greyscale video.

3
  • How are you getting your movie data into image frames? Are you already using OpenCV's functions for opening the movie file and getting images, or are you free to do something else? Commented Oct 20, 2012 at 22:02
  • I am already using OpenCV to open the movie file because it's the simplest way I know of to do this using Python. I am free to use something else if it is faster though. Commented Oct 21, 2012 at 0:02
  • What's your timeframe on this project? The reason I ask is I am working on the python wrapper for the OpenVideo library from AMD: github.com/kbrafford/pyopenvideo ...if you have time and want to help out, we could use your problem to help get this library in a usable state, and solve your problem at the same time. Commented Oct 21, 2012 at 1:21

2 Answers 2

2

There are many ways to do this, and the "best" way is going to depend on the hardware you have at your disposal.

If you are using a good AMD video card, you can use AMD's OpenVideo Decode library to deliver frames to your GPU and then use OpenCL to do your math. It will be wicked fast.

If you don't have an AMD graphics card, but you do have a nice NVidia card or an Intel HD4000 (new Ivy Bridge based Core i7 system), you can use OpenCV to read the frames, then pass that data to OpenCL and still do your math in massive parallel.

Even if you don't have a nice video card, you can still use an OpenCL CPU context to do the calculations, and if you use the int4 vector data type, your code will use the SSE2 registers of your Intel or AMD processor. This should be upwards of 4x the speed of a naive pixel iteration as mentioned in the question statement.

Sign up to request clarification or add additional context in comments.

Comments

1

Adding a answer since K. Brafford didn't directly answer the 'OpenCV or PIL' part of your question

From the bench-marking done here, it seems like OpenCV is the clear winner.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.