VDVideoSelfieCapture¶
Presentation¶
Today, the current solutions that exist in the market do not provide a safe alternative when video capturing able to recognize a person's face, simply because its functionality is too basic. VDPhotoSelfieCapture arises due to the necessity of a more advanced and safer video selfie capture technique. The videos are done by the front camera of the device.
This SDK retrieves this information:
- byte array with video in MPEG-4 format, video encoder H.264 and audio encoder AAC.
Some permissions are needed to use the framework:
- Camera
- Microphone
The SDK is localised in English and Spanish. By default English language is selected and the language is automatically switched to Spanish if the device locale is Spanish.
The SDK can be configured using a dictionary. All possible keys and values can be checked in Configuration.
Two special configurations can be done outside the SDK.
- If a developer wants to create the font of the top label, the following lines have to added to styles.xml.
<style name="LabelText" parent="TextAppearance.AppCompat">
<item name="android:textColor">#HEXVAL</item>
<item name="android:textSize">XXdp</item>
<item name="android:fontFamily">@font/name_of_the_font</item>
</style>
Specifications¶
- Android minimum SDK version: API Level 21 (Android 5) (mobile devices only).
- SDK compatible with Harmony OS.
- Supported platforms: 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'.
-
SDK size: 370 KB (approx.). Additionally, some dependencies will be needed. These are:
Artifact Size common-core-X.Y.Z.aar 232 KB common-core-jvm-X.Y.Z.jar 106 KB common-logger-X.Y.Z.aar 19 KB common-logger-firebase-X.Y.Z.aar (optional library) 17 KB common-image-processing.aar is available for different architectures so its final size is the result of adding the size of each of the supported architectures.
Architecture Size x86 8.6 MB x86_64 9.2 MB armeabi-v7a 6.9 MB arm64-v8a 7.5 MB (All sizes have been calculated with Android Studio .aar analyzer)
Each mobile device on the market uses a unique software architecture. Thus, each mobile device does NOT install the full weight of the image processing library, but installs the part of the weight associated with its architecture. In fact, this process of dividing the weight according to the architecture also takes place when the APP is uploaded to the Play Store.
The integrator should not include anything in the app because Google Play will manage the complete APK (including all architectures) which size is bigger than individual ones. To separate that APK and show the user which is going to download the app it's real size based on the architecture the device is accessing to Google Play.
This is explained here (abis) and here (APK splits).
In case the integrator wants to check the different APK sizes, or just build for one architecture only. The following code can be added to the app gradle (as stated in the links provided):
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
- Video captured resolution is HD if available with a bit rate of 1.5Mbps (~3-4MB for a 15 sec video).
- The recognised documents that can be automatically detected with their IDs are:
- AR_IDCard_2009: Argentina IDCard 2009 v2
- AR_IDCard_2012: Argentina IDCard 2012 v2
- AT_DrivingLicense_2006: Austria DrivingLicense 2006
- AT_DrivingLicense_2014: Austria DrivingLicense 2014
- AT_IDCard_2002: Austria IDCard 2002
- AT_IDCard_2010: Austria IDCard 2010
- AT_IDCard_2021: Austria IDCard 2021
- AT_ResidencePermit_2005: Austria ResidencePermit 2005
- AT_ResidencePermit_2011: Austria ResidencePermit 2011
- AT_ResidencePermit_2020: Austria ResidencePermit 2020
- CO_IDCard_2000: Cedula de Ciudadania 2000
- DE_IDCard_2007: Germany IDCard 2007
- DE_IDCard_2010: Germany IDCard 2010
- ES_IDCard_2006: DNI 2.0
- ES_IDCard_2015: DNI 3.0
- ES_IDCard_2021: Spain IDCard 2021 (DNI 4.0)
- ES_ResidencePermit_2007: Spain ResidencePermit 2007 v2 (CERCU)
- ES_ResidencePermit_2010: NIE 2010
- ES_ResidencePermit_2011: NIE 2011
- ES_ResidencePermit_2020: NIE 2020
- HR_IDCard_2003: Croatia IDCard 2003
- HR_IDCard_2015: Croatia IDCard 2015
- HR_IDCard_2021: Croatia IDCard 2021
- HU_IDCard_2000: Hungary IDCard 2000
- HU_IDCard_2015: Hungary IDCard 2015
- MX_IDCard_2008: Credencial C
- MX_IDCard_2014: Credencial D/E/F
- MX_IDCard_2019: Credencial G
- MYS2001: Malaysia IDCard
- PE_IDCard_2007: Peru IDCard 2007
- PE_IDCard_2013: Peru IDCard 2013
- PE_IDCard_2020: Peru IDCard 2020
- PE_ResidencePermit_2017: Peru ResidencePermit 2017
- PE_ResidencePermit_2021: Peru ResidencePermit 2021
- RO_IDCard_2009: Romania IDCard 2009 and 2017
- RO_IDCard_2021: Romania IDCard 2021
Other strings passed to setDocumentType are not automatically detected.
Integration¶
- Create a new Android project.
- Import the framework (video-selfie-capture.aar) as a module (New... > Module > Import .JAR/.AAR Package) into your app.
- Add the following dependency:
implementation project (":video-selfie-capture")
(same name as aar) to the app gradle file. - Implement the Interface named
IVDVideoSelfieCapture
. - Import the rest of .aar/jar the same way (only steps 2 and 3).
- Add the following dependencies to the app gradle file:
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0" implementation 'androidx.exifinterface:exifinterface:1.3.7' implementation 'com.github.bumptech.glide:glide:4.16.0' implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23' implementation "org.jetbrains.kotlin:kotlin-reflect:1.9.23" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
Disabling allowBackup¶
By default the SDK allows the application to participate in the backup infrastructure, this behavior can be altered by
adding android:allowBackup="false"
to the application tag in the manifest file from the created application.
When this directive has been overridden tools:replace="android:allowBackup"
must be added to the application tag as
well, including adding the tools namespace xmlns:tools="http://schemas.android.com/tools"
to the manifest tag.
See this page for more details.
Example of use¶
// Add implementation of interface
public class SomeClass implements VDVideoSelfieCapture.IVDVideoSelfieCapture ...
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.your_layout);
// Start SDK. Is needed a delegate to receive delegated methods (this) and a Context to debug or use files (getApplicationContext()).
if (!VDVideoSelfieCapture.isStarted()) {
final Context applicationContext = getApplicationContext();
Map<String, String> configuration = new HashMap<>();
configuration.put("closebutton", "YES");
////////////// Veridas' recommended configuration //////////////
configuration.put("tickcolor", "#53A335");
configuration.put("tickcirclecolor", "#DCEFD4");
configuration.put("facemobileovalcolor", "#DCEFD4");
configuration.put("documentmobileovalcolor", "#DCEFD4");
configuration.put("videoinformativelabelbackgroundcolor", "#30000D44");
configuration.put("videoinformativelabelbordercolor", "#30000D44");
configuration.put("documentlabeltextbackgroundcolor", "#30000D44");
configuration.put("tutorialbackgroundcolor", "#FFFFFF");
configuration.put("tutorialtitlecolor", "#000D44");
configuration.put("tutorialtextcolor", "#000D44");
configuration.put("tutorialcontinuebuttoncolor", "#000D44");
configuration.put("tutorialcontinuebuttontextcolor", "#FFFFFF");
configuration.put("videoflashingcolor", "#B0FFFFFF");
VDVideoSelfieCapture.setDocumentType("ES_IDCard_2015", applicationContext);
VDVideoSelfieCapture.start(this, applicationContext, configuration);
}
}
...
// In another place you can stop the process (not recommended).
private boolean someMethod() {
// Stop it whenever you want.
VDVideoSelfieCapture.stop(someContext);
}
...
// Interface method
@Override
public void VDVideoSelfieFinished() {
// Do whatever you want when SDK is finished.
}
@Override
public void VDVideoSelfieCaptured(byte[] video) {
// Do with file as needed.
}
Workflow¶
The next diagram represents the current workflow of the framework. Some method's names may be shortened due to legibility issues.
Logging events¶
The SDK logs various events, please refer to Logging Events to learn more about this subject.
Third party libraries¶
- OpenCV 4.1.0 (main page. documentation). Library used for image manipulation.
- Firebase: storage 20.0.0 (main page). Used for logging purposes. Only needed when using the VDLoggerFirebase library.
- Glide: 4.16.0 (main page). Used for image loading.