Labplus Knowledge Base

Product Documentation

  • mPython Board 3.0 Documentation
  • mPython Core 2.0 Documentation
  • AI Camera 4.0 Documentation
    • 1. Hardware Introduction
    • 2. Sensor Programming Modes
    • 3. Example Programs
      • 1. Initialize AI Camera 4.0
      • 2. 80-Class Object Detection
      • 3. Face Recognition
      • 4. Face Detection
      • 5. Expression Recognition
      • 6. Blink and Mouth-Open Detection
        • 6.1. Python Example
        • 6.2. mPython Graphical Example
        • 6.3. Functions and Methods
        • 6.4. Test Video
      • 7. Palm Detection
      • 8. Dynamic Gesture Recognition
      • 9. Palm Keypoint Classification
      • 10. Human Detection
      • 11. Fall Detection
      • 12. Human Pose Recognition
      • 13. Human Skeleton Keypoint Recognition
      • 14. License Plate Recognition
      • 15. Barcode
      • 16. QR Code Recognition
      • 17. LAB Color Recognition
      • 18. Self-Trained Model - Object Detection
      • 19. Self-Trained Model - Image Classification
    • 4. Serial Port Protocol
    • 5. Main Controller Mode
    • 6. FAQ
    • 7. Copyright Notice
  • mPython IoT Documentation
  • mPython Module Documentation

Knowledge Base

  • Labplus Knowledge Base

About

  • Product Selection Guide
Labplus Knowledge Base
  • AI Camera 4.0 Documentation
  • 3. Example Programs
  • 6. Blink and Mouth-Open Detection
  • View page source

6. Blink and Mouth-Open Detection

Perform blink and mouth-open detection on the AI Camera.

Blink and mouth-open detection is a common facial behavior analysis task in computer vision, typically used for fatigue detection, liveness detection, human-computer interaction, and similar scenarios.

6.1. Python Example

Example: Blink and Mouth-Open Detection
#mPythonType:0
from mpython import *

import smartcamera_k230 as smartcamera

smart_camera = smartcamera.SmartCameraK230(tx=Pin.P1, rx=Pin.P0)

smart_camera.model_init(27)

while True:
    smart_camera.face_living_body.recognize()
    print(str('Blink count: ') + str(smart_camera.face_living_body.mouth_blink_counter[0]))
    print(str('Mouth-open count: ') + str(smart_camera.face_living_body.mouth_blink_counter[1]))

6.2. mPython Graphical Example

../../../../_images/blink.png

6.3. Functions and Methods

smart_camera.model_init(cur_state)

Instantiate the model

Parameters:

cur_state (int) – model id for initialization

class smart_camera.face_living_body
recognize()

Run recognition

class smart_camera.face_living_body

Blink and mouth-open detection instance

Variables:
  • mouth_blink_counter (list) – list of blink and mouth-open counts

  • mouth_blink_counter[0] (int) – number of blinks

  • mouth_blink_counter[1] (int) – number of mouth opens

6.4. Test Video

Previous Next

© Copyright 2026, Labplus.

Built with Sphinx using a theme provided by Read the Docs.