Skip to content

senxor.cv_utils

senxor.cv_utils

Thread utilities for Senxor devices.

CVCamThread(video_capture, on_data=None, *, raise_on_backlog=False, backlog_threshold=5)

Parameters:

Name Type Description Default

video_capture

VideoCapture

The video capture to read frames from.

required

on_data

Callable

The callback function to call when a frame is read.

None

raise_on_backlog

bool

Whether to raise an error if the frame buffer backlog exceeds the threshold.

False

backlog_threshold

int

The threshold for the frame buffer backlog.

5

read()

Read the frame from the video capture.

Returns:

Type Description
ndarray | None

The frame from the video capture.

Raises:

Type Description
RuntimeError

If the thread is not started.

list_camera_info(backend=0)

List available camera information.

Parameters:

Name Type Description Default

backend

int

The backend to use for camera enumeration. If 0, all supported backends are used.

0

Returns:

Type Description
list of CameraInfo

List of camera information objects. Use cv2.VideoCapture(camera.index, camera.backend) to open a camera.

Examples:

  1. Print all cameras information available.
>>> for camera in list_camera_info():
...     print(camera.index, camera.name, camera.backend)
...     print(camera.path, camera.vid, camera.pid)
  1. Connect to a specific camera.
>>> camera_info = list_camera_info()[0]
>>> cap = cv2.VideoCapture(camera_info.index, camera_info.backend)