UltimateCreditCard SDK Save

Bank credit card deep layout analysis, fields extraction and recognition/OCR (ScanToPay) using deep learning

Project README

This is a state-of-the-art DeepLayout Analysis implementation based on Tensorflow to accurately detect, qualify, extract and recognize/OCR every field from a bank credit card using a single image: Number, Holder's name, Validity, Company...

Our implementation works with all cards (credit, debit, travel, prepaid, corporate...) from all payment networks (Visa, MasterCard, American Express, RuPay, Discover...).

Both Embossed and UnEmbossed formats are supported.

Unlike other implementations we're not doing brute force OCR (trying multiple images/parameters until match). You only need a single image to get the correct result. There is no template matching which means the data could be malformed or at any position and you'll still have the correct result (WYSIWYG).

Next video (https://youtu.be/BBI_3AJIc1c) shows CCardVideoRecognizer sample Running on Android:
CCardVideoRecognizer Running on Android


You can reach 100% precision on the credit card number recognition using validation process.

The number of use cases in FinTech industry are countless: Scan To Pay, Helping visually impaired users, Online shopping speed-up, payment forms auto-filling, better user experience, reducing typing errors, process automation...

Don't take our word for it, come check our implementation. No registration, license key or internet connection is required, just clone the code and start coding/testing. Everything runs on the device, no data is leaving your computer. The code released here comes with many ready-to-use samples for Android, Raspberry Pi, Windows and Linux to help you get started easily.

You can also check our online cloud-based implementation (no registration required) to check out the accuracy and precision before starting to play with the SDK.

Please check full documentation at https://www.doubango.org/SDKs/credit-card-ocr/docs/

Getting started

The SDK works on many platforms and comes with support for many programming languages but the next sections focus on Android and Raspberry pi.

Android

The next sections are about Android and Java API.

Sample applications (Android)

The source code comes with #2 Android sample applications: Benchmark and CCardVideoRecognizer.

Benchmark (Android)

This application is used to check everything is ok and running as fast as expected. The information about the maximum frame rate (27fps) on Snapdragon 855 devices could be checked using this application. It's open source and doesn't require registration or license key.

CCardVideoRecognizer (Android)

This application should be used as reference code by any developer trying to add ultimateCreditCard to their products. It shows how to detect and recognize credit cards in realtime using live video stream from the camera.


CCardVideorecognizer sample application on Android

Trying the samples (Android)

To try the sample applications on Android:

  1. Open Android Studio and select "Open an existing Android Studio project" alt text

  2. Navigate to ultimateCreditCard-SDK/samples, select android folder and click OK alt text

  3. Select the sample you want to try (e.g. ccardvideorecognizer) and press run. alt text

Adding the SDK to your project (Android)

The SDK is distributed as an Android Studio module and you can add it as reference or you can also build it and add the AAR to your project. But, the easiest way to add the SDK to your project is by directly including the source.

In your build.gradle file add:

android {

      # This is the block to add within "android { } " section
      sourceSets {
         main {
             jniLibs.srcDirs += ['path-to-your-ultimateCreditCard-SDK/binaries/android/jniLibs']
             java.srcDirs += ['path-to-your-ultimateCreditCard-SDK/java/android']
             assets.srcDirs += ['path-to-your-ultimateCreditCard-SDK/assets/models']
         }
      }
}

Using the Java API (Android)

It's hard to be lost when you try to use the API as there are only 3 useful functions: init, process and deInit.

The C++ API is defined here.


	import org.doubango.ultimateAlpr.Sdk.ULTCCARD_SDK_IMAGE_TYPE;
	import org.doubango.ultimateAlpr.Sdk.UltCreditCardSdkEngine;
	import org.doubango.ultimateAlpr.Sdk.UltCreditCardSdkResult;

	final static String CONFIG = "{" +
		"\"debug_level\": \"info\"," + 
		"\"gpgpu_enabled\": true," + 

		"\"detect_minscore\": 0.5," + 
		"\"detect_quantization_enabled\": true," + 

		"\"recogn_score_type\": \"min\"," + 
		"\"recogn_minscore\": 0.2," + 
		"\"recogn_rectify_enabled\": false," + 
		"\"recogn_quantization_enabled\": true" + 
	"}";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Initialize the engine
		assert UltCreditCardSdkEngine.init(
				getAssets(),
				CONFIG
		).isOK();
	}

	// Camera listener: https://developer.android.com/reference/android/media/ImageReader.OnImageAvailableListener
	final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() {

		@Override
		public void onImageAvailable(ImageReader reader) {
				try {
				    final Image image = reader.acquireLatestImage();
				    if (image == null) {
				        return;
				    }

				    // Credit card detection and recognition
				    final Image.Plane[] planes = image.getPlanes();
				    final UltCreditCardSdkResult result = UltCreditCardSdkEngine.process(
				        ULTCCARD_SDK_IMAGE_TYPE.ULTCCARD_SDK_IMAGE_TYPE_YUV420P,
				        planes[0].getBuffer(),
				        planes[1].getBuffer(),
				        planes[2].getBuffer(),
				        image.getWidth(),
				        image.getHeight(),
				        planes[0].getRowStride(),
				        planes[1].getRowStride(),
				        planes[2].getRowStride(),
				        planes[1].getPixelStride()
				    );
				    assert result.isOK();

				    // The result contains JSON string to parse in order to get recognitions
				    // result.json();

				    image.close();

				} catch (final Exception e) {
				   e.printStackTrace();
				}
		}
	};

	@Override
	public void onDestroy() {
		// DeInitialize the engine
		assert UltCreditCardSdkEngine.deInit().isOK();

		super.onDestroy();
	}

Again, please check the sample applications for Android and Raspberry Pi and full documentation for more information.

Raspberry Pi (Raspbian OS), Linux, Windows and others

Sample applications (Others)

The source code comes with #2 C++ sample applications: Benchmark and Recognizer. These sample applications can be used on all supported platforms: Android, Windows, Raspberry pi, iOS, OSX, Linux...

Benchmark (Others)

This application is used to check everything is ok and running as fast as expected. The information about the maximum frame rate could be checked using this application. It's open source and doesn't require registration or license key.

For more information on how to build and run this sample please check samples/c++/benchmark.

Recognizer (Others)

This is a command line application used to detect and recognize a license plate from any JPEG/PNG/BMP image.

For more information on how to build and run this sample please check samples/c++/recognizer.

Using the C++ API

The C++ API is defined at https://www.doubango.org/SDKs/credit-card-ocr/docs/cpp-api.html.

	#include <ultimateCreditCard-SDK-API-PUBLIC.h> // Include the API header file

	// JSON configuration string
	// More info at https://www.doubango.org/SDKs/credit-card-ocr/docs/Configuration_options.html
	static const char* __jsonConfig =
	"{"
	"\"debug_level\": \"info\","
	"\"debug_write_input_image_enabled\": false,"
	"\"debug_internal_data_path\": \".\","
	""
	"\"num_threads\": -1,"
	"\"gpgpu_enabled\": true,"
	""
	"\"detect_roi\": [0, 0, 0, 0],"
	"\"detect_minscore\": 0.5,"
	""
	"\"recogn_minscore\": 0.2,"
	"\"recogn_score_type\": \"min\""
	"}";

	// Local variable
	UltCreditCardSdkResult result;

	// Initialize the engine (should be done once)
	ULTCCARD_SDK_ASSERT((result = UltCreditCardSdkEngine::init(
		__jsonConfig
	)).isOK());

	// Processing (detection + recognition)
	// Call this function for every video frame
	const void* imageData = nullptr;
	ULTCCARD_SDK_ASSERT((*result_ = UltCreditCardSdkEngine::process(
			ULTCCARD_SDK_IMAGE_TYPE_RGB24,
			imageData,
			imageWidth,
			imageHeight
		)).isOK());

	// DeInit
	// Call this function before exiting the app to free the allocate resources
	// You must not call process() after calling this function
	ULTCCARD_SDK_ASSERT((result = UltCreditCardSdkEngine::deInit()).isOK());

Again, please check the sample applications for more information on how to use the API.

Technical questions

Please check our discussion group or twitter account

Open Source Agenda is not affiliated with "UltimateCreditCard SDK" Project. README Source: DoubangoTelecom/ultimateCreditCard-SDK

Open Source Agenda Badge

Open Source Agenda Rating