Computer vision engine

This is the final piece of the puzzle! In the last section, we briefly touched upon the computer vision engine and how it was being called using the cv_engine() function. In this section, we will look inside this function. For the sake of simplicity, in the last section, the cv_engine() function was capable of performing only one operation, which is to convert the image to a grayscale image. Let's add support for more operations for our service in this function.

First, we will add the capability to compute canny edges in images. The following is the code for this:

def cv_engine(img, operation):    if operation == 'to_grayscale':        return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)    elif operation == 'get_edge_canny': gray = cv2.cvtColor(img, ...

Get Computer Vision with Python 3 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.