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
Color Tracker
- Fou-Lu
- Enthusiast
- Posts: 201
- Joined: Tue Jul 12, 2005 8:30 am
- Location: I'm pretty sure this is all a nightmare
- Contact:
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:
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:
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
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