Skip to content

Document capture

The document is detected on the device by IDCardDetectionBaseFragment and captured automatically once the user holds it correctly in front of the camera. You then send the captured image to Prove ID for verification.

IDCardDetectionBaseFragment fragment = IDCardDetectionBaseFragment.create(getApplicationContext());
IDCardDetectionConfiguration configuration = new IDCardDetectionConfiguration();
configuration.setCardTypeList(Collections.singletonList(CardType.NEW_ID));
configuration.setMessageToEncrypt(transactionId);
configuration.setEncryptDeviceId(true);
configuration.setDetectBothOrientation(true);
fragment.setConfiguration(configuration);
fragment.setListener(new OcrListener() {
@Override
public void cardDetected(Bitmap captured, CardType cardType) {
// Send the image to Prove ID (below)
}
@Override
public void cardDetectionFailed(CardDetectionErrorsModel errors) {
// Guide the user: move closer, add light, etc.
}
@Override
public void cardOcrCompleted(OcrResultModel ocrResultModel) {
// Only called when setDoOcr(true)
}
});
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_camera, fragment)
.commit();

Start capturing when the screen is visible and stop when it goes to the background:

fragment.startCapture(); // onResume
fragment.stopCapture(); // onPause

Convert the captured image to Base64 and send it with the call for the document type:

ByteArrayOutputStream out = new ByteArrayOutputStream();
captured.compress(Bitmap.CompressFormat.PNG, 100, out);
String base64 = Base64.encodeToString(out.toByteArray(), Base64.NO_WRAP);
ServerCall.verifyIDPhoto(new CheckIDModel(base64, transactionId),
new TechsignServiceListener<CheckIdReturnModel>() {
@Override
public void onSuccess(CheckIdReturnModel result) {
CapturedModel data = result.getCapturedData();
ControlEntryModel[] controls = result.getControlResults();
}
@Override
public void onFailure(Exception e) { }
});
Document Call
Turkish ID card — front ServerCall.verifyIDPhoto(new CheckIDModel(base64, tid), …)
Turkish ID card — back ServerCall.addSecondary(new AddSecondaryModel(base64, tid), …)
Old Turkish ID card ServerCall.verifyOldId(new CheckIDModel(base64, tid), …)
Driving licence ServerCall.verifyDriverPhoto(new CheckIDModel(base64, tid), …)
Passport ServerCall.verifyPassportPhoto(new CheckIDModel(base64, tid), …)
Blue card ServerCall.verifyTurkishBlueCard(new CheckIDModel(base64, tid), …)
Foreign ID card ServerCall.verifyForeignId(new CheckIDModel(base64, tid), …)

CapturedModel holds the data read from the document: getId(), getName(), getSname(), getNat(), getGend(), getSno(), getBdat(), getEdat().

Setting Default Description
setCardTypeList(List<CardType>) NEW_ID, NEW_ID_BACK, NEW_DRIVER, DRIVER_BACK Document types to detect
setDetectBothOrientation(boolean) false Detects the document in both orientations
setFocusScoreThresholdActive(boolean) false Waits for the sharpest frame instead of capturing immediately
setMinFocusScore(float) — Sharpness threshold (e.g. 0.55f)
setEligibleFocusScoreCount(int) — Consecutive frames that must pass the threshold
setRePredictWithMargin(boolean) false Re-predicts to sharpen the crop
setRePredictionMargin(float) — Re-prediction margin (e.g. 0.1f)
setMaxHologramScoreForBlur(float) 1.0f Avoids hologram glare; 1.0f turns the check off
setTurnIfReverse(boolean) false Rotates a document held upside down
setDoOcr(boolean) false On-device OCR (needs ML Kit)
setMrzActive(boolean) false MRZ reading (needs jmrtd)
setMessageToEncrypt(String) — Message embedded in the image; pass the transaction ID
setEncryptDeviceId(boolean) — Embeds the device ID in the image

For visual settings see Customization.