cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
最新推荐文章于 2022-10-10 18:51:36 发布
Zhang_314
最新推荐文章于 2022-10-10 18:51:36 发布
cnt = np.array([[x1,y1],[x2,y2],[x3,y3],[x4,y4]]) # 必须是array数组的形式
rect = cv2.minAreaRect(cnt) # 得到最小外接矩形的(中心(x,y), (宽,高), 旋转角度)
box = cv2.boxPoints(rect) # cv2.boxPoints(rect) for OpenCV 3.x 获取最小外接矩形的4个顶点坐标
box = np.int0(box)
一直报错:cv2.error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\imgproc\src\convhull.cpp:137: error: (-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) in function 'cv::convexHull'
原因是 cnt 是float64 类型,cnt只能是float32或者int32
改过来就好了
cnt = np.array(cnt, dtype=np.float32)
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
cnt = np.array([[x1,y1],[x2,y2],[x3,y3],[x4,y4]]) # 必须是array数组的形式rect = cv2.minAreaRect(cnt) # 得到最小外接矩形的(中心(x,y), (宽,高), 旋转角度)box = cv2.boxPoints(rect) # cv2.boxPoints(rect) for OpenCV 3.x 获取最小外接矩形的...
sorted() 函数对所有可迭代的对象进行排序操作。返回重新排序的列表。
sort 与 sorted 区别:
sort 是应用在 list 上的方法,sorted 可以对所有可迭代的对象进行排序操 作。
list 的 sort 方法返回的是对已经存在的列表进行操作,无返回值,而内建函 数 sorted 方法返回的是一个新的 list,而不是在原来的基础上进行的操作。
sorted 语法:
sorted(iterable, cmp=None, key=None, reverse=False)
参数说明:
iterable – 可迭代对象。
cmp – 比较的函数,这个具有两个
【解决】error: (-
215
:
Assertion
failed
) npoints >= 0 && (
depth
==
CV
_
32F
||
depth
==
CV
_
32S
) in function ‘
cv
::contour
Area
’
In
OpenCV
3.4:
image, contours, hierarchy=
cv2
.findContours(image,...
Traceback (most recent call last):
File "***.py", line 47, in <module>
(x, y, w, h) =
cv2
.bounding
Rect
(contour)
cv2
.error:
OpenCV
(4.0.0) /Users/travis/build/skvark/
opencv
-python/open...
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
huang02120828:
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
wangmeili@:
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
Cassandrabcf:
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
Zhang_314:
cv2.minAreaRect(cnt) 报错:(-215:Assertion failed) total >= 0 && (depth == CV_32F || depth == CV_32S) i
qq_58984351: