# Development Guide

{% tabs %}
{% tab title="Android" %}

### Usage

For Android, a valid license key is required to start the process. In OkayDoc, there are two types of document verification:&#x20;

* Image
* Video

Use the **ImageConfig** for the image verification, and **VideoConfig** for video verification. The example is shown below:

```
Config videoConfig = new VideoConfig.Builder()
    .setMyKadThreshold(70)
    .setLandmarkThreshold(10)
    .setHologramThreshold(30)
    .setMinHologramDiff(2)
    .setMinHologramCount(1)
    .setMinLandmarkCount(3)
    .setColorDetection(false)
    .setScreenDetection(false)
    .setContentSubDetection(false)
    .setFaceTamperDetection(false)
    .setMicroprintDetection(false)
    .build();
    
Config imageConfig = new ImageConfig.Builder()
    .setMyKadThreshold(70)
    .setLandmarkThreshold(10)
    .setHologramThreshold(30)
    .setColorDetection(false)
    .setScreenDetection(false)
    .setContentSubDetection(false)
    .setFaceTamperDetection(false)
    .setMicroprintDetection(false)
    .build();
    
Config imagePathConfig = new ImagePathConfig.Builder()
    .setPath("path/to/image.jpg")
    .setMyKadThreshold(70)
    .setLandmarkThreshold(10)
    .setHologramThreshold(30)
    .setColorDetection(false)
    .setScreenDetection(false)
    .setContentSubDetection(false)
    .setFaceTamperDetection(false)
    .setMicroprintDetection(false)
    .build();
    
MyKadDetectionActivity.startDetection(this, LICENSE_KEY, 
MyKadDetectionManager.CameraType.IMAGE, imageConfig, (success, errorCode, result) -> { 
    if (success) {
        Log.d("SAMPLE", "result => " + result);
    } else {
        Log.d("SAMPLE", "error => " + errorCode);
    }
});
```

### Configuration

#### *ImageConfig*

There are several Config files that require to configure while developing. **ImageConfig** will be the first listed below:

| Config                 | Possible Input Range                                | Default |
| ---------------------- | --------------------------------------------------- | ------- |
| myKadThreshold         | between 1 and 100                                   | 70      |
| landmarkThreshold      | between 1 and 100                                   | 10      |
| hologramThreshold      | between 1 and 100                                   | 30      |
| setColorDetection      | set false to disable color detection                | true    |
| setScreenDetection     | set false to disable screen detection               | true    |
| setFaceTamperDetection | set false to disable face tamper detection          | true    |
| setContentSubDetection | set false to disable content substitution detection | true    |
| setMicroprintDetection | set false to disable microprint detection           | true    |

#### *ImagePathConfig*

As for the **ImagePathConfig,** it consists of ImageConfig plus image file path below:

| Config  | Value                             |
| ------- | --------------------------------- |
| SetPath | Full path to the valid image file |

#### *VideoConfig*

As for the **VideoConfig,** it consists of ImageConfig plus the following extra configurations below:

| Config                 | Possible Input Range                                | Default |
| ---------------------- | --------------------------------------------------- | ------- |
| minHologramDiff        | between 1 and 4                                     | 2       |
| minHologramCount       | between 1 and 4                                     | 1       |
| minLandmarkCount       | between 1 and 3                                     | 3       |
| setColorDetection      | set false to disable color detection                | true    |
| setScreenDetection     | set false to disable screen detection               | true    |
| setFaceTamperDetection | set false to disable face tamper detection          | true    |
| setContentSubDetection | set false to disable content substitution detection | true    |
| setMicroprintDetection | set false to disable microprint detection           | true    |

{% hint style="info" %}
The configurations that left it blank will follow the default values
{% endhint %}

### Result

Result is returned in ArrayList type. If video scanning is selected, there will be 2 MyKads returned: MyKad without flash and with flash. Kindly get hologram count from MyKad with flash as the holograms will be more obvious. You may get the rest of the results from MyKad without flash.

| Name                   | Description                                                  |
| ---------------------- | ------------------------------------------------------------ |
| isValidMykad()         | Return true if Mykad is valid                                |
| getHologramCount()     | Number of holograms detected                                 |
| getLandmarkCount()     | Number of landmarks detected                                 |
| isScreen()             | Return true if the screen is detected                        |
| isColor()              | <p>Return true if the image is not black and</p><p>white</p> |
| isFaceTampered()       | Return true if the face is tempered                          |
| isContentSubstituted() | Return true if the content is substituted                    |
| isMicroprint()         | Return true if the microprint is detected                    |

### Error Code

These are the error code that will be raised after process is completed.

| Error Code    | Constant Name                      |
| ------------- | ---------------------------------- |
| -1            | MyKad.NO\_ERROR                    |
| 1             | MyKad.ERROR\_INVALID\_LICENSE\_KEY |
| 2             | MyKad.ERROR\_PERMISSION\_DENIED    |
| 3             | MyKad.ERROR\_USER\_CANCEL\_ACTION  |
| 4             | MyKad.ERROR\_INVALID\_IMAGE        |
| 5             | MyKad.ERROR\_MYKAD\_NOT\_IN\_VIEW  |
| {% endtab %}  |                                    |
| {% endtabs %} |                                    |
