lundi 7 avril 2014

Flash - Actionscript 3 webcam couleur suivi - Stack Overflow


I need to track color using Adobe Flash, actionscript 3. I want to control mouse pointer using for example red color which is seen by laptop webcam. What is the best way to do this? Does flash have special functions to determine if the specified pixel color is in some range, for example (~red). I've heard about getColorBoundsRect() but I don't understand how to use it and if it's appropriate for what I need.


I will have multiple color markers - green and red, maybe blue too.


How is it possible to do so?




I believe the best way to solve your problem is taking picture from webcam and making bitmapData object out of it. Then define an uint of the color you are looking for and check the color difference for every pixel. You can get pixel color from bitmap data by calling getPixel(x,y). Compare each channel separatly like this


var red:uint = ((c >> 16) & 0xFF);
var green:uint = ((c >> 8) & 0xFF);
var blue:uint = (c & 0xFF);

then calculate the sum of difference and define some threshold when you accept that colors match.




It's generally a good idea to convert to the HSB colour space and threshold based on the hue, with a configurable tolerance.


Have a look at Jean-Philippe's ChromaTracker library


Also, you might find Didier's RGB Wheel Tracker interesting.



I need to track color using Adobe Flash, actionscript 3. I want to control mouse pointer using for example red color which is seen by laptop webcam. What is the best way to do this? Does flash have special functions to determine if the specified pixel color is in some range, for example (~red). I've heard about getColorBoundsRect() but I don't understand how to use it and if it's appropriate for what I need.


I will have multiple color markers - green and red, maybe blue too.


How is it possible to do so?



I believe the best way to solve your problem is taking picture from webcam and making bitmapData object out of it. Then define an uint of the color you are looking for and check the color difference for every pixel. You can get pixel color from bitmap data by calling getPixel(x,y). Compare each channel separatly like this


var red:uint = ((c >> 16) & 0xFF);
var green:uint = ((c >> 8) & 0xFF);
var blue:uint = (c & 0xFF);

then calculate the sum of difference and define some threshold when you accept that colors match.



It's generally a good idea to convert to the HSB colour space and threshold based on the hue, with a configurable tolerance.


Have a look at Jean-Philippe's ChromaTracker library


Also, you might find Didier's RGB Wheel Tracker interesting.


0 commentaires:

Enregistrer un commentaire