How do I determine whether a truck is inside its lane? I have a bunch of images from different trucks passing the road. Here is an example.

The truck needs to be at a certain distance from the border of the lane. Some of the trucks are way close to the border (that you can see on the shoulder of the road).
I want to find a way to measure the distance between the truck and the border of the lane and, more importantly, to detect whether a truck is inside its lane.
I would like to solve this problem by training a deep learning-based classifier or image processing techniques. Painting the ground is also possible if I can train a classification algorithm with painted images.
One possible approach will be to use an algorithm which detects lines (Ex. Hough lines or any deep neural net trained to detect lanes) and use some threshold range so that we can get the lane and the edges of truck, then after extracting the lines, you can easily find the distance between them.

Then you need to experiment out on few images to get the threshold distance that you are expecting the truck to maintain as the real distance and the distance calculated using images are not same 



If you want to classify using deep learning, you may need to preprocess the images and send them. As it will become very difficult to directly learn to classify 
based on image, you may need to first detect the lanes, then apply a mask and then send the masked image to your network to make the network to converge.