How it works...

cv2.solveLP accepts three arguments: a function's weights, a linear constraints matrix, and a NumPy array object to save results. Weights are represented with an (N,1) or (1,N) vector of float values. The length of this vector also means the number of optimized parameters. The linear constraints matrix is an (M, N+1) NumPy array, where the last column contains constant terms for each constraint and each row, except the last element, which contains coefficients for the corresponding parameters. The last argument is intended to store the solution if it exists.

In general, there are four possible outcomes for linear programming problems, they may have a single solution, many solutions (in some range), or no determined solutions ...

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.