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

[Bug]: adding rotation with adding border error #802

Open
eren-ay opened this issue Dec 25, 2024 · 0 comments
Open

[Bug]: adding rotation with adding border error #802

eren-ay opened this issue Dec 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@eren-ay
Copy link

eren-ay commented Dec 25, 2024

Issue

this bug It only happens in very rare cases. For this to happen, rotation must be turned on and the minimum image size must be small so that the add_border works.
i change detection/common.py line20
if auto_rotate or rotate:
minimum_image_size = 0
else:
minimum_image_size = 400
but this is not good solution

Command Line Arguments

config change
det_auto_rotate = true

Console logs

[local] Running in local mode
[local] Loading models
[local] Running text detection
[DefaultDetector] Adding border
[DefaultDetector] Detection resolution: 1536x1536
[DefaultDetector] Rerunning detection with 90° rotation
[DefaultDetector] Adding rotation
[DefaultDetector] Adding border
[DefaultDetector] Detection resolution: 1536x1536
[local] Running ocr
ERROR: [local] error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:3376: error: (-215:Assertion failed) _src.total() > 0 in function 'cv::warpPerspective'
Traceback (most recent call last):
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\__main__.py", line 94, in <module>
    asyncio.run(dispatch(args))
  File "C:\Users\eren-\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\__main__.py", line 56, in dispatch
    await translator.translate_path(path, dest, args_dict)
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\mode\local.py", line 115, in translate_path
    raise e
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\mode\local.py", line 111, in translate_path
    if await self.translate_file(file_path, output_dest, params, config):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\mode\local.py", line 140, in translate_file
    return await self._translate_file(path, dest, config, ctx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\mode\local.py", line 183, in _translate_file
    ctx = await self.translate(img, config)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\manga_translator.py", line 174, in translate
    result = await self._translate(config, ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\manga_translator.py", line 219, in _translate
    ctx.textlines = await self._run_ocr(config, ctx)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\manga_translator.py", line 330, in _run_ocr
    textlines = await dispatch_ocr(config.ocr.ocr, ctx.img_rgb, ctx.textlines, config.ocr, self.device, self.verbose)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\ocr\__init__.py", line 39, in dispatch
    return await ocr.recognize(image, regions, config, verbose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\ocr\common.py", line 46, in recognize
    return await self._recognize(image, textlines, config, verbose)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\ocr\common.py", line 57, in _recognize
    return await self.infer(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\utils\inference.py", line 350, in infer
    return await self._infer(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\ocr\model_48px.py", line 72, in _infer
    region_imgs = [q.get_transformed_region(image, d, text_height) for q, d in quadrilaterals]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\manga_translator\utils\generic.py", line 508, in get_transformed_region
    region = cv2.warpPerspective(img_croped, M, (w, h))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.10.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:3376: error: (-215:Assertion failed) _src.total() > 0 in function 'cv::warpPerspective'
@eren-ay eren-ay added the bug Something isn't working label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant