don't stop believing

OCR을 이용해 글자 찾기 본문

Testing Automation/SikuliX

OCR을 이용해 글자 찾기

Tongchun 2018. 2. 5. 11:32

OCR을 이용해 원하는 글자를 찾아 보겠습니다.


Optical character recognition (also optical character reader, OCR) is the mechanical or electronic conversion of images of typed, handwritten or printed text into machine-encoded text, whether from a scanned document, a photo of a document, a scene-photo (for example the text on signs and billboards in a landscape photo) or from subtitle text superimposed on an image (for example from a television broadcast). It is widely used as a form of information entry from printed paper data records, whether passport documents, invoices, bank statements, computerised receipts, business cards, mail, printouts of static-data, or any suitable documentation. It is a common method of digitising printed texts so that they can be electronically edited, searched, stored more compactly, displayed on-line, and used in machine processes such as cognitive computing, machine translation, (extracted) text-to-speech, key data and text mining. OCR is a field of research in pattern recognition, artificial intelligence and computer vision.


OCR을 사용하기 위해서는 SikuliX를 설치할 때 3- I want to use the Tesseract based OCR features에 체크해야 합니다.


설치가 완료되었다면 바로 확인해 보겠습니다.

dejavuqa 블로그에서 config라는 글자를 찾아 봅니다.


runsikulix.cmd를 더블클릭해 SikuliX IDE를 엽니다.

그리고 아래와 같이 작성합니다.

Ocr를 사용하려면 1번과 2번 라인처럼 Settings.OcrTextSearch와 Settings.OcrTextRead를 True로 설정해야 합니다.


몇가지 예외 되는것이 있지만 기본적으로 SikuliX 명령에 이미지가 들어가는 자리에 찾으려는 글자를 넣어주면 됩니다.


특정 위치의 글자를 인식하고 싶을 경우 Region으로 선택 후 text() 속성으로 확인할 수 있습니다.

만약 아래와 같은 게임에서 전투력이 10000 이하면 어떤 동작을 하고 이상이면 다른 동작을 시키고 싶습니다.

그럼 아래와 같이 전투력이 써진 곳을 Region으로 선택합니다. 그리고 text()속성으로 해당 영역의 글을 인식합니다.

그리고 아래와 같이 SikuliX 코드를 작성할 수 있습니다.


지금까지 확인할 결과 Windows에서는 문자의 인식률이 좋지는 않습니다. 이미지 matching과는 다르게 배경 이미지의 간섭이 심한 편입니다. 또한 한글을 읽으려면 데이터 파일을 추가해야 합니다.


인식률을 높이는 방법을 찾아봐야 할 것 같습니다.

한글을 인식하는 방법도 확인해서 올리겠습니다.


우선 OCR을 사용하는 예제는 여기까지 입니다.


Comments