Table of Contents

addclassfromstage()

Function Definition: addclassfromstage(label_number = 1, label_name = "Jarvis")

Parameters

NameTypeDescriptionExpected ValuesDefault Value
label_numberintLabel number for which the information is stored.1-101
label_namestringLabel name of the face.String"Jarvis"

Description

The function allows the user to add a particular face to the database from the stage. The user can specify the name of the face with the argument as well. This addition of the face in the database is also stored inside the PictoBlox file while saving.

Face Recognition Process

Face recognition has the ability to recognize a face and then match it with the data of the faces stored in a database. Face recognition is an extremely useful application of artificial intelligence that can identify an individual by analyzing their facial patterns and textures.

Example

The example demonstrates how face recognition works with analysis on the stage.

The example demonstrates the application of face recognition with stage. Following are the key steps happening:

  1. Initializing the program with parameters for the sprite and face detection library.
  2. Saving Chris’s face as class 1.
  3. Saving Robert’s face as class 2.
  4. Running face recognition and placing the square box sprite on the faces of Chris and Robert.

Code

sprite = Sprite('Square Box')
fd = FaceDetection()
import time

fd.setthreshold(0.5)
fd.enablebox()

# Reset Database
fd.deleteallclass()

# Adding Chirs face to database
sprite.switchbackdrop("Chris")
time.sleep(0.5)
fd.addclassfromstage(1, "Chris")

# Adding Robert face to database
sprite.switchbackdrop("Robert")
time.sleep(0.5)
fd.addclassfromstage(2, "Robert")

sprite.switchbackdrop("Robert and Chris")

while True:
  fd.recognisefromstage()
  
  print(fd.count())
  for i in range(fd.count()):
    sprite.setx(fd.x(i+1))
    sprite.sety(fd.y(i+1))
    sprite.setsize(fd.width(i+1))
    sprite.say(getclassname(i+1))
    time.sleep(1)

Result

Read More
All articles loaded
No more articles to load