Class «objectSensor»

This article is automatically translated from Russian by Google Translator.

Camera in object sensor mode. Captures a contrasting object in the center of the frame and returns its coordinates and size in the frame.

detect

Detects the dominant color in the center of the frame and remembers it as the color of the object. After that, the "read" method starts to return data for the object.

Syntax

brick.objectSensor().detect();

init

Switches the camcorder on and initializes it in object sensor mode. The boolean parameter determines whether to display the image from the camera (true — display).

Syntax

brick.objectSensor().init(true);

The boolean parameter defines whether to display the image from the camera:

  • true — output,

  • false — don't output.

read

Returns an array that contains the following data in its cells:

  • In the zero cell, the X-axis coordinate of the object center relative to the center of the frame (-100 to 100, -100 is the center of the object on the edge of the frame on the left);

  • The Y-coordinate of the object's center relative to the frame center (from -100 to 100, -100 is the center of the object on the frame edge at the top);

  • The second cell is the relative size of the object, a number from 0 to 100 (100 - the object occupies almost the entire frame, 0 - the object is not on the frame).

Syntax

brick.objectSensor().read();

stop

Turns off the camera and stops the sensor.

Syntax

brick.objectSensor().stop();

Last updated