Enable real-time object vision training using scripts
How to add the Train Vision Object By Script robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the Camera category tab.
- Press the Train Vision Object By Script icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the Train Vision Object By Script robot skill.
How to use the Train Vision Object By Script robot skill
In order to train objects to the camera device, the Train Object menu is used in the camera device skill. This menu normally requires human intervention to enter the object name and use the mouse. This skill allows your robot to learn objects in real-time triggered by ControlCommand() scripts programmatically. Take a look at the Cheat Sheet within the Script skill settings to see what ControlCommand() this skill accepts.
Main Window
1. Beginning Learning Button This button will attach/detach the camera configured in the camera device skill to the program with pictures skill window.
2. Attach/Detach Camera Button This button will attach/detach the camera configured in the camera device skill to the Train Vision Object by Script skill window.
3. Train Status Bar This will show the object training process time remaining. During this time move the object around to train it at different angles.
4. Status Display This field will display the status and name of the learned object and any errors that occur.
How To Use the Train Vision Object by Script Skill
Add a camera device skill (Project -> Add Skill -> Camera -> Camera Device).
Connect to a camera.
Add this skill (Project -> Add skill -> Camera -> Train Vision Object by Script).
Press the ATTACH button. This will attach this skill to the camera device skill. You will now see a mirror of the camera's video stream in this skill.
Center the onscreen pink box on the object that will be trained. Have the object fill up the pink box completely. Press the BEGIN LEARNING button, then physically move the object around during the training process to get multiple angles.
Wait until the Train Status bar has completed and make note of the object name in the Status display so that you can use it in your scripts.
Script Sample
Here's an script sample that learns an object titled DJ FACE via ez-script:
# Check if the camera is active. If not, exit the script and notify user
if (!$IsCameraActive)
say("The camera is not active")
halt()
endif
# This is the name of the object that will be stored
$LearnedObject = "DJ FACE"
# Attach to the camera for the control
ControlCommand("Train Vision Object By Script", Attach)
# Introduce verbally out of the PC speaker what it is about to happen
SayWait("Prepare to learn " + $LearnedObject + ". 3, 2, 1, learning")
# Instruct the skill to begin learning
ControlCommand("Train Vision Object By Script", Learn, $LearnedObject)
# Wait until the skill has completed learning the object
WaitFor($CameraIsLearning == 0)
# Speak what the object has been learned
Say("I have learned " + $LearnedObject)
# Enable object tracking in the camera control
ControlCommand("Camera", CameraObjectTracking)
Hi EzAng, Thank you again for the help
But I am going to give up on this for now. I cannot get your code or even the code from DJs live hack to work properly. I Have looked over it and corrected any and all my syntax errors several times now but still getting the results I wanted. At least the old fashion way of doing it manually still works, somewhat.
One of the biggest hurtles I keep running into with this is that after the program ask me for the name of the object, the program just seems to stop (Bingspeech will just timeout) or if it does take my answer, then when is responds that it will learn name of new object, Bing responds with "learning a new object" as the name of the object instead. this has baffled me to no end, so I will take a break from this and tray again some other time.
@RobotHappy.
Try putting this code in Speech Recognition add a new phrase - " Learn a new object" next to that, under the Command line , click on it and add the java script below...
This is work on my robot...
EDIT: This is not complete...
merne
here is DJ's code from the train object by script video
Put this code in Speech Recognition add a new phrase - " Learn a new object" next to that, under the Command line , click on it and add the java script below
Audio.sayWait("what is the name of the new object you want me to learn"); setVar("$BingSpeech", "" ); ControlCommand("Bing Speech Recognition", "StartListening"); while (getVar("$BingSpeech") == "" ); sleep(250); if (getVar("$BingSpeech") == "cancel"){ Audio.sayWait("cancelling"); return; }
Audio.sayWait("Let me know when you are ready to teach me what the " + getVar("$BingSpeech") + "is." );
var resp = Audio.waitForSpeech(60, "ready", "cancel");
if (resp != "ready"){ Audio.sayWait("ok, I will not learn the "+ getVar("$BingSpeech"));
return; }
ControlCommand("Camera", "CameraObjectTrackingDisable");
ControlCommand("Train Vision Object By Script", "Learn", getVar("$BingSpeech"));
sleep(1000);
while (getVar("$CameraIsLearning"));
sleep(250);
Audio.SayWait("Great, I know what a " + getVar("$BingSpeech") + "is.");
ControlCommand("Camera", "CameraObjectTracking");
*Camera then in the Scripts&variables tab inside the camera config
add the java script below
Audio.sayWait("I see the "); Audio.say (getVar("$CameraObjectName"));
Sometimes you might have to stop Bing from recording
that's it, this works great here, In Camera, objects, add trained images then Camera recognizes them
Here you go: https://synthiam.com/Community/Apps/train-object-by-script-19553
Thank you DJ.
Is they a way to only delete selected objects without deleting all object created? Cheers
Thank you too @EzAng.
You are welcome, merne,
In Camera, Object, trained images, that would be a nice feature to be able to delete one image you don't want instead of all of them like it is now.