I am a beginner in OpenCV, and am trying to extract numbers from a dataset of images and use the extracted numbers as a dataset for NN. For this, I'm using mser's bounding boxes and then cropping the image in size of the bounding box. but mser is not detecting the text area correctly. Please help me on how to do it more precisely. here is my code:
mser = cv2.MSER_create(_delta = 1)
msers, bbs = mser.detectRegions(gray)
Here bbs are the list of bounding boxes, they are not on the text area, not even one.
Image of the ground truth, where the bounding box should be:
Bounding box by mser:
Another example of the bounding box by mser:




If you want to detect text on an image, I use Tesseract to accomplish this. You just link it a tessdata file to the language you are using, and it should detect the text in the image and output it as a string. However, if you want to crop the original image further before you detect text on an image, you could use blob detection. Blob detection is where an image is passed through a variety of different image thresholds, and it looks for consistency, and if consistency is found, a blob is created at that region. You could use blob detection in this situation, then create your bounding rectangles off of those blobs.