How to do it...

You need to complete the following steps:

  1. Import the modules:
import cv2import numpy as np
  1. Generate a fourth degree polynomial equation:
N = 4coeffs = np.random.randn(N+1,1)
  1. Find all the roots in the complex domain:
retval, roots = cv2.solvePoly(coeffs)
  1. Check the roots:
for i in range(N):    print('Root', roots[i],'residual:',           np.abs(np.polyval(coeffs[::-1], roots[i][0][0]+1j*roots[i][0][1])))

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.