Table of Contents

deleteallclass()

Function Definition: deleteallclass()

Parameters

Description

The function deletes all the stored databases of the images for face recognition.

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
The example demonstrates how face recognition works with analysis on the camera.

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

  1. Initializing the program with parameters for the sprite and face detection library.
  2. Saving the face showing in the camera as class 1.
  3. Running face recognition and reporting whether class 1 is detected or not.

Code

sprite = Sprite('Tobi')

fd = FaceDetection()
import time

fd.setthreshold(0.5)
fd.video("on", 0)
fd.enablebox()
time.sleep(2)

fd.deleteallclass()

# Adding face 1 to database
fd.addclassfromstage(1, "Face 1")

while True:
  fd.recognisefromcamera()
  
  if fd.isclassdetected(1):
    sprite.say("Face 1 Recognised")
  else:
    sprite.say("Face 1 Missing")

Output

Read More
All articles loaded
No more articles to load