OpenCV Error: Assertion Failed (L.channels() == 1 && I.channels() == 1) In ConnectedComponents_sub1
I got the following error in OpenCV (python) and have googled a lot but have not been able to resolve. I would be grateful if anyone could provide me with some clue. OpenCV Error
Solution 1:
Let us analyze it:
Assertion failed (L.channels() == 1 && I.channels() == 1)
The images that you are passing to some function should be 1 channel (gray not color).
__extractPlantArea(plant_img)
That happened in your code exactly at the function called __extractPlantArea
.
cv2.connectedComponentsWithStats
While you are calling the OpenCV function called connectedComponentsWithStats
.
Conclusion:
Do not pass colorful (BGR) image to connectedComponentsWithStats
Post a Comment for "OpenCV Error: Assertion Failed (L.channels() == 1 && I.channels() == 1) In ConnectedComponents_sub1"