Monday, 13 April 2015

Selenium with OCR Technology for Image Verification With Text

Agenda for this blog:To discuss the verification of IMAGE in Selenium c# with the OCR technology.

What is OCR:Optical character recognition (OCR) is the mechanical or electronic conversion of images of typewritten or printed text into machine-encoded text.It is a common method of digitizing printed texts so that it can be electronically edited, searched, stored more compactly, displayed on-line, and used in machine processes.

Where and When OCR technology is required for Selenium:

When we are automating our application with Selenium and C# as a language.There  might be some scenario where we need to verify images,In this type of situation tampering images won't give good result,and also Selenium c# is not that much compatible with SIKULI which does a decent job for Selenium JAVA in this kind of image processing/verification etc etc. There OCR technology comes in to the picture which serves the purpose well.

What we can Do with OCR:
We can extract text from the images and can verify the same from our Selenium C# application Under test.

HOW:
           We need to download the required image locally and perform the action in following two ways:

A. Using "https://www.newocr.com/" we can upload the image and can extract the text from the image.

B. Using "tesseract-ocr"  we can achieve the purpose very well.


What is Tesseract-Ocr:

Tesseract is probably the most accurate open source OCR engine available. Combined with the Leptonica Image Processing Library it can read a wide variety of image formats and convert them to text in over 60 languages.

How: We need to install tesseract-ocr in our system and through cmd prompt we can extract text from the image.



Visit for More Automation Related Discussion:

https://www.youtube.com/channel/UCKSk4gkmO3LXcW17hFUkmcQ/videos






5 comments:

  1. Nice dude. But how to compare the image size and pixels ?

    ReplyDelete
    Replies
    1. Hi Dollar ,

      Thanks....
      We generally verify the Image Text ,but we usually don't go with Pixel,Colors,fonts because its not consistent/stable approach as if the pixel changes the verification would fail,as it would treat it as a different image.

      Delete
  2. I find a free online ocr to extract text from image online, it's using google tesseract ocr 3.02.

    ReplyDelete
    Replies
    1. Hello Buyi Wen,

      Yes we can use some free online resources to extract the text but we may not be able to use the free online stuffs as there might be sometimes security/privacy reason for the application data,so in that case we can go with the concept I discussed here.

      Thanks

      Delete
  3. For far better results you can use MICROSOFT COMPUTER VISION API for OCR, it’s free for 5000 hits per month and 20 hits per minute but provides best results than others.

    Below is the link to the api
    https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc

    you can use the sample code from the API usage code for JAVA/JS etc.
    which is available below on the given above link web page and try to use the HTTP client latest maven dependency for JAVA.

    ReplyDelete