The invention discloses an identity card number recognition method and a device based on a natural scene. An identity card picture which is distinct and can enable the identity card number to be recognized by a
human eye is acquired through a front-end hardware device, and the hardware device can be a
mobile phone, a camera, a
scanner and the like; and through technical means such as
image processing and mode recognition, automatic extraction and recognition are carried out on the identity card number. The technical scheme is mainly as follows: the captured picture is firstly subjected to image pre-
processing, wherein the pre-
processing comprises
noise removal, image
gray level conversion, identity card boundary extraction, and image binarization; connection region searching is carried out on the
binary image after pre-
processing, and certain candidate regions with dense characters are determined to be the regions of the identity card number; local binarization processing is then carried out on each candidate region, the position of each character is acquired, and character segmentation on a
gray level image is carried out; and finally, a
deep learning method is used for recognizing each segmented character, discrimination is then carried out according to the arrangement sequence of the identity card number, the width and the height of each character and the
character recognition confidence, and a character sequence with the highest confidence level is selected as the final recognition result and is outputted.