网上写的都不够通俗易懂,所以自己开一个贴
用法查询官网
https://docs.opencv.org/4.5.1/d3/dc0/group__imgproc__shape.html#gaf849da1fdafa67ee84b1e9a23b93f91f
error: (-215:Assertion failed) npoints2 >= 0 || npoints3 >= 0 in function ‘fitLine’
此报错原因是传入的点集不符合参数条件。
首先排查传给fitLine的点集是否为空。