September 2019
Intermediate to advanced
420 pages
10h 29m
English
Using OpenCV, we can easily create a k-NN model via the cv2.ml.KNearest_create() function. Building the model then involves the following steps:
We first import all of the necessary modules: OpenCV for the k-NN algorithm, NumPy for data processing, and Matplotlib for plotting. If you are working in a Jupyter Notebook, don't forget to call the %matplotlib inline magic:
In [1]: import numpy as np... import cv2... import matplotlib.pyplot as plt... %matplotlib inlineIn [2]: plt.style.use('ggplot') ...Read now
Unlock full access