Currently my company's R&D department is working on an iOS application that recognizes credit card numbers and expiration dates using a camera of a mobile device. We have successfuly completed most of the project and now working on the stage of splitting card number digits into separate blocks for further recognition. Read more to find the details: http://rnd.azoft.com/optical-recognition-ios-application/ If you have worked on similar tasks we will appreciate if you could share your approaches and the results you received.
问题:
回答1:
All credit cards I know of use a Luhn scheme, something like a checksum, so you should use that to validate numbers. The most critical numbers are on the left as they encode the brand, that then informs you of the length. That said there are exceptions that make absolute assumptions difficult. The Luhn code is going to be your best friend.
There is an iOS Credit Card Entry project that has some code with Luhn code and brand identification that should be helpful.
回答2:
1) Image quality judgement, only send the images with good quality to the next stages. Poor quality images will give you incorrect result. This will be a very bad user experience on smart phone. Many smart phones' camera have auto-focus functionality, you may only use the image when camera finish auto focusing.
2) Card detection. Detect entire card. This stage is very import, many algorithm fail to it. You can detect a card via morphological operator or other image operator. But this operator is a little bit slow on smart phone. Or you can training a cascade classifier for card detection. This detections is quicker than last method. But it's very hard to deal with general card, I mean, This method only can detect only one kind of card.
3) extract characters zone, it's very easy to get characters zone, because the numbers is be in the fix position of a specified card.
4) character segmentation, use vertical projection to do segmentation, you can get every individual digital images
5) character recognition. find connected component in each digital images, crop the images so that only contain the connected component. send the cropped images to a signal digital classifier. I tried tesseact , the result is not very bad. Maybe you can use other great digital classifiers.
6) number validation. Some cards' number have validation rules. you can utilise it.