์ ํด์ด๋ฏธ์ง๋ฅผ ํ๋ณํด์ผํ๋๋ฐ
์ฒ์์๋ ์ผํ์ด๋ฏธ์ง๋ ์์ธํ์ด๋ฏธ์ง๋ฅผ ํ๋ณํ๋ ๋ชจ๋ธ์ ๋ง๋ค์์๋ค.
๋ง๋ค๊ณ ๋์ ์ดํ ๋ด์์ ์ด์ ์ ๊ด๊ณ ๋ก ํ๋จ๋์ด
์ญ์ ๋์๋ ์ด๋ฏธ์ง๋ฅผ ๊ฐ์ง๊ณ ์์ ํ ์คํธ๋ฅผ ํด๋ณด์๋ค.
ํ์ง๋ง ์ค์ ๋ก ์ดํ์์๋ ๊ทธ๋ฐ ๊ฒฝ์ฐ๋ ๋ง์ด ์๊ณ ๊ธ์๋ก ๊ด๊ณ ํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง์๋ค.
๊ทธ๋์ ์ฐ์ ๊ธ์๋ก ๊ด๊ณ ํ๋ ๊ฒ์๋ฌผ์ ์ก๋ ๋ก์ง์ ๊ฑฐ์น๋ ค๊ณ ํ๋ค.
๋ด๊ฐ ์๊ฐํ ๋ฐฉ๋ฒ์ ๋จผ์ OCR์ ํตํด์ ๊ธ์๋ฅผ ์ถ์ถํ๊ณ ๊ธ์๊ฐ ์๋ค๋ฉด
ํํ์ ๋ถ์์ ํตํด ํค์๋๋ฅผ ์ถ์ถํ์ฌ ๋ก์ง์ ํตํด ๊ด๊ณ ์ฑ ๊ธ์ด ๋ค์ด๊ฐ๋์ง ํ๋ณํ๋ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.
๋ด๊ฐ ์๊ฐํ ์๊ณ ๋ฆฌ์ฆ์ธ๋ฐ ์ฐ์ ์ ํด์ด๋ฏธ์ง์ ๋ํด ์ ์ํ์๊ณ ๋ฌด๋ฃ OCR๋ฅผ ๋จผ์ ์ฌ์ฉํด๋ณด์๋ค.
1. tesseract
tesseract๋ ๊ฒ์ํ์๋ ๊ฐ์ฅ ๋จผ์ ๋์จ ํ์ด์ฌ OCR ๋ผ์ด๋ธ๋ฌ๋ฆฌ์๋ค.
pip install pytesseract
๋จผ์ ํ ์๋ ํธ๋ฅผ installํ์ฌ ์ฌ์ฉํ๋๋ฐ ์๋ฌ๊ฐ ๋์๋ค.
import pytesseract
import numpy as np
from PIL import Image
def image2text(filename):
image = np.array(Image.open(filename))
return pytesseract.image_to_string(image)
print(image2text('test.png'))
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH. See README file for more information.
์ ์๋ ๊น ๋ ๊ฒ์ํ์ฌ ๋ณด๋ ๊ทธ๋ฅ ๋ชจ๋๋ง pip๋ก ๋ค์ด๋ก๋ํ๋ฉด ์๋๊ณ ์ํํธ์จ์ด๋ฅผ ๋ค์ด๋ฐ์์ผ ํ๋ค๊ณ ํ๋ค.
Home
Tesseract Open Source OCR Engine (main repository) - UB-Mannheim/tesseract
github.com
์ฌ๊ธฐ์ ์๋์ฐ ๋ฒ์ ์ ๋ค์ด๋ก๋๋ฐ๊ณ ์ฝ๋๋ฅผ ์ถ๊ฐํ์ฌ ๋ค์ ํด๋ณด์๋ค.
import numpy as np
import pytesseract
from PIL import Image
def image2text(filename):
image = np.array(Image.open(filename))
pytesseract.pytesseract.tesseract_cmd = R'C:\\Program Files\\Tesseract-OCR\\\tesseract'
return pytesseract.image_to_string(image)
print(image2text('test.png'))
"""
| ego 12) vipat &
hitpe://bem2 set
"""
๊ทธ๋ฐ๋ฐ ํ๊ธ๋ ์ ๋ถ ์์ด๋ก ์ธ์ํ๊ณ ์ธ์๋ฅ ์๋ ๋ฌธ์ ๊ฐ ์์๋ค.
๊ทธ๋๋ ํ๊ธ๋ ์ธ์์ ํด๋ด์ผํด์
return pytesseract.image_to_string(image, lang='kor')
lang์ ์ถ๊ฐํ์ฌ์ ์คํํด๋ณด์๋๋ฐ ์ด๋ฒ์๋ ํ๊ธ์ด ์๋ค๊ณ ์๋ฌ๊ฐ ๋์๋ค.
pytesseract.pytesseract.TesseractError: (1, 'Error opening data file C:\\Program Files\\Tesseract-OCR/tessdata/kor.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata"
directory. Failed loading language \'kor\' Error opening data file /home/debian/src/github/tesseract-ocr/tesseract/bin/ndebug/x86_64-w64-mingw32-5.0.0-alpha.20210506/usr/x86_64-w64-mingw32/share/tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language \'eng\' Tesseract couldn\'t load any languages! Could not initialize tesseract.')
๋ ๊ฒ์์ ํตํด์ kor ๋ฒ์ ์ด ์๋ค๊ณ ์๊ฒ ๋์๊ณ , github์์ ๋ค์ด๋ก๋ํ๋ค.
GitHub - tesseract-ocr/tessdata: Trained models with support for legacy and LSTM OCR engine
Trained models with support for legacy and LSTM OCR engine - GitHub - tesseract-ocr/tessdata: Trained models with support for legacy and LSTM OCR engine
github.com
๋ค์ด๋ก๋ ๋ฐ๊ณ kor ๋ฒ์ ์ ์ถ๊ฐ์์ผ์ฃผ์๋ค.
import numpy as np
import pytesseract
from PIL import Image
def image2text(filename):
image = np.array(Image.open(filename))
pytesseract.pytesseract.tesseract_cmd = R'C:\\Program Files\\Tesseract-OCR\\\tesseract'
return pytesseract.image_to_string(image, lang='kor+eng')
print(image2text('test.png'))
"""
. ๋ฉ๊ณ7๋ฌด182 20์ฌ๋น์ค
1ํ์ธ์ฌ์
"""
์ง์ง ํ๋ค๊ฒ ์ฐพ์๊ฐ๋ฉด์ ํ๋๋ฐ ์ ๋๋ก ๋์ค๋๊ฒ ์์ด์ ํํํ๋ค.
๊ทธ๋์ ๋ค๋ฅธ ocr์ ์ฐพ์๋ณด์๋๋ฐ easyocr์ด๋ผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐพ์๋ค.
ํ์ง๋ง ์ด๊ฑด ๋ฒ์ ๋ฌธ์ ์ ๊ธฐํ ์๋ฌ๋ก ์ธํด ์ฌ์ฉํ์ง ์์๋ค.
2. NAVER CLOUD OCR
NAVER CLOUD PLATFORM
cloud computing services for corporations, IaaS, PaaS, SaaS, with Global region and Security Technology Certification
www.ncloud.com
๋ค์ด๋ฒ์์ ํ ์คํธ๋ฅผ ํด๋ณด์๋๋ ์๋์ ์ฌ์ฉํด๋ณด์์ผ๊ฒ ๋ค๊ณ ์๊ฐํ๋ค.
๊ฒฐ๋ก ๋ถํฐ ๋งํ๋ฉด ๊ต์ฅํ ์ฐ๊ธฐ ๊ท์ฐฎ๊ฒ ๋ง๋ค์ด๋์๊ณ , API์ AI๊ธฐ๋ฅ์ ๋ถ๋ฆฌ์์ผ๋์์
์๊ธ์ ๋ถ์ฐ์์ผ๋์์ ๊ณ์ฐ์ด ์ ์๋๊ฒ ํด๋์๋ค.
๋จผ์ ์ด์ฉ์ ์ฒญํ๊ธฐ๋ฅผ ๋๋ฅด๋ฉด ์ฝ์๋ก ๊ฐ์ง๋ค.
๋๋ฌด ๋ด์ฉ์ด ๊ธธ์ด์ ธ์ (2)์์ ๊ณ์ ์ฐ๋ ค๊ณ ํ๋ค.
ํ์ด์ฌ ๊ฐ์ข OCR ์ฌ์ฉํด๋ณด๊ธฐ ๋ฐ ๋ค์ด๋ฒ ํด๋ผ์ฐ๋ AI OCR ์ฌ์ฉ๋ฒ (2)
ํ์ด์ฌ ๊ฐ์ข OCR ์ฌ์ฉํด๋ณด๊ธฐ ๋ฐ ๋ค์ด๋ฒ ํด๋ผ์ฐ๋ AI OCR ์ฌ์ฉ๋ฒ (1) ์ ํด์ด๋ฏธ์ง๋ฅผ ํ๋ณํด์ผํ๋๋ฐ ์ฒ์์๋ ์ผํ์ด๋ฏธ์ง๋ ์์ธํ์ด๋ฏธ์ง๋ฅผ ํ๋ณํ๋ ๋ชจ๋ธ์ ๋ง๋ค์์๋ค. ๋ง๋ค๊ณ ๋์ ์ดํ ๋ด์์ ์ด
beomcoder.tistory.com
'๐๐ฎ๐ฉ๐๐ค๐ฃ > ๐ผ๐๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋์ค์ฝ๋ ๋ด] ๋กค ์ ์ ๊ฒ์๊ธฐ๋ฅ ๋ง๋ค๊ธฐ - 1 (0) | 2024.03.17 |
---|---|
ํ์ด์ฌ ๊ธฐ์์ฒญ ๋จ๊ธฐ์๋ณด API ์ฌ์ฉํด๋ณด๊ณ ํ์ฉํ๊ธฐ (0) | 2023.02.20 |
ํ์ด์ฌ์ผ๋ก ๊ธฐ์์ฒญ ์ผ๊ธฐ์๋ณด์ ๋ ์จ API ์ฌ์ฉํ๊ธฐ (0) | 2023.02.18 |
koGPT, openAI GPT3 ์ฌ์ฉํด๋ณด๊ธฐ (chat gpt3, dall-e) (0) | 2023.02.13 |
์นด์นด์ค API 'Karlo', stable diffusion ์ฌ์ฉํด๋ณด๊ธฐ (0) | 2023.02.12 |
๋๊ธ