Deep learning in OpenCV

Since OpenCV 3.1, there has been a deep neural networks (DNN) module in the library, implementing forward pass (inferencing) with deep networks, pre-trained using some popular deep learning frameworks, such as Caffe (http://caffe.berkeleyvision.org/), TensorFlow (https://www.tensorflow.org/), Torch/Pytorch (http://torch.ch/), Darknet (https://pjreddie.com/darknet/), and models in ONNX (https://onnx.ai/) format. In OpenCV 3.3, the module has been promoted from an opencv_contrib repository to the main repository (https://github.com/opencv/opencv/tree/master/modules/dnn) and has been accelerated significantly. Therefore, since OpenCV 3.3, pre-trained networks can be used to make a prediction within our application, and many of the popular network architectures, which were introduced in the previous section, are compatible with OpenCV 3.3.

 In this section, we will see how to apply some of these architectures to both object detection and image classification, but before we cover this, a number of functions that OpenCV provides in the DNN module should be reviewed.