OCR Time stamp extraction with complex background

Viewed 316

Here is an image cut from CCTV video and I would like to extract the time stamp from the snapshot. OpenCV/Tesseract/python are the tools for this job: a cctv snapshot with complex background

the difficulty here is the complex background so that even I binarize the picture with a median filer (opencv) and the ocr result is still very bad. Of course, I can apply specific customized thresholds but here I got 2 issues:

  1. how can I handle the characters with both white and black?
  2. Is there a way (some ways) to give a more general thresholds for these kinds of picture?

Maybe my idea for handling the pre-processing here is not correct. It seems not an easy job to pre-process this kind of image before sending into Tesseract. Any hints and idea is thankful.

1 Answers
  1. Do the tresholding two times, once normally for white pixels above 254, and once on a inverted picture: img = cv2.bitwise_not(img) , then merge the two results

  2. There is an inRange function in OpenCV, where you can set min/max HSV values. Create a function with this with input arguments of the HSV values, record the values in lists, then iterate with a for cycle the masking+merging

Related