Sign Detection with Quadruped

Example Description
Learn how to set the bounding box threshold, and detect signals such as 'Go', 'TurnRight', 'TurnLeft', and 'Stop' to control quadruped movements.

Introduction

Sign detection is being performed using a camera and a RecognitionCards object. The RecognitionCards object is set up with a threshold value and is enabled to draw a box around the detected object. The robot uses sensors, cameras, and machine learning algorithms to detect and understand the sign, and then performs a corresponding action based on the signal detected.

These robots are often used in manufacturing, healthcare, and customer service industries to assist with tasks that require human-like interaction and decision-making.

Code

sprite = Sprite('Tobi')
quarky = Quarky()

import time
quad=Quadruped(4,1,8,5,3,2,7,6)

recocards = RecognitionCards()
recocards.video("on flipped")
recocards.enablebox()
recocards.setthreshold(0.6)
quad.home()
while True:
  recocards.analysecamera()
  sign = recocards.classname()
  sprite.say(sign + ' detected')
  
  if recocards.count() > 0:
    if 'Go' in sign:
      quarky.drawpattern("jjjijjjjjiiijjjiiiiijjjjijjjjjjijjj")
      quad.move("forward",1000,1)
      
      
    if 'Turn Left' in sign:
      quarky.drawpattern("jjjddjjjjjdddjdddddddjjjdddjjjjddjj")
      quad.move("lateral right",1000,1)
      
      
    if 'Turn Right' in sign:
      quarky.drawpattern("jjggjjjjgggjjjgggggggjgggjjjjjggjjj")
      quad.move("lateral left",1000,1)
      
      
    if 'U Turn' in sign:
      quarky.drawpattern("jjjbjjjjjjbjjjjbbbbbjjjbbbjjjjjbjjj")
      quad.move("backward",1000,1)
      
      
    else:
      quad.home()

Logic

  1. This code is using several objects to detect and respond to certain signs or images captured by a camera.
  2. First, it creates a Sprite object with the name ‘Tobi’, and a Quarky object. It also imports a time module.
  3. Next, a Quadruped object is created with some parameters. Then, a RecognitionCards object is created to analyze the camera input. The object is set to enable a box around the detected object and to set the threshold of detection to 0.6.
  4. The code then puts the Quadruped object in its home position and enters an infinite loop.
  5. Within the loop, the code captures the camera input and uses the RecognitionCards object to analyze it. If an object is detected, the object’s class name is retrieved and used by the Sprite object to say that the object was detected.
  6. If the count of detected objects is greater than zero, the code checks if the detected object is a specific sign.
  7. If the object is a ‘Go‘ sign, the Quarky object will draw a specific pattern, and the Quadruped object will move forward.
  8. If the object is a ‘Turn Left‘ sign, the Quarky object will draw a different pattern and the Quadruped object will move to the right.
  9. If the object is a ‘Turn Right‘ sign, the Quarky object will draw another pattern, and the Quadruped object will move to the left.
  10. Finally, if the object is a ‘U Turn‘ sign, the Quarky object will draw a fourth pattern, and the Quadruped object will move backward.
  11. If the detected object is not any of the specific signs, the Quadruped object will return to its home position.
  12. So, this code helps a robot understand hand signs and move in response to them!

Output

Table of Contents