
NYP.Shank_95
India
Asked
— Edited

I want to make my robot do a function in such a way that for example, when it detects a red colour object, the robot responses as "I see a red colour object" and it does the same thing for blue or green object.
I've been working on this a little more and I have found that trying to use "Multi Color Tracking" it gets a lot of false positives due to other objects in the room. It's difficult to fine tune the colors. I do have it working using "Color Tracking" looking for red, green or blue.
You should make the script check for red, pause if no red found. then check for blue if none found check for green.
this could all be in the same script so it will look as if the robot is looking for all three and will give you the same results.
@ Luis, that's what I did in another script. In fact I used a basic script you posted a while ago and expanded it.
The multi color was designed for exactly what you're looking to do
Define each multi color. Then edit the "tracking start" script. Add an IF condition for each color that you are looking to detect. There is a variable that holds the current multi color detected
. It was quoted earlier in this thread.
bhouston, Luis Vazquez & DJ Sures, I have made my own If-Else code using the idea from bhouston and Luis. The syntax was correct but the camera gave me flop results for eg. I show Blue object, it either says it doesn't detect or it says it detects red or green. I have changed the contrast and saturation. Still the same. What should I do?
This is my coding:
@NYP.Shank_95
Using Color Detection often gives unstable results depending of the light condition or object in the same nuance. Example in my environment if I want to detect red, the camera will see my skin, my cabinet and other objects. I am not telling it wont work, but you will need to select an object with a bright color and adjust "Min Object Size" and "Object Brightness"until you have stable result.
Personally I prefer using the Multi-Color tracking function. It gives you more set-up to play with.
as you can see, in multi color tracking mode the camera will detect strictly these colors.
you may also try this short script to experiment with it:
ControlCommand("Camera", CameraStart)
$CameraObjectColor = ("Unknown") # define variable
ControlCommand("Camera", CameraMultiColorTrackingEnable) # activate multi-color-tracking :loop $CameraObjectColor = ("Unknown") # clear variable at begining of the loop SayWait("let me look")
IF ($CameraObjectColor = "Unknown") # if no detection of color define SayWait(" No I do not see these color") ENDIF
IF ($CameraObjectColor != "Unknown") # when variable is different than "Unknown"
SayWait(" Yes, yes I see" + $CameraObjectColor) SayWait("the object is in" +$CameraVerticalQuadrant +"and" + $CameraHorizontalQuadrant) # tell localisation of color ENDIF
goto (loop)
Here is the STL file
Multi-ColorTest.EZB
Thank you bhouston