Asked — Edited
Resolved Resolved by Dunning-Kruger!

How To Detect Face And Motion Using The If-Else Statement In The Ez-Script Edito

Earlier, I have asked about the coding of detecting the colours using the EZ-Script. bhouston gave a very good code and I made a coding of my own similar to what bhouston gave. The coding was working but camera gave flop results for eg. I show Blue, it detects as Green.

So, I tried to do the If Else statement for Face and Motion but I cant find their default variables. Can anybody here help me out?


Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

United Kingdom

Have you tried adjusting the brightness and contrast settings in the camera control until it recognises the correct colour? Also is the room you are in when you try this bright enough for the camera to detect correctly?

United Kingdom

The camera will detect the colour it sees.

Which default values are you looking for? Try adding the variable watcher, this will give realtime feedback on all variables, including default values (when the project is first loaded).


@NYP.Shank_95 The variables for face tracking are in the same place as for colour track.... All that stuff is in the camera control under the variables tab....


Steve G, I have done that also. Its still the same result. However, when I used the same colour in Color & MultiColor trackingmodes, I have found that Color tracking mode gives much,much better result than the MultiColor.

United Kingdom

Multicolour should give more accurate tracking if you set it up with the actual object in front of the camera... it'll display what's detected on the screen. You wont get more accurate than that (and the control for multicolour gives more options too).

United Kingdom


I have just seen your other thread about multi colour detection. When I initially set my camera up I had a couple of issues similar to yours at first. After playing around with the various settings, brightness, contrast ect, I ended up deleting the camera control from my project and selected a new camera control. I then did what Rich mentioned above by placing an object in front of the camera and adjusted the settings needed. After this everything worked fine and detection was pretty good.

In regards to your question regarding face and motion variables, I'm not quite sure what you are looking for, as Richard mentioned in post #4 all the variables needed are in the variables tab in the scripts menu. If it helps, I have supplied a script I use for motion tracking. Maybe what you are looking for is in there. :)

#Script for motion detection

$direction = 1
ControlCommand("Camera", CameraMotionTrackingDisable)

IF ($direction = 1)
ServoUp(D19, 4)
  ServoDown(D19, 4)
IF (GetServo(d19) > 100)
$direction = 0
ELSEIF (GetServo(d19) < 30)
$direction = 1

ControlCommand("Camera", CameraMotionTrackingEnable)
$count = 0
IF ($count = 10)

IF ($CameraIsTracking = 1)
SayEZB("Motion detected.")
$count = $count + 1


Hi Steve G, thank you for the immediate reply. I have done the face recognition if else statement by myself. I ll use the motion detect if else statement on my project and let you know ASAP if it works.

United Kingdom

No worries. Just remember to change the values needed such as servo ect, as the script above is set up for my bots head to turn left and right looking for motion.


Steve G, your D19 refers to which part of servo?

United Kingdom

D19 is the EZ-B port I have my servo connected to, that does the camera tracking movement (Sweeps from left to right until motion is detected).


I mean is it the head or hands or legs? & which robot r u using in this?

United Kingdom

Sorry I misunderstood you. It's for the neck/head (repeatedly looking left to right) on a custom made robot, but that shouldn't matter. Same princable applies. I see in your other thread that you have finished your smart camera project. So I take it you got everything working on ARC the way you wanted to in the end?