iOScoder
iOScoder

Reputation: 191

Fast algorithm required to detect changes in pixels

I am looking for an algorithm to detect changes in a pixel array. In the picture below, the red line illustrates the pixel array. I want the algorithm to recognize and trigger once the golf club below passes through the red line.

My original thought was to read the pixels along the line and to detect changes in color (specifically on the lower half of the line) when the color changes above a certain threshold.

Is there a better way to do this or an algorithm I can use which detects once the golf club passes the red line?

Thank you for your thoughts.

enter image description here

Upvotes: 3

Views: 1812

Answers (2)

MrSmith42
MrSmith42

Reputation: 10151

Tracking the pixels along the line is a feasible approach. I recommend not to check the pixels in the order top to bottom or bottom to top, I recommend a kind of interlacing order to increase the chance to detect a change with few pixel-checks.

Here is what I mean:

If the index the pixels from the to to the bottom by 0,1,2,3,..63 [just an example]

I would check e.g. this order 0,32 ,16,48 ,8,24,40,56, 4,12,20,28,36,44,52,60, ...

Or if you predict a non equal distributed probability for the change of the pixels, you can take even this in account and find an order of pixel checks with, detects the change with the lowest average pixel checks.

Upvotes: 2

MrSmith42
MrSmith42

Reputation: 10151

What kind of video-source do you use? Most video compressions already use differences between images to reduce the amount of data to store.

It might be a quite a bit of work, but you might be able to see the change directly in the compressed data without decoding it. Sounds like an interesting challenge to me to implement detection of change in a video, by simply reading the undecoded data.

Upvotes: 0

Related Questions