NateScarlet / auto-derby

🐎🖥《赛马娘》(ウマ娘: Pretty Derby)辅助脚本
MIT License
464 stars 107 forks source link

OCR fails. It seems to often take the "ジ" as "シ". #12

Closed waraiotoko2501h closed 3 years ago

waraiotoko2501h commented 3 years ago

Thanks for the response the other day. The program was working fine, but the current version is failing to OCR.

OCR frequently mistakes "ジ" for "シ".

Is there something wrong with my settings? I have not changed any settings in NVIDIA Control Panel -> Manage 3D Settings. (Factory default)

Does the graphics board or Windows settings affect OCR?

TEST VERSION fed9276f2a02a770a3116211a3ce42b7bde10c9b launcher.log

screenshot_1622701278 screenshot_1622701289

If you need any other logs or screenshots, please let me know.

NateScarlet commented 3 years ago

Try add

"1800f800f801f001e0000f001ff03ff81cfc007f803fe01ffc07fe01fe001c00": "ジ"

to ocr_labels.json

waraiotoko2501h commented 3 years ago

Thanks. It worked. But immediately after, I was asked for input. I'm frequently asked to enter numbers. // The "launcher.cmd" will not prompt you for input. 2021-06-03_16h13_53

NateScarlet commented 3 years ago

This project is using a hash based OCR, so gpu setting should not be related.

For unknown reason(maybe clearType setting?) your text is rendered in different pixel value from my samples. Manually label them should work.

NateScarlet commented 3 years ago

There seems a launcher bug that not allow standard input, you can use the command line directly for now.

And if you finished the text labelling, please send a PR with updated ocr_labels.json, so others don't have to do it again.

waraiotoko2501h commented 3 years ago

I see. I understand.

Is there a best way to enter the hash manually? How did you come up with this hash?

"1800f800f801f001e0000f001ff03ff81cfc007f803fe01ffc07fe01fe001c00": "ジ"

NateScarlet commented 3 years ago

Is there a best way to enter the hash manually?

If you run py -3.8 -m auto_derby nurturing directly from a admin command prompt, you can input text in terminal.

https://github.com/NateScarlet/auto-derby/blob/fed9276f2a02a770a3116211a3ce42b7bde10c9b/auto_derby/ocr.py#L77-L82

How did you come up with this hash?

You can find it in debug log. current similarity threshold for ocr is 0.8, but has similarity 0.93 with .

NateScarlet commented 3 years ago

You can also input through launcher now, The text prompt somehow show after input, it should be show before input.

waraiotoko2501h commented 3 years ago

I've been adding the hashes manually. However, it is still very difficult to distinguish between "ジュニアクラス(junior class)" and "シニアクラス(senior class)".

2021-06-04_04h14_34 It seems that the hash of "ジ" registered for the junior class is also recognized as "ジ" for the senior class.

This may not be a good solution, but I solved it as follows. https://github.com/NateScarlet/auto-derby/blob/451e2122cb8e252c9f4f646d4e7f866576a1c338/auto_derby/single_mode/context.py#L38

    year = {
        'ジュニア級': 1,
        'シュニア級': 1,        
        'クラシック級': 2,
        'シニア級': 3,
        'ジニア級': 3,
    }[year_text]
NateScarlet commented 3 years ago

this 3800...3c00 hash not exists in my ocr_labels.json. you should just correct label data

NateScarlet commented 3 years ago

you can check image for that hash in ocr_images.local folder

waraiotoko2501h commented 3 years ago

After several attempts, adding it to ocr_labels.json alone did not solve the problem.

3800.... .3c00 hash will be similarity=1.000 for both when junior class and senior class.

"シ" or "ジ" problem is can happen with any other hash.

For both the senior and junior classes, these hashes will have similarity=1.000. In other words, if I register as "ジ" in the "ジュニア級", it will be recognized as "ジ" in the "シニア級" and you will get a Key error.

There may be others.

  "1800f800f801f001e0000f001ff03ff81cfc007f803fe01ffc07fe01fe001c00": "ジ",
  "3800f800f801f001e0010f001f703ff83cfc007e803fe01ffc0ffe01fe003c00": "ジ",
  "1800f800f801f001e0000f001ff03ff81cfe007f803fe01ffc07fe01fe001c00": "シ",
  "fc01fc01f801c0000f001f603ff83cfc10fe007fc03ff01ffc07fe01fe003c00": "シ",

I'm attaching it in case you need it. ocr.zip

I understand a little bit about how this program works, but... It seems like a difficult problem to solve. I'm going to try to find out if it's a problem with clear type text.

Thank you for your support. (My English is not very good, I apologize for that.)

NateScarlet commented 3 years ago

image

The top-right is not included in ocr image, you should not mark this as Base on given image, these hash should all be labeled as シ

Are you sure you see these hash while ジ is displaying ? Maybe image pre-processing is incorrectlly removed from image, I need a reproducable case (a screenshot that ocr recognize ジ as シ) to work on.

waraiotoko2501h commented 3 years ago

Are you sure you see these hash while ジ is displaying ?

yes. Please wait while I recreate the situation.

NateScarlet commented 3 years ago

I found the fisrt screenshot of this issue is the reproducable case, i could just run test against it

I will work on this tonight

waraiotoko2501h commented 3 years ago

P.S. The clear type text had nothing to do with it. I toggled between enabled and disabled, rebooted, and tried again, but there was no change in the hash value.

waraiotoko2501h commented 3 years ago
  1. 「シ」 2021-06-04_16h07_37

Immediately after

  1. 「゛ュ」 2021-06-04_16h09_23

screenshot screenshot_1622790467

pastelog.txt

fatinghenji commented 3 years ago

My solution to this problem:

  1. Use the mobile terminal of Google Translate, select Japanese as the original language, and output the language at will.
  2. Select handwriting input, and then find the most similar text on the screen for handwriting.
  3. Try to enter a whole sentence as much as possible.
  4. Google's intelligent error correction will complete the mistakes you may make.
  5. Use instant messaging software like discord or telegram to send the intelligently completed text to the computer.
  6. Copy and paste the corresponding text on the computer.
NateScarlet commented 3 years ago

图片

The become very blurry, image pre-processing need improve

NateScarlet commented 3 years ago

图片

resize + sharpen can solve this problem