Scanning a credit card from an image file with the Android Credit Card Scanner Module
The Scanbot SDK Credit Card Scanner can detect and extract information from still images imported from the gallery or any other source, not just live credit card detection.
Integration
You can take a look at the following example to see the Credit Card Scanner in action and to gain a comprehensive understanding of how to integrate it into your project:
Adding the feature as a dependency
CreditCardScanner is included in Scanbot SDK package 3. Therefore, add the dependency io.scanbot:sdk-package-3 or higher in your build.gradle:
implementation("io.scanbot:sdk-package-3:$latestSdkVersion")
implementation("io.scanbot:sdk-creditcard-assets:$latestSdkVersion")
Do not use multiple scanners (e.g., MRZ Scanner and Credit Card Scanner) at the same time.
Each scanner instance requires a lot of memory, GPU, and processor resources. Using multiple scanners will lead to performance issues for the entire application.
Initializing the SDK
Before use, the Scanbot SDK must be initialized. Add the following code snippet to your Application class:
loading...
Processing the image
Importing the image from the gallery
To select an image from the photo library and run detection on it, a class for an image import contract is created using the modern Android result API.
loading...
To run the gallery call and get a Bitmap using ImportImageContract, the following code is used:
loading...
Creating a scanner
loading...
Avoid creating new CreditCardScanner instances for each import operation, as this will also allocate memory for each instance.
Detection
Use the Scanbot SDK to detect the desired element on the imported image.
loading...
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get free trial license