Notebook 7.4 - Image Segmentation using Computer Vision

In this notebook we provide an example of Image Segmentation in practice, using the OpenCV, Keras and TensorFlow libraries. If you run the notebook, you will see a video recorded from the windscreen of a window, superimposed with a segmentation layer, that highlights the current lane.

This is what the output that you should see:

image.png

This particular demonstration requires an advanced set of libraries, that can be quite tricky to install. We tested this notbook in both Windows and MacOS, and it should function correctly.

We need a particular version of the opencv library for it to work correctly in both platforms, and therefore we will ensure that some other versions that you might have installed are not present (using the pip uninstall command).

For the purposes of this notebook, we will use a pre-trained model, that will be able to identify the segment of the road that belongs to the current lane.

The following function will resize the frames of the video to a size that is compatible with our model.

The following function will pretinct the presense of a lane segment on a perticular frame

Load video file and pre-trained model

Read the video frames in a loop and send to model for lane detection
Press "Q" to exit the streaming