How it works...

The getLayersShapes function of the Net class from the cv2.dnn module computes all tensor shapes. It accepts shape as input, a list of four integers. The elements in the list are the number of examples, number of channels, width, and height of the input tensor. The function returns a tuple of three elements: a list of layer identifiers in the model, a list of input tensor shapes for each layer, and a list of output tensor shapes also for each layer. The list of layer identifiers is necessary when we want to get some additional information about the layers, because some functions of cv2.dnn_Net accept identifiers from this list. Returned lists for the input and output shapes contain all the shapes for all of the outputs of ...

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.