April 2019
Intermediate to advanced
336 pages
8h 22m
English
Our query images will come from a web search. Before we start implementing the search functionality, let's write some helper functions that let us fetch images through the Requests library and convert them into an OpenCV-compatible format. Because this functionality is highly reusable, we will put it in a module of static utility functions. Let's create a file called RequestsUtils.py and import OpenCV, NumPy, and Requests, as follows:
#!/usr/bin/env pythonimport numpy # Hint to PyInstallerimport cv2import requestsimport sys
As a global variable, let's store HEADERS, a dictionary of headers that we will use when making web requests. Some servers reject requests that appear to come from a bot. To improve the chance ...
Read now
Unlock full access