[PYTHON] Character recognition from images! Explaining logic with 100% accuracy using PES as a theme

We will automate the data analysis of PES! part3

Hi, this is Yajun!

This article is a series, Part 3. If you like, I hope you can read it together.

  1. Part 1 article is a creation of character recognition software that extracts character data from match result images.
  2. article of part2 is to create software to graph the extracted data.

The software is written in Python. ■ Reference URL

■ Promotion

■ Introduction

"Collect more data and do a new analysis!" "Let's find a strategy for PES!"

However, a problem has greatly reduced development efficiency ...

** The accuracy of the character recognition software I created was 95%! ** **

▼ The reason why 95% accuracy is not good

Let's say you want to continue the analysis service for 10 customers for 6 months. Targeting professionals and distributors, suppose you get data for 2000 games a year.

10 people x 2000 games (1 year) x 0.5 (half a year) = 10000 games

Even if you fix a few games in one game, it will go bankrupt if it is 10,000 games. .. .. Therefore, ** 100% data extraction accuracy is a mandatory requirement. ** **

■ Goal

■ Method

▼ Method: OCR

The accuracy of OCR is composed of the following factors.

① Input data noise (2) Tool library performance ③ Operation mode ④ Noise removal from the output result

① Input data

(2) Tool library performance





③ Operation mode

If the output result is not a number, change the operation mode and re-execute.

④ Noise removal from the output result

** The result of doing this is a recognition accuracy of 95%. .. .. ** ** For those who want to see the actual output result, [■ Result](https://qiita.com/junya0001000/items/8f519cdb3846fcec397a#%E7%B5%90%E6%9E%9C--%E5%87%BA%E5 % 8A% 9B% E7% B5% 90% E6% 9E% 9C)

▼ Method: Template Matching

Does not rotate Do not distort The position of each data is unified Unified font Unified size

・ Preparation

・ Demo play

Save the data as if there is a corresponding number in the place where the frame is displayed. At that time, it is a mechanism to extract data from the image by letting you judge "which parameter number" depending on the location.

·Detection sensitivity

False positives: Judging that there is a number in a place where there is no number False negative: In fact, where the number is "yes", it is judged that the number is "no".

"Detection sensitivity" can adjust this.

"You should adjust the detection sensitivity so that both false positives and false negatives disappear!"

You might think, but it's usually not possible! The reason is that "there are often false-positive and false-negative detection sensitivity sections."

By the way, this software is swinging to the false positive side. This is because false negatives cannot be detected because the number of objects (number of numbers) is indefinite.

▼ Logic for detecting false negatives ▼ Number of numbers that should be-Number of numbers that could be detected = False negative if there is a difference

■ Results

▼ Result: Input image

▼ Result: Output result

** Achieved 100% correct answer rate! !! Wow (holiday) **

コメント 2020-02-29 181509.png

■ Conclusion

Also, software design that considers false positives / false negatives may have been a learning experience for engineers as well. I hope it helps someone.

We will continue to add functions and improve performance to the software. Stay tuned for part4!

■ Reference URL

  1. Play with Python + OpenCV (OCR)
  2. Get the number of dimensions, shape and size (total number of elements) of NumPy array ndarray
  3. Try Google Cloud Vision API
  4. Template matching
  5. Remove list (array) elements in Python
  6. How to use the abs function to find the absolute value

Recommended Posts

Character recognition from images! Explaining logic with 100% accuracy using PES as a theme
Extract characters from images using docomo's character recognition API
[Note] Using 16x2-digit character LCD (1602A) from Python with Raspberry Pi
I tried to compare the accuracy of machine learning models using kaggle as a theme.
Image recognition with API from zero knowledge using AutoML Vision