Page 1 of 1

Color Tracker

Posted: Mon Aug 01, 2005 4:37 am
by marvin
I need help in detecting colors or color tracking.

What I am trying to do is detect a specific color and tracking its position on the screen. I am going to use the position value to draw lines.

An example of my application goes like this; I have a light(any color) and is captured on the screen via webcam. The program detects this specified light and plots its coordinates and/or return its values. This position value will then be used as coordinates to draw lines or even used as position values for animated sprites.

What I am trying to do is create a virtual chalkboard.

Can anyone help me with color tracking or color detection. I think I can manage the rest.

Thanks

Posted: Mon Aug 01, 2005 7:24 am
by Fou-Lu
You could use point(x,y) on the whole screen... but it would be really slow.
If you grab the screen as a sprite and use peek at each pixel it would be a bit faster. Supposing you'd use point, you could do that:

Code: Select all

For sx=0 to screensizex
For sy=0 to screensizey
color=point(sx,sy)
if Red(color)>128  ;supposing you are using a red light
xposition=sx : yposition=sy : break 2
endif
next sy
next sx
But since this light will probably be greater than 1px in size you could add a "step" on the for sx and for sy to get some speed:

Code: Select all

For sx=0 to screensizex step 4 ; try other values
For sy=0 to screensizey step 4
color=point(sx,sy)
if Red(color)>128
xposition=sx : yposition=sy : break 2
endif
next sy
next sx