스마트폰은 애니메이션에서 수치를 식별해 보았다(전편)
12665 단어 Python3tesseract-ocr기계 학습pyocr
입문
스마트폰(본업은 시스템 엔지니어)은 스마트폰의 애니메이션에서 캐릭터가 입은 상처를 식별해 도표에 묘사하는 것을 만들었다.스마브라의 환율 대전에서는 VIP(상위 3%)였지만 시스템 엔지니어로는 반 VIP(후 3%)였다.(특히 머신러닝이 최근 시작되었다)
단축이 어렵기 때문에 전편, 후편으로 나뉜다.
Tesseract OCR을 사용한 캐릭터 이름과 손상 식별에 대한 설치
뒷편에는 OpenCV를 사용한 손상(숫자)의 윤곽 추출과 기계 학습을 이용한 손상 식별 설치를 쓰려고 합니다.
첫 투고였기 때문에 나는 주도면밀하지 못한 부분이 있다고 생각한다.
질문이 있으면 댓글로 남겨주세요(따끔한 질책도 기다리고 있습니다!!:D)
만든 물건
다음 화면(애니메이션 파일) 아래에 표시된 손상을 식별하여 도표에 묘사합니다.
Input
Output
개발 환경
OS :Windows10 Home 64 bit
언어: Python 3.7.4
편집기: 능동 1.40.0
소스 코드 관리: Github
실시 車輪の再発明はするな by えらいひと
이렇게 하기 어려우면 Qiita가 어디에 있는지 먼저 개원에서 이미지에서 문자를 식별할 수 있는 것을 찾아서 처음에 발견된'Tesseract OCR'을 사용해 봤다.
tesseract
Windows를 사용하기 때문에 아래 기사를 참고하여 설치했습니다.
Tesseract OCR의 시작 방법
pyocr
Tesseract OCR 자체는 하나의 도구(OCR)와 같아서 그림을 입력할 때 문자열을 되돌려줍니다. 원래의 상태를 유지하면 Python에서 이동할 수 없습니다.
따라서 pyocr를 설치하여python에서 OCR을 이동합니다.
설치는 간단합니다. 아래와 같이 pip 명령을 누르기만 하면 됩니다.
명령 프롬프트pip install pyocr
설치가 끝난 후 실제python에서 작동합니다.
※ 제 환경에서 환경 변수를 다루지 않으면pyocr는Tesseract를 잘 식별할 수 없기 때문에 아래 기사를 참고하여 환경 변수를 추가했습니다.
tesseract에서OCR@Windows7
캐릭터 이름(알파벳)의 식별
sample.pyimport pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# input image file
root_dir = os.path.split(__file__)[0]
image_luci = os.path.join(root_dir, 'data/lucina.png')
image_bayo = os.path.join(root_dir, 'data/bayonetta.png')
image = cv2.imread(image_luci, 0)
lucina = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_bayo, 0)
bayonetta = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:BAYONETTA 実行結果:{}'.format(bayonetta))
print('期待値:LUCINA 実行結果:{}'.format(lucina))
Input
Output
期待値:BAYONETTA 実行結果:BAYONETTA
期待値:LUCINA 実行結果:LUCINA
[Finished in 0.714s]
캐릭터명을 식별하면 실용적일 것 같다.
그럼 관건적인 상처에 대한 인식은 어떨까요?
데미지(수치)의 식별
sample.pyimport pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# read image file
root_dir = os.path.split(__file__)[0]
image_135_5 = os.path.join(root_dir, 'data/135_5.png')
image_6 = os.path.join(root_dir, 'data/6.png')
image = cv2.imread(image_135_5, 0)
damage_135_5 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_6, 0)
damage_6 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:135.5 実行結果:{}'.format(damage_135_5))
print('期待値:135.5 実行結果:{}'.format(damage_6))
Input
Output
期待値:135.5 実行結果:
期待値:6 実行結果:GB
[Finished in 0.712s]
결론
캐릭터 이름 식별에는 배경이 회색이기 때문에 Tesseract가 유용하다
상처에 대한 인식에서 배경은 게임 배경의 영향이 상당히 커서 어려워 보인다.
자세한 내용은 다음 기사에 쓰고, 우선 배경의 정보량을 줄일 필요가 있다.
(온갖 시도를 거쳐 기계를 배웠는데...)
Reference
이 문제에 관하여(스마트폰은 애니메이션에서 수치를 식별해 보았다(전편)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/cmadayo/items/d0e475c11dbb12eff6dc
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
다음 화면(애니메이션 파일) 아래에 표시된 손상을 식별하여 도표에 묘사합니다.
Input
Output
개발 환경
OS :Windows10 Home 64 bit
언어: Python 3.7.4
편집기: 능동 1.40.0
소스 코드 관리: Github
실시 車輪の再発明はするな by えらいひと
이렇게 하기 어려우면 Qiita가 어디에 있는지 먼저 개원에서 이미지에서 문자를 식별할 수 있는 것을 찾아서 처음에 발견된'Tesseract OCR'을 사용해 봤다.
tesseract
Windows를 사용하기 때문에 아래 기사를 참고하여 설치했습니다.
Tesseract OCR의 시작 방법
pyocr
Tesseract OCR 자체는 하나의 도구(OCR)와 같아서 그림을 입력할 때 문자열을 되돌려줍니다. 원래의 상태를 유지하면 Python에서 이동할 수 없습니다.
따라서 pyocr를 설치하여python에서 OCR을 이동합니다.
설치는 간단합니다. 아래와 같이 pip 명령을 누르기만 하면 됩니다.
명령 프롬프트pip install pyocr
설치가 끝난 후 실제python에서 작동합니다.
※ 제 환경에서 환경 변수를 다루지 않으면pyocr는Tesseract를 잘 식별할 수 없기 때문에 아래 기사를 참고하여 환경 변수를 추가했습니다.
tesseract에서OCR@Windows7
캐릭터 이름(알파벳)의 식별
sample.pyimport pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# input image file
root_dir = os.path.split(__file__)[0]
image_luci = os.path.join(root_dir, 'data/lucina.png')
image_bayo = os.path.join(root_dir, 'data/bayonetta.png')
image = cv2.imread(image_luci, 0)
lucina = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_bayo, 0)
bayonetta = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:BAYONETTA 実行結果:{}'.format(bayonetta))
print('期待値:LUCINA 実行結果:{}'.format(lucina))
Input
Output
期待値:BAYONETTA 実行結果:BAYONETTA
期待値:LUCINA 実行結果:LUCINA
[Finished in 0.714s]
캐릭터명을 식별하면 실용적일 것 같다.
그럼 관건적인 상처에 대한 인식은 어떨까요?
데미지(수치)의 식별
sample.pyimport pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# read image file
root_dir = os.path.split(__file__)[0]
image_135_5 = os.path.join(root_dir, 'data/135_5.png')
image_6 = os.path.join(root_dir, 'data/6.png')
image = cv2.imread(image_135_5, 0)
damage_135_5 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_6, 0)
damage_6 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:135.5 実行結果:{}'.format(damage_135_5))
print('期待値:135.5 実行結果:{}'.format(damage_6))
Input
Output
期待値:135.5 実行結果:
期待値:6 実行結果:GB
[Finished in 0.712s]
결론
캐릭터 이름 식별에는 배경이 회색이기 때문에 Tesseract가 유용하다
상처에 대한 인식에서 배경은 게임 배경의 영향이 상당히 커서 어려워 보인다.
자세한 내용은 다음 기사에 쓰고, 우선 배경의 정보량을 줄일 필요가 있다.
(온갖 시도를 거쳐 기계를 배웠는데...)
Reference
이 문제에 관하여(스마트폰은 애니메이션에서 수치를 식별해 보았다(전편)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/cmadayo/items/d0e475c11dbb12eff6dc
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
車輪の再発明はするな by えらいひと
이렇게 하기 어려우면 Qiita가 어디에 있는지 먼저 개원에서 이미지에서 문자를 식별할 수 있는 것을 찾아서 처음에 발견된'Tesseract OCR'을 사용해 봤다.
tesseract
Windows를 사용하기 때문에 아래 기사를 참고하여 설치했습니다.
Tesseract OCR의 시작 방법
pyocr
Tesseract OCR 자체는 하나의 도구(OCR)와 같아서 그림을 입력할 때 문자열을 되돌려줍니다. 원래의 상태를 유지하면 Python에서 이동할 수 없습니다.
따라서 pyocr를 설치하여python에서 OCR을 이동합니다.
설치는 간단합니다. 아래와 같이 pip 명령을 누르기만 하면 됩니다.
명령 프롬프트
pip install pyocr
설치가 끝난 후 실제python에서 작동합니다.※ 제 환경에서 환경 변수를 다루지 않으면pyocr는Tesseract를 잘 식별할 수 없기 때문에 아래 기사를 참고하여 환경 변수를 추가했습니다.
tesseract에서OCR@Windows7
캐릭터 이름(알파벳)의 식별
sample.py
import pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# input image file
root_dir = os.path.split(__file__)[0]
image_luci = os.path.join(root_dir, 'data/lucina.png')
image_bayo = os.path.join(root_dir, 'data/bayonetta.png')
image = cv2.imread(image_luci, 0)
lucina = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_bayo, 0)
bayonetta = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:BAYONETTA 実行結果:{}'.format(bayonetta))
print('期待値:LUCINA 実行結果:{}'.format(lucina))
Input
Output
期待値:BAYONETTA 実行結果:BAYONETTA
期待値:LUCINA 実行結果:LUCINA
[Finished in 0.714s]
캐릭터명을 식별하면 실용적일 것 같다.그럼 관건적인 상처에 대한 인식은 어떨까요?
데미지(수치)의 식별
sample.py
import pyocr
import cv2
import os
import sys
from PIL import Image
# read OCR tools
tools = pyocr.get_available_tools()
if len(tools) == 0:
print("No OCR tool found")
sys.exit(1)
# select pyocr.tesseract
tool = tools[0]
# read image file
root_dir = os.path.split(__file__)[0]
image_135_5 = os.path.join(root_dir, 'data/135_5.png')
image_6 = os.path.join(root_dir, 'data/6.png')
image = cv2.imread(image_135_5, 0)
damage_135_5 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
image = cv2.imread(image_6, 0)
damage_6 = tool.image_to_string(
Image.fromarray(image),
builder=pyocr.builders.TextBuilder(tesseract_layout=6)
)
# output
print('期待値:135.5 実行結果:{}'.format(damage_135_5))
print('期待値:135.5 実行結果:{}'.format(damage_6))
Input
Output
期待値:135.5 実行結果:
期待値:6 実行結果:GB
[Finished in 0.712s]
결론
캐릭터 이름 식별에는 배경이 회색이기 때문에 Tesseract가 유용하다
상처에 대한 인식에서 배경은 게임 배경의 영향이 상당히 커서 어려워 보인다.
자세한 내용은 다음 기사에 쓰고, 우선 배경의 정보량을 줄일 필요가 있다.
(온갖 시도를 거쳐 기계를 배웠는데...)
Reference
이 문제에 관하여(스마트폰은 애니메이션에서 수치를 식별해 보았다(전편)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/cmadayo/items/d0e475c11dbb12eff6dc
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
Reference
이 문제에 관하여(스마트폰은 애니메이션에서 수치를 식별해 보았다(전편)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/cmadayo/items/d0e475c11dbb12eff6dc텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)