cv_object_detection


Overview

The cv_object_detection example uses a selected camera to capture an image every 5 seconds and display it on the robot’s chest screen. The application detects objects in the image, draws bounding boxes around them, and logs the detection results.

Inputs

  • Optional command-line argument for selecting a camera (-c or –camera).

  • User input via terminal menu when no camera argument is provided.

Outputs

  • Log messages indicating the detection status.

  • A snapshot is captured every 5 seconds and displayed on the robot’s chest screen.

  • If objects are detected, bounding boxes are drawn on the image.

  • The console logs the detected objects’ names.

Execution

The application can be executed using:

  1. Specify the camera directly using an argument:

    python3 cv_object_detection/ --auto-run -c <camera_name>
    
    python3 cv_object_detection/ --auto-run --camera <camera_name>
    
  2. Select the camera via an interactive terminal menu:

    If no camera argument is provided, the user will be prompted to select a camera from a menu:

    python3 cv_object_detection/ --auto-run
    
    • If the terminal window is too small, a notification will appear instructing the user to resize it.

    • The user selects a camera by pressing the Enter key.

Behavior

  • The application enables the object detection model.

  • It captures an image every 5 seconds.

  • The captured image is displayed on the chest screen.

  • If no objects are detected, the following log message is displayed:

[INFO] [timestamp] [pyraya.cv_object_detection]: No objects detected
  • If one or more objects are detected:
    • Bounding boxes are drawn around the detected objects.

    • A console log message is generated:

      If one object is detected:

      [INFO] [timestamp] [pyraya.cv_object_detection]: 1 object detected
      [INFO] [timestamp] [pyraya.cv_object_detection]:   - <object_name>
      

      If multiple objects are detected:

      [INFO] [timestamp] [pyraya.cv_object_detection]: <number> objects detected
      [INFO] [timestamp] [pyraya.cv_object_detection]:   - <object1_name>
      [INFO] [timestamp] [pyraya.cv_object_detection]:   - <object2_name>
      ...
      

Example Output

During execution, the output logs follow this pattern:

[INFO] [timestamp] [pyraya.cv_object_detection]: Auto running the app
[WARNING] [timestamp] [pyraya.cv_object_detection]: Enabling object detection model 🔍
[WARNING] [timestamp] [pyraya.cv_object_detection]: Capturing image...
[INFO] [timestamp] [pyraya.cv_object_detection]: 1 object detected
[INFO] [timestamp] [pyraya.cv_object_detection]:   - <object_name>

Additionally, the output image will be displayed on the chest.

Key Note

  • If the camera or chest display is unavailable, the application logs an error and exits.