I have written a program to extract text out of a given image to validate if the image contains the data we are looking for. I have used PyTesseract which is a Python wrapper of Tesseract OCR library and Python Imaging Libray (PIL) in image_to_text.py.
To run this program,
$python3 image_to_text.py test3.png
and then
$python3 isvalid.py output.txt