March 2018
Beginner to intermediate
306 pages
9h 54m
English
You need to complete the following steps:
import cv2import numpy as np
def contours_pca(contours): # join all contours points into the single matrix and remove unit dimensions cnt_pts = np.vstack(contours).squeeze().astype(np.float32) mean, eigvec = cv2.PCACompute(cnt_pts, None) center = mean.squeeze().astype(np.int32) delta = (150*eigvec).astype(np.int32) return center, delta
def draw_pca_results(image, contours, center, delta): cv2.drawContours(image, contours, -1, (255, 255, 0)) cv2.line(image, tuple((center + delta[0])), ...