Skip to content

Camera Self Driving ​

Instance declaration ​

When you add a Camera Self Driving block to the workspace, the following instance declaration is automatically inserted into the Python code:

python
self_driving = SelfDriving(0)
# When there are multiple instances
self_driving_1 = SelfDriving(1)

Parameters ​

NameKindDescriptionRange / TypeDefault
indexDropdown optionInstance number (starting from 0)Integer 0 or greater0

Select the camera device ​

Sets the camera to use for camera self driving.

device

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionCamera device nameSystem camera label-

Python ​

python
self_driving = SelfDriving(0)

self_driving.device('')

Set the lane colors ​

Sets the color of the left and right lanes.

set_lane_color

Parameters ​

NameKindDescriptionRange / TypeDefault
leftDropdown optionLeft lane colorred, green, blue-
rightDropdown optionRight lane colorred, green, blue-

Python ​

python
self_driving = SelfDriving(0)

self_driving.set_lane('green', 'blue')

Detect once ​

Finds the selected colors/lanes on the screen and marks their regions just once.

detect_once

Parameters ​

(none)

Python ​

python
self_driving = SelfDriving(0)

self_driving.detect_once()

Start / stop continuous detection ​

Keeps following the screen for the selected colors/lanes and marks their regions on the screen.

detect_continuous

Parameters ​

NameKindDescriptionRange / TypeDefault
unitDropdown optionActionstart, stop-

Python ​

python
self_driving = SelfDriving(0)

# unit = "start"
self_driving.detect_continuous()
# unit = "stop"
self_driving.stop()

Show the detection result ​

Decides whether or not to show the color/lane detection result on the camera screen.

display

Parameters ​

NameKindDescriptionRange / TypeDefault
onDropdown optionDisplay ON / OFFshow (on=True), hide (off=False)TRUE

Python ​

python
self_driving = SelfDriving(0)

self_driving.display(True)
self_driving.display(False)

Lane data ​

Returns the position or distance value of the specified lane.

lane_data

Parameters ​

NameKindDescriptionRange / TypeDefault
laneDropdown optionLaneleft, right-
unitDropdown optionKind of measurementx, distance-

Python ​

python
self_driving = SelfDriving(0)

self_driving.lane('left', 'x')
self_driving.lane('right', 'distance')

Color data ​

Returns the position/size values of the specified color.

color_data

Parameters ​

NameKindDescriptionRange / TypeDefault
colorDropdown optionColor namered, green, blue-
unitDropdown optionKind of coordinate/sizex, y, min_x, max_x, min_y, max_y, width, height, area-

Python ​

python
self_driving = SelfDriving(0)

self_driving.color('red', 'x')
self_driving.color('green', 'y')
self_driving.color('blue', 'area')

Distance between two colors ​

Returns the distance between two colors.

color_to_color

Parameters ​

NameKindDescriptionRange / TypeDefault
unit1Dropdown optionFirst colorred, green, blue-
unit2Dropdown optionSecond colorred, green, blue-
typeDropdown optionKind of distancedistance (omitted or None), horizontal distance (horizontal), vertical distance (vertical)None

Python ​

python
self_driving = SelfDriving(0)

self_driving.get_distance('red', 'blue')  # distance
self_driving.get_distance('green', 'blue', 'horizontal')  # horizontal distance

Whether a lane was detected ​

Whether a particular lane was found

lane_detected

Parameters ​

NameKindDescriptionRange / TypeDefault
laneDropdown optionLaneleft, right, both, anyany

Python ​

python
self_driving = SelfDriving(0)

self_driving.lane_detected('left')

Whether a color was detected ​

Whether a particular color region was found

color_detected

Parameters ​

NameKindDescriptionRange / TypeDefault
colorDropdown optionColor namered, green, blue, anyany

Python ​

python
self_driving = SelfDriving(0)

self_driving.color_detected('red')