How to detect deviation from the track

Application scenarios are as follows: a driving car, from the white line 20CM (allow error of 5cm) driving, how to achieve deviation from the track after the alarm.Thank you very much!

Hi, we have a line following script example for color tracking that comes with the IDE. It solves this problem more or less to follow a single line (white or black) on an opposite color surface. Note that the line may have gaps. This is okay.

Or are you trying to stay between two lines on either side?

Thanks kwagyeman! I will be check!