What's the fastest way to see if some screen region has x percentage pixels of a given color?
in
Programming Questions
•
10 months ago
I've been using blob detection with the XBox Kinect to trigger events. It's kind of slow for my purposes (using Processing to send MIDI or OSC). I'm thinking I should invert the problem: instead of finding every blob and seeing where they are, instead check if certain regions of the screen are this or that color.
What's the fastest way to see if some bounded screen region has x percentage pixels of a given color (e.g., 20% are not black)?
What's the fastest way to see if some bounded screen region has x percentage pixels of a given color (e.g., 20% are not black)?
I start with the assumption that the entire screen is colored black. I want to check the pixels bounded by, say (0,0) and (100, 100) on a 900x900 screen.
My first thought is, at setup, sum the values of pixel colors in the defined rectangle, store that, and in the draw loop recalculate that value and see by how much it differs. But I also wonder if there's a way to do an OR or XOR of some screen region and note the results.
Thank you,
James
1