Table of Contents

Function Definition: showemotion(pattern = "happy")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
patternstringThe emotion that need to be displayed."happy", "angry", "crying", "super angry ", "surprise", "basic", "love", "nerd", "reject", "wave", "thinking", "giggle", or "disco""happy"

Description

The function sets the RGB LED display matrix to the emotion specified: “happy”, “angry”, “crying”, “super angry “, “surprise”, “basic”, “love”, “nerd”, “reject”, “wave”, “thinking”, “giggle”, and “disco”.

Example

The example demonstrates the various animation of the Quarky LED display in the Python Coding Environment.

Code

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

quarky.showemotion('happy')
time.sleep(1)
quarky.showemotion('angry')
time.sleep(1)
quarky.showemotion('crying')
time.sleep(1)
quarky.showemotion('super angry')
time.sleep(1)
quarky.showemotion('surprise')
time.sleep(1)
quarky.showemotion('basic')
time.sleep(1)
quarky.showemotion('love')
time.sleep(1)
quarky.showemotion('nerd')
time.sleep(1)
quarky.showemotion('reject')
time.sleep(1)
quarky.showemotion('wave')
time.sleep(1)
quarky.showemotion('thinking')
time.sleep(1)
quarky.showemotion('giggle')
time.sleep(1)
quarky.showemotion('disco')
time.sleep(1)

Output

Read More
Learn about AI-based face expression detection, a technology that uses artificial intelligence algorithms and computer vision techniques to analyze images or videos of human faces and recognize emotions or expressions.

Introduction

AI-based face expression detection refers to the use of artificial intelligence algorithms and computer vision techniques to analyze images or videos of human faces and recognize the emotions or expressions being displayed. The technology can detect and analyze subtle changes in facial features, such as eye movement, mouth shape, and eyebrow position, to determine whether a person is happy, sad, angry, surprised, or expressing other emotions.

Discover the various fields that utilize this technology, including psychology, marketing, and human-computer interaction. Additionally, read about the logic and code behind face detection with a camera feed, including the initialization of parameters, face detection library, loop execution, and if-else conditions. Explore how the technology continuously analyzes emotions, and how the humanoid responds with different facial expressions and movements.

Code

sprite = Sprite('Tobi')

fd = FaceDetection()

quarky = Quarky()

import time

humanoid = Humanoid(7, 2, 6, 3, 8, 1)

# Turn the video ON with 0% transparency
fd.video("ON", 0)
fd.enablebox()

# Run this script forever
while 1:
  fd.analysecamera()          # Analyse image from camera 
  sprite.say(fd.expression()) # Say the face expressions
  
  if fd.isexpression(1, "happy"): # if face expression is happy
    quarky.showemotion("happy")   # show happy emotion on Quarky
    humanoid.action("dance2", 1000, 1)
    
  if fd.isexpression(1, 'sad'):
    quarky.showemotion("crying")
    humanoid.action("updown", 1000, 1)
    
  if fd.isexpression(1, 'surprise'):
    quarky.showemotion('surprise')
    humanoid.action("moonwalker", 1000, 1)
    
  if fd.isexpression(1, 'angry'):
    quarky.showemotion('angry')    
    humanoid.action("flapping2", 1000, 1)
  else:
    humanoid.home()
    
# Comment the above script, uncomment the below script and 
# run this script to clear the stage and quarky display

fd.disablebox()
fd.video("off")    
quarky.cleardisplay()

Logic

The example demonstrates how to use face detection with a camera feed. Following are the key steps happening:

  1. The code is using face detection to recognize facial expressions and control a humanoid and a display device called Quarky accordingly.
  2. Then, the program turns on the video with 0% transparency and enables the bounding box for face detection.
  3. The code then enters an infinite loop where it continuously analyzes the image from the camera using face detection and says the detected facial expressions.
  4. The code then checks if the expression is happy, sad, surprised, or angry using the if statement. If the expression is happy, the Quarky device displays a happy emotion, and the humanoid performs the “dance2” action for specific time. Similarly, for sad, surprised, and angry expressions, Quarky displays the respective emotion, and the humanoid performs the associated action.
  5. If no facial expression is detected, the humanoid is set to its “home” position. Finally, if the program needs to be stopped.

Output

Read More
This code example shows how to program a humanoid robot to perform a dance routine. Learn how to use the Humanoid object with specific pins to control robot movement.

Introduction

Humanoid is a class in a programming code that is used to control the movements of a humanoid robot. The code provides specific pins to control the robot’s movement, and it allows the robot to perform a series of actions such as dancing, flapping, moving forward, and other actions. We can learn how to program a humanoid robot to dance.

Code

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

humanoid = Humanoid(7,2,6,3,8,1)

quarky.showemotion("surprise")
humanoid.home()
humanoid.move("forward",1000,1)
quarky.playsound("QuarkyIntro")
humanoid.action("flapping",1000,1)
time.sleep(1)
humanoid.action("dance2",1000,1)
time.sleep(1)
humanoid.action("moonwalker",1000,1)
time.sleep(1)
humanoid.action("dance1",1000,1)
time.sleep(1)
humanoid.action("forward",1000,1)
time.sleep(1)
Humanoid.action("tiptoeswing",1000,1)
time.sleep(1)
Humanoid.action("swing",1000,1)
time.sleep(1)
Humanoid.action("flapping",1000,1)
time.sleep(1)
Humanoid.action("updown",1000,1)
Humanoid.home()

Logic

  1. This code is an example of how to program a humanoid robot to perform a dance routine.
  2. The first line code imports the time module for later use.
  3. Then we initialize the Humanoid object with specific pins to control the movement of the robot. The pins are passed as arguments to the Humanoid function.
  4. Furthermore, we involve the Quarky object showing emotion, the humanoid robot moving to its home position, and then moving forward for a specified duration and speed.
  5. Then, Quarky plays a sound, and the humanoid performs a series of different actions, each with specific duration and speed, including flapping, dancing, moving forward, and other actions.
  6. The time. sleep(1) functions are used to pause the program for one second between each action.
  7. Finally, the humanoid returns to its home position at the end of the program.

Output

Read More
Learn about AI-based face expression detection, computer vision techniques to analyze images or videos of human faces and recognize emotions or expressions.

Introduction

AI-based face expression detection refers to the use of artificial intelligence algorithms and computer vision techniques to analyze images or videos of human faces and recognize the emotions or expressions being displayed. The technology can detect and analyze subtle changes in facial features, such as eye movement, mouth shape, and eyebrow position, to determine whether a person is happy, sad, angry, surprised, or expressing other emotions.

Discover the various fields that utilize this technology, including psychology, marketing, and human-computer interaction. Additionally, read about the logic and code behind face detection with a camera feed, including the initialization of parameters, face detection library, loop execution, and if-else conditions. Explore how the technology continuously analyzes emotions, and how the Humanoid responds with different facial expressions and movements.

Code

sprite = Sprite('Tobi')
fd = FaceDetection()
quarky = Quarky()
import time

humanoid = Humanoid(7, 2, 6, 3, 8, 1)

# Turn the video ON with 0% transparency
fd.video("ON", 0)
fd.enablebox()

# Run this script forever
while 1:
  fd.analysecamera()          # Analyse image from camera 
  sprite.say(fd.expression()) # Say the face expressions
  
  if fd.isexpression(1, "happy"): # if face expression is happy
    quarky.showemotion("happy")   # show happy emotion on Quarky
    humanoid.action("dance2", 1000, 1)
    
  if fd.isexpression(1, 'sad'):
    quarky.showemotion("crying")
    humanoid.action("updown", 1000, 1)
    
  if fd.isexpression(1, 'surprise'):
    quarky.showemotion('surprise')
    humanoid.action("moonwalker", 1000, 1)
    
  if fd.isexpression(1, 'angry'):
    quarky.showemotion('angry')    
    humanoid.action("flapping2", 1000, 1)
  else:
    humanoid.home()
    
# Comment the above script, uncomment the below script and 
# run this script to clear the stage and quarky display

fd.disablebox()
fd.video("off")    
quarky.cleardisplay()

Logic

The example demonstrates how to use face detection with a camera feed. Following are the key steps happening:

  1. Creates a sprite object named ‘Tobi’. A sprite is typically a graphical element that can be animated or displayed on a screen.also creates a Quarky object.
  2. Creates a face detection object named ‘fd’. This object is responsible for detecting faces in images or video using fd = FaceDetection()
  3. Imports the ‘time’ module, which provides functions to work with time-related operations using import time.
  4.  Creates a humanoid object with specific pins assigned to control various actions of the humanoid robot.
  5.  Turns on the video display with 0% transparency for the face detection module using fd.video(“ON”, 0).
  6.  Enables the face detection module to draw boxes around detected faces using fd.enablebox().
  7. The code enters an infinite loop using while 1, which means it will keep running indefinitely until interrupted.
  8. Analyzes the image from the camera for face detection using fd.analysecamera().
  9. The sprite says the detected face expressions obtained from the face detection module using sprite.say(fd.ex * pression()).
  10. The code checks for different face expressions using if statements and performs corresponding actions.
  11. For example, if the face expression is determined to be “happy“, the Quarky device shows a “happy” emotion, and the humanoid performs a dance action.
  12. Similarly, other face expressions like “sad”, “surprised”, and “angry” trigger specific emotional displays on Quarky and corresponding actions on the humanoid.
  13. If none of the predefined face expressions match, the humanoid goes back to its default or “home” position.

Output

Read More
All articles loaded
No more articles to load