opencv - python 使用findContours时报错
image, contours, hierarchy = cv2.findContours(blue_gray, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
TypeError: Layout of the output array image is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)
解决
类型转换
blue_gray=blue_gray.astype(np.uint8

在使用OpenCV的findContours函数时遇到了TypeError,提示输出数组图像布局与cv::Mat不兼容。解决方法是确保输入图像为单通道灰度图或二值图,并进行适当类型转换。同时,提到了轮廓检索模式的相关补充。
最低0.47元/天 解锁文章
3913

被折叠的 条评论
为什么被折叠?



