Sensors module

class sensors.Camera[source]

Bases: object

A class to groups functions related to OpenMV Cam

More infos: https://openmv.io/products/openmv-cam-h7

width

the screen width in pixels

height

the screen height in pixels

BALL_DIAMETER = 45
FOCAL_LENGTH = 2.8
HFOV = 70.8
REAL_SIZE = 7
THRESHOLDS = [(0, 100, 127, 42, -128, 127)]
VFOV = 55.6
__init__()[source]

Initialize the LED to show state and setup the camera sensor

static ball_blob()[source]

Takes a snapshot and find pixels area matching with thresholds . :returns: returns a blob object if visible. :rtype: image.blob | None

Additionnal informations can be found here about the blob object:

https://docs.openmv.io/library/omv.image.html

static distance_to(blob) float[source]

Calculate real distance between camera and object.

Parameters

blob – a blob object (you can get one with ball_blob())

Returns

The distance in millimeters.

static get_angle(blob) float[source]

Get horizontal relative angle (in degrees) of the blob.

Parameters

blob – a blob object (you can get one with ball_blob())

Returns

The angle between [-35.4, +35.4]

shutdown()[source]

Shutdown the camera and the LED

class sensors.Sensor[source]

Bases: object

A class that represent the Arduino-controlled sensors

Offers an interface for ultrasonics sensors and line sensors (IR).

PIN = 2
SLAVE_ADDRESS = 16
__init__()[source]
recv() tuple[source]

Requests the Arduino controller via I2C and unpack data received from sensors.

Returns

The front and back distance and a list of four line sensors values.

Return type

(front_dist, back_dist, line_sensors)