blinkcard / blinkcard-android

SDK for scanning and OCR of credit or payment cards. Contains native Android SDK, code samples and documentation.
44 stars 5 forks source link

Not getting card image #4

Closed samirpramanik closed 3 years ago

samirpramanik commented 5 years ago

Hello,

I am trying to scan cards using BlinkCard however i am not able to get the card image. The other fields are coming fine such as cardNumber, issuer and expiry date. I am using the version 1.0.0. I tried result.getFullDocumentFrontImage and getEncodedFrontFullDocumentImage, but both return null. Please find our implementation below : `private BlinkCardRecognizer mRecognizer; private RecognizerBundle mRecognizerBundle; public static final int MY_REQUEST_CODE = 0x222;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // create BlinkCardRecognizer mRecognizer = new BlinkCardRecognizer(); mRecognizer.setExtractCvv(false);

    // bundle recognizers into RecognizerBundle
    mRecognizerBundle = new RecognizerBundle(mRecognizer);
    startScanning();
}

public void startScanning() {
    // Settings for BlinkCardActivity Activity
    BlinkCardUISettings settings = new BlinkCardUISettings(mRecognizerBundle);

    // tweak settings as you wish

    // Start activity
    ActivityRunner.startActivityForResult(this, MY_REQUEST_CODE, settings);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    try {
        if (requestCode == MY_REQUEST_CODE) {
            if (resultCode == BlinkCardActivity.RESULT_OK && data != null) {
                // load the data into all recognizers bundled within your RecognizerBundle
                mRecognizerBundle.loadFromIntent(data);

                // now every recognizer object that was bundled within RecognizerBundle
                // has been updated with results obtained during scanning session

                // you can get the result by invoking getResult on recognizer
                BlinkCardRecognizer.Result result = mRecognizer.getResult();
                if (result.getResultState() == Recognizer.Result.State.Valid) {
                    // result is valid, you can use it however you wish
                    String cardNumber = result.getCardNumber();

                    CardIssuer issuer = result.getIssuer();
                    String owner = result.getOwner();
                    DateResult validity = result.getValidThru();
                    Image cardImage = result.getFullDocumentFrontImage();
                    ByteArrayOutputStream fos = new ByteArrayOutputStream();
                    byte[] byteArray = result.getEncodedFrontFullDocumentImage();
                    if(byteArray != null ){
                        String base64CardImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
                    }

                }
            }
        }`

BlinkCardIssue

samirpramanik commented 5 years ago

And also, we are not getting the owner name. Is there any other API to fetch the same?

i1E commented 5 years ago

Hi @samirpramanik,

you have to enable returning of full document image on the recognizer instance, use BlinkCardRecognizer.setReturnFullDocumentImage.

By default, owner name is not extracted, you also have to enable that feature, use BlinkCardRecognizer.setExtractOwner.

Hope this helps.