-
-
Save spilist/4dfa257e81bcef84a1320d4b4197b9ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# =================================================== | |
# 16/06/10 | |
# OsX 10.11.4, Chrome, 안드로이드/아이폰 캡처 파일 둘 다 작동 확인. | |
# 컬처랜드 홈페이지 또는 식권대장 이미지 형태가 바뀌면 작동이 안될 수 있음. | |
# 사용방법 | |
# 1. tesseract를 설치한다. | |
# (mac 기준) $brew install tesseract | |
# 2. 아직 충전하지 않은 이미지 파일들을 한 폴더에 넣어놓고, 이 스크립트 파일을 같은 폴더에 넣는다. | |
# 3. 이 스크립트의 권한을 실행 가능하게 설정한다. | |
# $chmod u+x cultureland-ocr.sh | |
# 4. $./cultureland-ocr.sh로 실행한다. | |
# 5. 아래와 같이 터미널에 결과가 뜬 것을 복사한다. | |
# $('.pin_input > dd input')[0].value='4173'; | |
# $('.pin_input > dd input')[1].value='7558'; | |
# $('.pin_input > dd input')[2].value='9019'; | |
# $('.pin_input > dd input')[3].value='0271'; | |
# $('.pin_input > dd input')[4].value='4173'; | |
# $('.pin_input > dd input')[5].value='1857'; | |
# $('.pin_input > dd input')[6].value='2893'; | |
# $('.pin_input > dd input')[7].value='3065'; | |
# $('.pin_input > dd input')[8].value='4177'; | |
# $('.pin_input > dd input')[9].value='4468'; | |
# $('.pin_input > dd input')[10].value='1713'; | |
# $('.pin_input > dd input')[11].value='3534'; | |
# $('.pin_input > dd input')[12].value='4170'; | |
# $('.pin_input > dd input')[13].value='5198'; | |
# $('.pin_input > dd input')[14].value='0721'; | |
# $('.pin_input > dd input')[15].value='6903'; | |
# $('.pin_input > dd input')[16].value='4179'; | |
# $('.pin_input > dd input')[17].value='7016'; | |
# $('.pin_input > dd input')[18].value='0096'; | |
# $('.pin_input > dd input')[19].value='2263'; | |
# 6. 컬처랜드 충전 페이지에 가서 (https://www.cultureland.co.kr/mypage/cash/CashCharge_gift_small_sss.asp, 로그인 필요) | |
# 개발자 콘솔을 열고, 복사한 것을 붙여넣어서 실행한다. 16/06/10 현재 5개씩 충전된다. | |
# 7. 실행하면 번호가 안으로 들어간다. 충전하기 클릭 후 뒤로가기로 다시 충전 페이지로 돌아간다. | |
# 8. 충전 완료된 5개 이미지는 자동으로 done_images 로 들어가기 때문에 | |
# 다시 해당 폴더 안에서 $./cultureland-ocr.sh를 실행하여 나온 걸 복사해서 충전하기를 반복한다. | |
# =================================================== | |
mkdir -p temp_outputs | |
mkdir -p done_images | |
i=0 | |
for image in *.png; do | |
i=$(($i+1)) | |
tesseract "$image" "temp_outputs/$i" | |
mv "$image" "done_images/" | |
if [ "$i" -eq 5 ]; then break; fi | |
done | |
perl -nle 'print $& if m{(([0-9]){4}(\s)*){4}}' temp_outputs/*.txt > out.txt | |
tr -d ' ' < out.txt > out2.txt | |
i=0 | |
while read -r line | |
do | |
echo "\$('.pin_input > dd input')[$i].value='${line:0:4}';" | |
echo "\$('.pin_input > dd input')[$(($i+1))].value='${line:4:4}';" | |
echo "\$('.pin_input > dd input')[$(($i+2))].value='${line:8:4}';" | |
echo "\$('.pin_input > dd input')[$(($i+3))].value='${line:12:4}';" | |
i=$(($i+4)) | |
done < out2.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment