-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathspatialCNNLaneDetectionExample.m
38 lines (29 loc) · 1.15 KB
/
spatialCNNLaneDetectionExample.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
%% Lane Detection Using Spatial-CNN Network
% The following code demonstrates running lane detection on a pre-trained SCNN
% network, trained on CULane dataset.
%% Prerequisites
% To run this example you need the following prerequisites -
% * MATLAB (R2021a or later).
% * Deep Learning Toolbox.
% * Pretrained Spatial-CNN network (download instructions below).
%% Add path to the source directory
addpath('src');
%% Download Pre-trained Network
model = helper.downloadSCNNLaneDetection;
net = model.net;
%% Specify Detection Parameters
% Use the function helper.createSCNNDetectionParameters to specify the
% parameters required for lane detection.
params = helper.createSCNNDetectionParameters;
% Specify the executionEnvironment as either "cpu", "gpu", or "auto".
executionEnvironment = "auto";
%% Detect on an Image
% Read the test image.
path = fullfile("images","testImage.jpg");
image = imread(path);
% Call detectLaneMarkings to detect the lane markings.
laneMarkings = detectLaneMarkings(net, image, params, executionEnvironment);
% Visualize the detected lanes.
fig = figure;
helper.plotLanes(fig, image, laneMarkings);
% Copyright 2021 The MathWorks, Inc.