Installing OpenCV to the TensorFlow Docker Image

This tutorial will walk you through installing OpenCV into an existing TensorFlow Docker image. OpenCV is a library that provides C/C++, Python, and java interfaces for computer vision applications.  Primarily, we will be using OpenCV to read in images for training and testing networks with TensorFlow.

Download the Required Files and Install OpenCV to Your Docker Image

  • Pull the new version of the deepcars repo from (if you downloaded the repo as a zip previously, replace your old ‘deepcars-master’ directory with the new one from the zip)
  • Download the Dockerfile for installing OpenCV here (Make sure the files saves with no extension, if your browser appends ‘.txt’ to the file, please delete the extension)
  • Open Powershell (Windows) or a terminal (Mac OS X/Linux) and navigate to the directory where you saved ‘Dockerfile’
  • Rebuild the Docker image with OpenCV and save the image as ‘deepcars’

Updating Your Docker Script

  • Open the script you created in the previous tutorial for starting the TensorFlow docker image in a text editor.
  • Change the line


    or, if you are not using a script, execute the above line from now on to launch your Docker image

Now, when you navigate to the URL given to you by Docker, you should have an an additional notebook titled ‘5_tensorflow_traffic_light_classification.ipynb’ that can be run with OpenCV support.