vinaygaba/CreditCardView

Can you add feature that image recognition

xu6148152 opened this issue · 3 comments

I saw many app have this feature, if the app have this feature, people do not input any message, it's very convenience

Hi,
I am looking into using the Card.io SDK to implement this feature. Do you have any suggestions on how the camera should be called to recognize the content on the cards?

@vinaygaba I don't think it's possible to do this at least with the Card.IO SDK. The CreditCardView is an extended object of a View. You could grab the context that the view is in, but it is only guaranteed to be an activity from the Android framework.

If you take a look at the sample app for the Card.IO SDK, you will see that the activity that uses Card.IO needs to have "onActivityResult" overridden to get the results of the image recognition.

I'm pretty sure that you can not override a method on an object that was already created. You would need to write an activity class that has the appropriate method overridden..

This could be an opt-in feature (and one with little effort on your part) whose entry point is to just call some method on your view that takes the activity result as a parameters and knows how to dissect it. A consuming developer would have to know to call:

creditCardView.updateFromCardIOResult(data);

where 'data' is the Intent object from onActivityResult(...). Definitely could not have the view listen for the result or any kind of notification given the volatile nature of any activities in the backstack -- the view may not exist anymore if the OS has killed it.