Improving the accuracy

The code provided on Github comes with default configuration to make everyone almost happy. You may want to increase the speed our accuracy to match your use case.

Detector

This section explains how to increase the accuracy for the detection layer.

Region of interest

Unlike other applications you can find on the market we don’t define a region of interest (ROI), the entire frame is processed to look for valid credit cards. Setting a ROI could decrease the false-positives and improve the precision score without decreasing the recall value. The deep learning model used for the detection is very accurate (high precision and high recall) and should not output false-positives if you’re using the default recommended values.

Detection score threshold

The configuration section explains how to set the minimum detection score.

  • If you have too many false-positives, then increase the detection score in order to increase the precision.

  • If you have too many false-negatives, then decrease the detection score in order to increase the recall.

Matching training data

The training data for the detection predominantly contains credit cards with clear borders. To increase the detection accuracy you should provide images showing the entire credit card: borders, chip and payment network (Visa, MasterCard, AMEX…) logo included.

For example, detecting credit card on the next image will be done with the highest accuracy possible (99.99%):

Complete card

Complete card

While detecting the credit card on the next image will be done with very low accuracy or even fail:

Partial card

Partial card

The fact that the training data predominantly contains images showing the entire credit card while there are few images with partial cards is done on purpose to decrease the number of false-positives.

Recognizer

This section explains how to increase the accuracy for the recognizer layer.

Data validation

For every JSON result returned by the SDK you will have a boolean field ("valid") defining whether the credit card number is correct based on the check digit. The validation process is done using Luhn algorithm. You can safely stop the processing when this boolean field is equal to true.

Adding rectification layer

When the credit cards are highly distorted (skewed and/or slanted) you’ll need to activate the rectification layer to remove the distortion. The configuration section explains how to activate the rectification layer.

Check the section about rectification for more info about this feature.

Recognition score threshold

The configuration section explains how to set the minimum recognition score.

  • If you have too many false-positives, then increase the detection score in order to increase the precision.

  • If you have too many false-negatives, then decrease the detection score in order to increase the recall.

Restrictive score type

The configuration section explains the different supported score types: “min”, “mean”, “median”, “max” and “minmax”.

  • The “min” score type is the more restrictive one as it ensures that every character on the credit card have at least the minimum target score.

  • The “max” score type is the less restrictive one as it only ensures that a least one of the characters on the credit card have the minimum target score.

  • The “median” score type is a good trade-off between the “min” and “max” types.

We recommend using “min” score type. See the configuration section for more info on how to set the score type.