Skip to content

Commit

Permalink
added v11.4.13
Browse files Browse the repository at this point in the history
  • Loading branch information
sMaltsevAcuant committed May 25, 2021
1 parent b289f9f commit 5edb7af
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 44 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Acuant Android SDK v11.4.12
**April 2021**
# Acuant Android SDK v11.4.13
**May 2021**

See [https://github.com/Acuant/AndroidSDKV11/releases](https://github.com/Acuant/AndroidSDKV11/releases) for release notes.

Expand Down Expand Up @@ -193,18 +193,18 @@ The SDK includes the following modules:
- Add the following dependencies

implementation 'com.acuant:acuantcommon:11.4.12'
implementation 'com.acuant:acuantcamera:11.4.12'
implementation 'com.acuant:acuantimagepreparation:11.4.12'
implementation 'com.acuant:acuantdocumentprocessing:11.4.12'
implementation 'com.acuant:acuantechipreader:11.4.12'
implementation 'com.acuant:acuantfacematch:11.4.12'
implementation 'com.acuant:acuanthgliveness:11.4.12'
implementation ('com.acuant:acuantipliveness:11.4.12'){
implementation 'com.acuant:acuantcommon:11.4.13'
implementation 'com.acuant:acuantcamera:11.4.13'
implementation 'com.acuant:acuantimagepreparation:11.4.13'
implementation 'com.acuant:acuantdocumentprocessing:11.4.13'
implementation 'com.acuant:acuantechipreader:11.4.13'
implementation 'com.acuant:acuantfacematch:11.4.13'
implementation 'com.acuant:acuanthgliveness:11.4.13'
implementation ('com.acuant:acuantipliveness:11.4.13'){
transitive = true
}
implementation 'com.acuant:acuantfacecapture:11.4.12'
implementation 'com.acuant:acuantpassiveliveness:11.4.12'
implementation 'com.acuant:acuantfacecapture:11.4.13'
implementation 'com.acuant:acuantpassiveliveness:11.4.13'

- Acuant also relies on Google Play services dependencies, which are pre-installed on almost all Android devices.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class AcuantMrzCameraFragment : AcuantBaseCameraFragment(), ActivityCompat.OnReq
override fun onOcrDetected(textBlock: String?){
if (textBlock != null && allowCapture) {
val result = mrzParser.parseMrz(textBlock)
//Log.d("MRZLOG", " " + result?.checkSumResult1 + ", "+ result?.checkSumResult2 +", "+ result?.checkSumResult3 +", "+ result?.checkSumResult4 +", "+ result?.checkSumResult5)
if (result != null) {
if (result.checkSumResult1 && result.checkSumResult2 && result.checkSumResult3 && result.checkSumResult4 && result.checkSumResult5) {
capturing = true
Expand Down Expand Up @@ -204,7 +205,7 @@ class AcuantMrzCameraFragment : AcuantBaseCameraFragment(), ActivityCompat.OnReq

fun isAcceptableAspectRatio(points: Array<Point>) : Boolean {
val ratio = distance(points[0], points[3]) / distance(points[0], points[1])
return ratio > 8f && ratio < 10f
return ratio > 4f && ratio < 10f
}

fun isAcceptableDistance(points: Array<Point>, screenSize: Float): Boolean {
Expand Down
135 changes: 124 additions & 11 deletions acuantcamera/src/main/java/com/acuant/acuantcamera/helper/MrzParser.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.acuant.acuantcamera.helper

import android.util.Log

class MrzParser{

companion object {
Expand All @@ -19,15 +17,130 @@ class MrzParser{
mrzLines.add(mrzLinesTmp[i])
}
}
if(mrzLines.size == 2){
val result = parseFirstLine(mrzLines[0])

if (mrzLines.size == 2) {
//Log.d("MRZLOG", "Follows:\n" + mrzLines[0] + "\n" +mrzLines[1])
var result = parseFirstLineOfTwoLine(mrzLines[0])
//not checking result of first line as it is not strictly needed for echip reading
return parseSecondLine(mrzLines[1], result)
result = parseSecondLineOfTwoLine(mrzLines[1], result)

result?.threeLineMrz = false
//Log.d("MRZLOG", " " + result?.checkSumResult1 + ", "+ result?.checkSumResult2 +", "+ result?.checkSumResult3 +", "+ result?.checkSumResult4 +", "+ result?.checkSumResult5)
return result
} else if (mrzLines.size == 3) {
//Log.d("MRZLOG", "Follows:\n" + mrzLines[0] + "\n" +mrzLines[1])
var result = parseFirstLineOfThreeLine(mrzLines[0])
if (result != null) {
result = parseSecondLineOfThreeLine(mrzLines[1], result)

result?.threeLineMrz = true

return result
//third line does not contain any relevant info
}
}
return null
}

private fun parseFirstLine(firstLine:String): MrzResult?{
private fun parseFirstLineOfThreeLine (firstLine: String) : MrzResult? {
var startPos = 0
if(firstLine.length == 30){
startPos+=2

val country = firstLine.substring(startPos, startPos+3)
startPos+=3

var passportNumber = firstLine.substring(startPos, startPos+9)
startPos+=9

var check1 = firstLine[startPos]
var checkSumResult1 = checkSum(passportNumber, check1)
++startPos

if (!checkSumResult1) {
passportNumber = passportNumber.replace('O', '0')
checkSumResult1 = checkSum(passportNumber, check1)

if (checkSumResult1 && check1 == 'O') {
check1 = '0'
checkSumResult1 = checkSum(passportNumber, check1)
}
}

val optional1 = firstLine.substring(startPos, startPos + 15)

return MrzResult(country = country, passportNumber = passportNumber, checkSumResult1 = checkSumResult1, checkChar1 = check1, optionalField1 = optional1)
}
return null
}

private fun parseSecondLineOfThreeLine (line: String, result: MrzResult) : MrzResult? {

if(line.length != 30){
return null
}

var startPos = 0
result.dob = line.substring(startPos, startPos+6)
startPos+=6

var check2 = line[startPos]
result.checkSumResult2 = checkSum(result.dob, check2)
++startPos

if (!result.checkSumResult2) {
result.dob = result.dob.replace('O', '0')
result.checkSumResult2 = checkSum(result.dob, check2)

if (!result.checkSumResult2 && check2 == 'O') {
check2 = '0'
result.checkSumResult2 = checkSum(result.dob, check2)
}
}

result.gender = line.substring(startPos, startPos+1)
++startPos

result.passportExpiration = line.substring(startPos, startPos+6)
startPos+=6

var check3 = line[startPos]
result.checkSumResult3 = checkSum(result.passportExpiration, check3)
++startPos

if (!result.checkSumResult3) {
result.passportExpiration = result.passportExpiration.replace('O', '0')
result.checkSumResult3 = checkSum(result.passportExpiration, check3)

if (!result.checkSumResult3 && check3 == 'O') {
check3 = '0'
result.checkSumResult3 = checkSum(result.passportExpiration, check3)
}
}

result.nationality = line.substring(startPos, startPos+3)
startPos+=3

val optional2 = line.substring(startPos, startPos+11)
startPos += 11

val finalCheckString = result.passportNumber + result.checkChar1 + result.optionalField1 + result.dob + check2 +
result.passportExpiration + check3 + optional2
result.checkSumResult4 = checkSum(finalCheckString, line[startPos])

if (!result.checkSumResult4 && line[startPos] == 'O') {
result.checkSumResult4 = checkSum(finalCheckString, '0')
}

result.checkSumResult5 = true

result.passportNumber = result.passportNumber.replace("<", "")

return result
}


private fun parseFirstLineOfTwoLine(firstLine:String): MrzResult?{
var startPos = 0
if(firstLine[startPos] == PASSPORT_FIRST_VALUE && firstLine.length == 44){
startPos+=2
Expand All @@ -46,9 +159,8 @@ class MrzParser{
return null
}

private fun parseSecondLine(line:String, result: MrzResult?): MrzResult?{
private fun parseSecondLineOfTwoLine (line: String, result: MrzResult?) : MrzResult? {

//Log.d("SecondLine:", line)

if(line.length != 44){
return null
Expand All @@ -61,7 +173,7 @@ class MrzParser{
}

var startPos = 0
resultLocal.passportNumber = line.substring(startPos, startPos+9).replace("<", "")
resultLocal.passportNumber = line.substring(startPos, startPos+9)//.replace("<", "")
startPos+=9

var check1 = line[startPos]
Expand Down Expand Up @@ -140,9 +252,10 @@ class MrzParser{
resultLocal.checkSumResult5 = checkSum(finalCheckString, line[startPos])

if (!resultLocal.checkSumResult5 && line[startPos] == 'O') {
resultLocal.checkSumResult5 = checkSum(resultLocal.personalDocNumber, '0')
resultLocal.checkSumResult5 = checkSum(finalCheckString, '0')
}
Log.d("SecondLine:", "" + resultLocal.checkSumResult1 + " " + resultLocal.checkSumResult2 + " " + resultLocal.checkSumResult3 + " " + resultLocal.checkSumResult4 + " " + resultLocal.checkSumResult5)

resultLocal.passportNumber = resultLocal.passportNumber.replace("<", "")

return resultLocal
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ data class MrzResult(var surName:String = "",
var gender: String= "",
var passportExpiration: String= "",
var personalDocNumber: String= "",
internal var optionalField1: String= "",
var checkSumResult1: Boolean = false,
var checkSumResult2: Boolean = false,
var checkSumResult3: Boolean = false,
var checkSumResult4: Boolean = false,
var checkSumResult5: Boolean = false): Serializable
var checkSumResult5: Boolean = false,
var threeLineMrz: Boolean = false,
internal var checkChar1: Char = '<'): Serializable
Binary file modified acuantcommon/acuantcommon.aar
Binary file not shown.
Binary file modified acuantdocumentprocessing/acuantdocumentprocessing.aar
Binary file not shown.
Binary file modified acuantechipreader/acuantechipreader.aar
Binary file not shown.

This file was deleted.

Binary file modified acuantfacematch/acuantfacematch.aar
Binary file not shown.
Binary file modified acuanthgliveness/acuanthgliveness.aar
Binary file not shown.
Binary file modified acuantimagepreparation/acuantimagepreparation.aar
Binary file not shown.
Binary file modified acuantipliveness/acuantipliveness.aar
Binary file not shown.
Binary file modified acuantpassiveliveness/acuantpassiveliveness.aar
Binary file not shown.
1 change: 1 addition & 0 deletions app/src/main/java/com/acuant/sampleapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener, IP
confirmNFCDataActivity.putExtra("DOE", result.passportExpiration)
confirmNFCDataActivity.putExtra("DOCNUMBER", result.passportNumber)
confirmNFCDataActivity.putExtra("COUNTRY", result.country)
confirmNFCDataActivity.putExtra("THREELINE", result.threeLineMrz)

this.startActivity(confirmNFCDataActivity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class NfcConfirmationActivity : AppCompatActivity(), NfcTagReadingListener {
private var documentNumber: String? = null
private var dob: String? = null
private var doe: String? = null
private var threeLine: Boolean = false
private var error: Boolean = true

private fun setProgress(visible : Boolean, state : HelpState = HelpState.Locate, text : String = "") {
Expand Down Expand Up @@ -123,13 +124,14 @@ class NfcConfirmationActivity : AppCompatActivity(), NfcTagReadingListener {
documentNumber = intent.getStringExtra("DOCNUMBER")
dob = intent.getStringExtra("DOB")
doe = intent.getStringExtra("DOE")
threeLine = intent.getBooleanExtra("THREELINE", false)

mrzDocNumber = findViewById(R.id.mrzDocumentNumber)
mrzDOB = findViewById(R.id.mrzDOB)
mrzDOE = findViewById(R.id.mrzDOE)
locationText = findViewById(R.id.mrzInstruction2)

if(!position.equals("unknown", true) && position != "") {
if(!position.equals("unknown", true) && position != "" && !threeLine) {
locationText.text = "Note: For $country passports, the eChip is typically on the $position"
} else {
locationText.text = ""
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<string name="verify_captured_data">Verify captured data and tap &startEchip;</string>
<string name="photo_of_person">Photo of the person obtained from chip</string>
<string name="photo_of_signature">Photo of signature obtained from passport chip</string>
<string name="mrz_camera">Read Passport MRZ</string>
<string name="mrz_camera">Read MRZ</string>

<string name="mrz_help_text">Ensure sufficient lighting with no reflection or glare on the passport.</string>
<string name="tap_anywhere_to_continue">Tap anywhere to continue</string>
Expand Down

0 comments on commit 5edb7af

Please sign in to comment.