def _try_black_tophat(self, roi, cur_text, cur_mrz):
roi_b = morphology.black_tophat(roi, morphology.disk(5))
new_text = ocr(roi_b) # There are some examples where this line basically hangs for an undetermined amount of time.
new_mrz = MRZ.from_ocr(new_text)
if new_mrz.valid_score > cur_mrz.valid_score:
new_mrz.aux['method'] = 'black_tophat'
cur_text, cur_mrz = new_text, new_mrz
new_text, new_mrz = self._try_larger_image(roi_b, cur_text, cur_mrz)
if new_mrz.valid_score > cur_mrz.valid_score:
new_mrz.aux['method'] = 'black_tophat(rescaled(3))'
cur_text, cur_mrz = new_text, new_mrz
return cur_text, cur_mrz
评论列表
文章目录