O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required