White Detector Grid

White Detector Grid + troubles with LockBufferRepresentationWithPixelFormat

Lango's picture

Hey all

I have nearly finished a custom patch that I am happy to use in my project. However i've come across two stumbling blocks and am hoping for some guidance from the intelligent people here.

First what the patch does

Aim: Detects the intensity of white in different parts of an image

Why: A difference image shows motion in black and white. With this patch you will be able to have general areas of movement. Other patches that detect movement I have found to be too precise and finicky. This trys to simplify it.

How: The patch creates a grid of cells, each cell generates a 'weight' from the amount of white in the corresponding part of the image. This grid is outputted as an array. The amount of white, currently, is detememined by the intensity level that has the highest pixel count in the red channel.

Video of it in basic use:

Bugs:

  1. If the y origin is set to 25% and the height % is set to 100 the Quartz Composer crashes with a bad access error. However this doesn't happen if you do the same combination with the x origin and width. The last time I did memory management was about 3 years ago at uni, so i'm probably doing something really stupid here.

In the attached QC file set Y Origin (%) to 25 and Height of Grid(%) to 100 to reporduce this bug.

  1. The next one is a method call that causes lag. It is the lockBufferRepresentationWithPixelFormat call. This takes double the amount of time as the same call in the HistogramOperation tutorial. I have tracked this down to the fact in my call, within lockBufferRepresentationWithPixelFormat, a call to createPixelBufferFromImageBuffer is made. This call is never made in the histogramOperation tutorial. And I don't know why. (That was very complicated, looking at the attached profiles.png will better illustrate what I mean).

Any help would be so very much awesome

Cheers

Lango

** EDIT: attached the actual profile files as a zip. One that is the HistogramOperation tutorial and one is from my patch. **

** EDIT 2: Corrected the source attachment **