Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv2.connectedComponentsWithStats raises weird error on latest version #602

Closed
SHA65536 opened this issue Dec 29, 2021 · 8 comments
Closed

Comments

@SHA65536
Copy link

Actual behaviour

When using cv2.connectedComponentsWithStats I am presented with a mysterious error

nLabels, labels, stats, centroids = cv2.connectedComponentsWithStats(text_score_comb.astype(np.uint8), connectivity=4)
cv2.error: Unknown C++ exception from OpenCV code

Took me a long time to figure out what's wrong because of the vague error message...
Finally solved it by switching back to version 4.5.4.60

Steps to reproduce

Windows 10 64bit
opencv-python 4.5.5.62
Use the cv2.connectedComponentsWithStats function with the latest opencv-python version

@alalek
Copy link
Member

alalek commented Dec 30, 2021

Lets track it here: opencv/opencv#21366

@noxqs
Copy link

noxqs commented Mar 7, 2022

For me removing the parameter connectivity=4 from cv2.connectedComponentsWithStats fixed it. This is in cojunction with easyOCR.

@robertschweizer
Copy link

FYI: This still fails with the latest release opencv-python 4.5.5.64, because it does not include a newer OpenCV C++ library than 4.5.5.62.

The OpenCV C++ library has been fixed, but not released yet.

@rinnegann
Copy link

For me removing the parameter connectivity=4 from cv2.connectedComponentsWithStats fixed it. This is in cojunction with easyOCR.

Thanks!,This has worked for me.

@GeraldLJW
Copy link

For me removing the parameter connectivity=4 from cv2.connectedComponentsWithStats fixed it. This is in cojunction with easyOCR.

thanks!!!!

@bhumika-cashify
Copy link

For me removing the parameter connectivity=4 from cv2.connectedComponentsWithStats fixed it. This is in cojunction with easyOCR.

thankyou so much.

@Nadinegp
Copy link

For me removing the parameter connectivity=4 from cv2.connectedComponentsWithStats fixed it. This is in cojunction with easyOCR.

Where can I find the file? what is it called?

@mikeboharsik
Copy link

For anyone else experiencing this issue, @robertschweizer seemed to have it right. I ran the following command:

pip install --upgrade opencv-contrib-python

and the exception went away. The suggestion from @noxqs works as well but obviously is far less ideal than having the packages "fix" themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants