JaidedAI / EasyOCR

Ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic and etc.
https://www.jaided.ai
Apache License 2.0
23.79k stars 3.12k forks source link

cv2.error: Unknown C++ exception from OpenCV code #687

Open Dimuthu-10 opened 2 years ago

Dimuthu-10 commented 2 years ago

When I have tried to run my code sometimes this error occurred. but sometimes the application works properly. i have tried lots of ways to fix this error.


  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1516, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\flask\app.py", line 1502, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\dash\dash.py", line 1344, in dispatch
    response.set_data(func(*args, outputs_list=outputs_list))
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\dash\_callback.py", line 151, in add_context
    output_value = func(*func_args, **func_kwargs)  # %% callback invoked %%
  File "E:\Git Projects\simple-flask-webApp\index.py", line 305, in update_output
    return [[parse_contents(list_of_contents, list_of_names)], [parse_image(list_of_contents)]]
  File "E:\Git Projects\simple-flask-webApp\index.py", line 122, in parse_image
    numberplate = number_plate(original_img)
  File "E:\Git Projects\simple-flask-webApp\index.py", line 289, in number_plate
    ocr_result = reader.readtext(region)
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\easyocr.py", line 385, in readtext
    horizontal_list, free_list = self.detect(img, min_size, text_threshold,\
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\easyocr.py", line 275, in detect
    text_box_list = get_textbox(self.detector, img, canvas_size, mag_ratio,
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\detection.py", line 95, in get_textbox
    bboxes_list, polys_list = test_net(canvas_size, mag_ratio, detector,
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\detection.py", line 55, in test_net
    boxes, polys, mapper = getDetBoxes(
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\craft_utils.py", line 236, in getDetBoxes
    boxes, labels, mapper = getDetBoxes_core(textmap, linkmap, text_threshold, link_threshold, low_text, estimate_num_chars)
  File "C:\Users\MY-PC\AppData\Local\Programs\Python\Python39\lib\site-packages\easyocr\craft_utils.py", line 31, in getDetBoxes_core
    nLabels, labels, stats, centroids = cv2.connectedComponentsWithStats(text_score_comb.astype(np.uint8), connectivity=4)
cv2.error: Unknown C++ exception from OpenCV code```
suzakuwcx commented 2 years ago

640

downgrade opencv-python to 4.5.1.48 seems still working

adeel-learner commented 1 year ago

upgrading opencv-python worked for me