This code should live in the OCR module.