gpt4 book ai didi

python - 错误:函数arcLength中的(-215)计数> = 0 &&(深度== CV_32F ||深度== CV_32S)

转载 作者:行者123 更新时间:2023-12-02 16:21:24 26 4
gpt4 key购买 nike

我正在使用python 2.7

当我尝试在其上运行epsilon操作时出现此错误,
这是我的代码

import cv2
import numpy as np

img = cv2.imread('img.jpeg')
img = cv2.convertScaleAbs(img)
epsilon = 0.01 * cv2.arcLength(img, True)
approx = cv2.approxPolyDP(img, epsilon, True)
hull = cv2.convexHull(img)

这是错误,
Traceback (most recent call last):
File "/home/decentmakeover2/lanedetect.py", line 6, in <module>
epsilon = 0.01 * cv2.arcLength(img, True)
error: /home/decentmakeover2/opencv-
3.2.0/modules/imgproc/src/shapedescr.cpp:285: error: (-215) count >= 0 &&
(depth == CV_32F || depth == CV_32S) in function arcLength

我不确定在这里要更改什么,有什么想法吗?

编辑:
Traceback (most recent call last):
File "/home/decentmakeover2/lanedetect.py", line 8, in <module>
epsilon = 0.01 * cv2.arcLength(img,True)
TypeError: curve data type = 6 is not supported
>>>

enter image description here

最佳答案

arcLength (还有approxPolyDPconvexHull)需要作为输入

Input vector of 2D points



而不是图像。

所有这些功能都适用于点,计算图像的弧长(或多边形近似值或凸包)没有意义。

关于python - 错误:函数arcLength中的(-215)计数> = 0 &&(深度== CV_32F ||深度== CV_32S),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46849668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com