Asked
— Edited
Resolved by bhouston!
Hey guys.
A little help is needed with a script. I am helping a friend out setting up their v4 camera and doing some object recognition. What my friend want's is, if nothing is recognized after 10 seconds, a script or part of a script runs. Here's an example of what is needed...
waitforchange($CameraObjectName,10000)
sayezbwait("I have identified, " +$CameraObjectName)
stop()
# If nothing is detected, the following should run
# which will shine an LED on the subject.
Servo(D5, 120)
Set(D6, On)
waitforchange($CameraObjectName,10000)
sayezbwait("I have identified, " +$CameraObjectName)
stop()
# If nothing is detected again after a further 10 seconds,
# the following phrase will be spoken.
SayEZB("Sorry. I could not recognize the object.")
I don't have my laptop with me, and I cannot figure out for the life of me what else is needed.
As always, I'd be grateful for any help filling in the gaps.
Steve.
Here's a script that L. Vasquez posted awhile ago. It's a basic script that is easily changed for different types of object detection.
Thanks Bob. I'll have a play around and give it a try.
Thanks again Bob(and to Luis for sharing the script).
I had a quick play with the script Luis originally posted, and have the following script working well...
A I mentioned, it works well but I would like to add a "wait for change" command in somewhere so as soon as the object is recognized, it will say what the object is. At the moment, you have to wait for the 5 second time out to be reached, so if an object is detected at the 3 second mark, and then the recognition is lost at the 4 or 5 second mark, the "object cannot be detected" phrase is spoken (I hope that makes sense). I had a play around adding a wait for change command, but no joy. If I can get this bit sorted, then I'll add what is needed to be done such as "Goto's" for the script posted in post #1 for my friends project.
Anybody have any ideas how to achieve this?
I wrote a script for my friend (I may actually use this in K-9 and E4-B4 as well), and thought I'd share it here too for anyone who is interested.
I would still like to find a way to add a third instance where if the second part of the script is not met after 10 seconds, a phrase is spoken to say that the object needs to be trained or something. I tried using elements from the script in post #2, but so far my efforts have failed.
One question for DJ if you're reading. Would it be possible to implement the option to delete individually trained objects from the camera control at some point, rather than deleting everything and retraining the one's we want to keep. Thanks.
Just butting in here.
Before I can be of assistance, I would need to ask a few questions since I've not worked with the object recognition thing yet.
Should that be: if($CameraIsTracking =True)
Or does it work OK the way it is? Usually there always has to be a =True or =False in there.
It looks like it will say whatever is in $CameraObjectName regardless if the object was recognized or not. Is that what is wanted?
Finally, I believe the data for the learned objects should be in the EZB file along with everything else. Which means it should be possible to find it by searching through the EZB file. I already have a program to do this for the data associated with the Speech Recognition control. The program finds the control and copies the data stored in the control and presents it for modification. It then can replace the existing data there with the modified data. By "Data" I mean the scripts stored in it for what to do when a given phrase is spoken. It was part of my methodology to totally remove the data from the Speech Recognition control and place it in separate scripts for processing instead.
Anyway, it should be possible to modify it to do the same thing for the learned objects. This would allow one, or more to be deleted from that data and then the whole thing replaced, effectively deleting just the one (or more) objects from the group.
Additionally, the program, as it stands now, can save the data to a file. I had thought to use that so as to be able to load different sets of data to a given project. For example, the same things, but in a different language. Then I discovered the "Merge" function in ARC so that wasn't so important to pursue any longer. Still, that could also be done for the learned objects data.
Hi WBS, and thanks for the response. I'll go through the questions one by one...
It does work okay this way, but the object has to be recognised immediately when the end of the 2 second sleep is reached or it won't return the objects name. I believe you can also use a "True/False" or "0/1" with this command as well. I actually did give this a try but couldn't getting it working the way I wanted to correctly.
Not so. When the first part of the script runs and nothing is detected, the "I'll try again" phrase is spoken. Then the second part of the script runs. If the object is recognised within the 10 seconds, then the name of that object will be spoken. If after the 10 second timeout nothing is recognised, nothing is said.
Yes. The 10 second WaitForChangetimeout for the second half of the script is correct.
As for he deleting of the saved images, when you click on an image, you get a message confirming you wish to proceed. When excepting, another window pops up saying that this option has not been implemented yet and you have to use the clear everything option. I remember this was mentioned a few months ago by someone and DJ said put it in a future update. I was just wondering about an ETA. But thanks for the advice though. I'll have a look at the ARC file and see if I can delete individual images.
Thanks again.
Could you not use that to test for the third instance you wanted?
Or maybe I don't quite understand what you meant.
FWIW, as a possible alternative:
If nothing is recognized after 10 seconds, it will say the "I will need ..." text. If something is recognized, it will say the object name instead instead.
I looks like you got the gist of it. I'll have a go with the examples you've supplied and try again.
Thanks.