Based on this excellent post, but using only C++ and OpenCV. No additional dependencies. Some image pre-processing steps were also added.
./scanner images/ticket.JPG
If you have questions, contact Mariusz Ryndzionek at:
mryndzionek@gmail.com