> For the complete documentation index, see [llms.txt](https://portal-integracao.intelbras.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://portal-integracao.intelbras.com.br/linha-android/algoritimos-e-funcionamento/reconhecimento-de-face-+-idcard.md).

# Reconhecimento de Face + IDCard

Atualmente, o reconhecimento de cartão de identificação facial suportado é uma identificação mista, ou seja, prioridade de reconhecimento de cartão de identificação facial, se não houver informações de cartão de identificação, vá para o reconhecimento facial O limite de similaridade do reconhecimento de cartão de identificação facial é mantido pelo próprio serviço, e o serviço de IA não precisa ser usado.

Para detalhes, verifique o demo LamyAiServer

```java
**
* Face ID Card Recognition, there is no face ID, so determine a unique face ID, different from the
face base library comparison (face base library comparison face ID is the caller passed in)
*/
private static final int FACE_ID_OF_FACE_CARD_ARITHMETIC = -123456789;
/**
* Face ID Card Recognition，The similarity threshold is a recommended value, which can be defined by
the service
*/
private static final int SIMILARITY_THRESHOLD_OF_FACE_CARD = 60
```

### 1 - Inicio do Algorítimo

```java
@Override
protected int getCurrentArithmeticType() {
    return ArithmeticType.ARITHMETIC_TYPE_FACE;
}
protected void startAlgorithm() {
    //Create the parameter object
    Bundle requestBundle = new Bundle();
    //Set the width and height of the preview screen.Otherwise, before drawing the face frame in the
    preview interface, it is necessary to convert the recognition coordinate value to preview coordinate
    FaceParametersHelper.setViewHeight(requestBundle, mSurfaceView.getHeight());
    FaceParametersHelper.setViewWidth(requestBundle, mSurfaceView.getWidth());
    LamyAiServerClientProxy.getInstance().startArithmetic(getCameraId(), getCurrentArithmeticType(),
    requestBundle, mAiServerListener);
}
```

### 2 - Parse de recebimentos de dados do Algorítimo

The callback processing of witness recognition results is as follows. The processing process of face recognition results is consistent with

```java
protected void dealFaceRecognitionObject(final IAIFaceObject face) {
    if (face == null) {
        return;
    }
    // Face algorithm a frame recognition will call back twice, once for the
    // detection result, once for the recognition result
    // The detection results are mainly used to display the face frame in advance,
    // and the recognition results can be used for subsequent logic
    // You can determine the type of the current callback result according to the
    // following code,
    // Can also use the judging mSimilarity, not for FaceDetectSimilarityResult.
    // DETECT_RESULT_IN_VALIDITY_PERIOD for face recognition results, this method in
    // the runOnUiThread code
    // If there is no special treatment, the similarity judgment method can be used
    // generally
    AiDetectExternalInfo detectExternalInfo = null;
    if (face.mExtraInfo != null) {
        detectExternalInfo = AiDetectExternalInfo.deserialize((Bundle) face.mExtraInfo);
        if (detectExternalInfo.mFaceResultType == AiDetectExternalInfo.FACE_RESULT_TYPE_DETECT) {
            ModuleLog.i(TAG, "dealSingleFaceObject: FACE_RESULT_TYPE_DETECT");
        } else {
            ModuleLog.i(TAG, "dealSingleFaceObject: FACE_RESULT_TYPE_RECOGNITION");
        }
    }
    if (face.mId == FACE_ID_OF_FACE_CARD_ARITHMETIC) {
        // Processing face ID card comparison results
        dealFaceCardCompareResult(face, detectExternalInfo);
    } else {
        // Processing face comparison results, consistent with 3.2
        dealFaceCompareResult(face, detectExternalInfo);
    }
}

private void dealFaceCardCompareResult(IAIFaceObject face, AiDetectExternalInfo detectExternalInfo) {
    // Get the recognition frame related information
    dealExtraInfoOfDetectFrame(detectExternalInfo);
    // Get ID card information
    IDCardExternalInfo idCardExternalInfo = null;
    if (face.mExtraInfo != null) {
        idCardExternalInfo = IDCardExternalInfo.deserialize((Bundle) face.mExtraInfo);
        ModuleLog.e(TAG, "dealFaceCardCompareResult: " + face.mSimilarity + " " +
                idCardExternalInfo.name + " " + idCardExternalInfo.no);
        if (face.mSimilarity >= SIMILARITY_THRESHOLD_OF_FACE_CARD) {
            showToast("Id card recognition success " + idCardExternalInfo.name);
        } else {
            showToast("Id identification failed, similarity is too low " + face.mSimilarity);
        }
    }
}
```

### 3 - Encerramento do Algorítimo

```java
private void stopAlgorithm() {
    ModuleLog.i(TAG, "stopAlgorithm");
    mLamyAiServerClientProxy.stopArithmetic(getCameraId(), getCurrentArithmeticType(),
    mAiServerListener);
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://portal-integracao.intelbras.com.br/linha-android/algoritimos-e-funcionamento/reconhecimento-de-face-+-idcard.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
