[Etoys] [FUN]Track color with camera

karl karl.ramberg at comhem.se
Wed Feb 6 14:22:10 EST 2008


Bert Freudenberg wrote:
>
> On Feb 6, 2008, at 15:03 , Karl wrote:
>
>> Bert Freudenberg wrote:
>>> On Feb 4, 2008, at 21:31 , karl wrote:
>>>
>>>> I have used Wiebe Barons WebCamMorph and added some Etoy support to 
>>>> it. It is possible to track a color with the camera and a ellipse 
>>>> on the screen reflect the movement. I'll see if I can make it into 
>>>> a input feature like the eyeToy to the Playstation2. Enjoy
>>>
>>> Not bad :) Here's a project version of this:
>>>
>>> http://dev.laptop.org/~bert/camTrack.pr
>>>
>>> Works nicely on the XO (if you have good lighting and a distinctly 
>>> colored shape) ...
>>>
>>> - Bert -
>>>
>>>
>> Cool.
>> I tinkered a little more with this and added a setting for how many 
>> points should be scanned each scan. That fewer scanned points made 
>> morphic more responsive but jumpier movement of the ellipse. Next 
>> change will be to just return x and y values so any object can be 
>> hooked up to input.
>>
>> Future enhancement is:
>>    - several colors scanned for, that would enable more advanced 
>> input like one for mouse click simulation and one for movement.
>>    -putting scanning in a primitive would really speed up everything 
>> and make even more stuff possible, like gestures, sign language ? etc.
>
> You might try (ab-)using BitBlt for this - for example, convert to 16 
> bit, then use a 32k entry tolerant color map to convert to b/w, then 
> use #innerPixelRectFor:orNot: or #rectangleEnclosingPixelsNotOfColor: 
> to find the rectangle enclosing the object ... Or with WarpBlt and 
> smoothing you can reduce the image size while retaining colors ...
>
> - Bert -
>
>
I found a promising looking method:
Form>>cgForPixelValue: pv orNot: not
    "Return the center of gravity for all pixels of value pv.
    Note:  If orNot is true, then produce the center of gravity for all 
pixels
    that are DIFFERENT from the supplied (background) value"

The method has no senders but there is a example. I have to experiment. 
It's fun to browse around the image and look for stuff :-)

Karl



More information about the etoys-dev mailing list