我在OpenCV (python)中得到了以下错误,并搜索了很多内容,但一直无法解决。
如果有人能给我一些线索,我将不胜感激。
OpenCV错误:断言失败(L.channels() == 1& I.channels() == 1),在connectedComponents_sub1中,文件/home/snoopy/opencv- opencv行341回溯(最近一次调用):文件"test.py",第30行,在I.channels=analyzeplant.analyzeSideView(植物) file“/home/snoopy/Desktop/叶子-201612/my-work/ripps/src/AnalyzePlant.py”中,第229行,在analyzeSideView plant_img = self.__extractPlantArea(plant_img) File“/home/snoopy/Desktop/叶子-201612/my-work-编辑/ripps/src/AnalyzePlant.py”中,在__extractPlantArea output =cv2.connectedComponentsWithStats(植物,4,3.1.0/modules/imgproc/src/connectedcomponents.cpp:341:错误:(-215) >函数connectedComponents_sub1中的L.channels() == 1和I.channels() == 1
发布于 2016-12-20 23:44:02
让我们分析一下:
断言失败(L.channels() == 1 && I.channels() == 1)
您要传递给某些功能的图像应该是1通道(灰色而不是颜色)。
__extractPlantArea(plant_img)
这发生在您的代码中,正好发生在名为__extractPlantArea
的函数中。
cv2.connectedComponentsWithStats
在调用名为OpenCV的connectedComponentsWithStats
函数时。
结论:
不要将彩色图像传递给connectedComponentsWithStats
https://stackoverflow.com/questions/41257336
复制相似问题