Python + OpenCV: OCR Image Segmentation

后端 未结 4 823
名媛妹妹
名媛妹妹 2021-01-30 11:56

I am trying to do OCR from this toy example of Receipts. Using Python 2.7 and OpenCV 3.1.

Grayscale + Blur + External Edge Detection + Segmentation of each area

4条回答
  •  后悔当初
    2021-01-30 12:17

    The option on the top of my head requires the extractions of 4 corners of the skewed image. This is done by using cv2.CHAIN_APPROX_SIMPLE instead of cv2.CHAIN_APPROX_NONE when finding contours. Afterwards, you could use cv2.approxPolyDP and hopefully remain with the 4 corners of the receipt (If all your images are like this one then there is no reason why it shouldn't work).

    Now use cv2.findHomography and cv2.wardPerspective to rectify the image according to source points which are the 4 points extracted from the skewed image and destination points that should form a rectangle, for example the full image dimensions.

    Here you could find code samples and more information: OpenCV-Geometric Transformations of Images

    Also this answer may be useful - SO - Detect and fix text skew

    EDIT: Corrected the second chain approx to cv2.CHAIN_APPROX_NONE.

提交回复
热议问题