Table of Contents

Function Definition: analysecamera()

Parameters

Description

This function is used to analyze the image received as input from the camera, for objects.

Alert: This block processes the image input and updates the values in the other functions hence it needs to be put inside loops while making projects.

Example

waste
A waste management system that will differentiate the waste based on its type in Python Coding Environment. If it detects biodegradable waste, the LEDs Quarky’s matrix will turn green. If it’s non-biodegradable waste, the LEDs will turn blue.

Code

sprite = Sprite('Tobi')
od = ObjectDetection()
speech = TexttoSpeech()
quarky = Quarky()

od.video("on", 1)
od.enablebox()
od.setthreshold(0.5)

speech.setvoice('alto')
speech.setlanguage('en')

while True:
  od.analysecamera()
  
  if od.isdetected('banana'):
    quarky.drawpattern("ccccccccccccccccccccccccccccccccccc")
    speech.speak("Biodegradable Waste")
  
  if od.isdetected('bottle'):
    quarky.drawpattern("fffffffffffffffffffffffffffffffffff")
    speech.speak("Non Biodegradable Waste")

Output

waste

Read More
Learn how to code logic for video input detection with this example code. You will be able to direct your own Mars Rover easily by just showing signs through the camera input.

Introduction

A sign detector Mars Rover robot is a robot that can recognize and interpret certain signs or signals, such as hand gestures or verbal commands, given by a human. 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')
# sprite = Sprite('Tobi')
quarky = Quarky()
import time

recocards = RecognitionCards()
rover = MarsRover(4, 1, 7, 2, 6)

recocards.video("on flipped")
recocards.enablebox()
recocards.setthreshold(0.6)

while True:
  recocards.analysecamera()
  sign = recocards.classname()
  sprite.say(sign + ' detected')
  
  if recocards.count() > 1:
    if 'Go' in sign:
      rover.home()
      rover.setinangle(0)
      quarky.runtimedrobot("F",100,3)
      
    if 'Turn Left' in sign:
      rover.home()
      rover.setinangle(40)
      quarky.runtimedrobot("L",100,3)

    if 'Turn Right' in sign:
      rover.home()
      rover.setinangle(40)
      quarky.runtimedrobot("R",100,3)
      
    if 'U Turn' in sign:
      rover.home()
      rover.setinangle(0)
      quarky.runtimedrobot("B",100,3)

Logic

  1. Firstly, the code sets up the stage camera to look for signs and detects and recognizes the signs showed on the camera.
  2. Next, the code starts a loop where the stage camera continuously checks for the signs.
  3. Finally, if the robot sees certain signs (like ‘Go’, ‘Turn Left’, ‘Turn Right’, or ‘U Turn’), it moves in a certain direction (forward, backward, left, or backward) based on the respective signs.
  4. This can help the Mars Rover to manoeuvre through the terrain easily by just showing signs on the camera.

Output

Forward-Backward Motions:

Right-Left Motions:

Read More
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

Read More
All articles loaded
No more articles to load