I ran across a neat project online that uses a web camera as a button for application. The functionality is nothing too wild as the code takes the camera values and if the image detection meets a threshold of darkness (like you block the camera with your hand) that registers as a button press and you make the app do what you want from there, like open or close a window or play music or whatever.
I thought, why can't ARC do this? I created a custom multicolor named "Dark" and set it the darkest shade of blue with a narrow scope. The result is most of the time it will only detect my multicolor "Dark" if the camera is blocked with my hand. Sometimes it see that color flash by looking around the room.
Has anyone else done this? Is there a better way to achieve this in EZ-Builder?
Below is my script to trigger a sound file from a sound board when the custom multicolor is detected incase anyone would like to see it as an example.
$CameraObjectColor = ""
IF ($CameraObjectColor = "Dark")
ControlCommand("Bender Sounds and Noises", Track_22)
$CameraObjectColor = ""
Upgrade to ARC Pro
ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!
Also, and bear in mind I'm only quickly looking here, but your code will reset the $CameraObjectColor variable on each loop and wait 5 seconds for the loop. Which may mean the hand would need to be over the camera for up to 5 seconds for it to work.
There is a script command called WaitForChange($variable) which would work better. It will hold the script at that line until the variable value is changed. Since the variable may provide a value which may not be "dark" you may want to add in another variable which sets to 1 if the $CameraObjectColor is "dark" and 0 if it isn't. Then use that variable in the WaitForChange. It would mean having another script looping too which would constantly (or with a slight sleep) monitoring the variable and setting the 0 or 1 as appropriately.
And the main script just throw a WaitForChange($SwitchVariable) in there to hold it before the IF.
Another camera question I have is, what is the proper variable that changes when a face is detected when using face tracking? I know $CameraTrackingType will change to "Face" if a face is detected. And if a face is being tracked the $CameraIsTracking will change from 0 to 1 (or maybe higher for more faces?) but that change seems to happen rather slow, like not as fast as when the colored box appears in the camera preview window. Are those the only two system variables that change when a face is detected?
The drop down you mentioned is from the Motion tab, correct?
I don't believe it would be the tracking option under scripts because I'm not kicking off a script.
Can you tell me where the "drop down for how many frames before object is considered tracked" is located?