---
name: "enhanceCalibrationForImage"
mode: "kit"
versionRequirements:
  - { name: "AIKit", version: "1.4.1" }
  - { name: "@ray-js/ray", version: "1.7.37" }
platform:
  - "iOS"
  - "Android"
async: true
title: "enhanceCalibrationForImage"
---

## enhanceCalibrationForImage

> [VERSION] AIKit >= 1.4.1 | @ray-js/ray >= 1.7.37

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Image distortion correction

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `trace_id` | `string` | Yes | - | `2.1.0` | Link ID |
| `device_id` | `string` | Yes | - | `2.1.0` | Device ID |
| `scene_type` | `string` | Yes | - | `2.1.0` | Business type |
| `inputImagePath` | `string` | Yes | - | `1.4.1` | Image input path |
| `outputImagePath` | `string` | Yes | - | `1.4.1` | Image output path |
| `interpolationType` | `1 \| 2 \| 3 \| 4 \| 5` | No | `1` | `1.4.1` | Interpolation type |
| `ratio` | `number` | Yes | - | `1.4.1` | Scale |
| `fCx` | `number` | Yes | - | `1.4.1` | Camera intrinsic Cx |
| `fCy` | `number` | Yes | - | `1.4.1` | Camera intrinsic Cy |
| `fFx` | `number` | Yes | - | `1.4.1` | Camera intrinsic Fx |
| `fFy` | `number` | Yes | - | `1.4.1` | Camera intrinsic Fy |
| `fK1` | `number` | Yes | - | `1.4.1` | Camera radial distortion coefficient K1 |
| `fK2` | `number` | Yes | - | `1.4.1` | Camera radial distortion coefficient K2 |
| `fK3` | `number` | Yes | - | `1.4.1` | Camera radial distortion coefficient K3 |
| `fP1` | `number` | Yes | - | `1.4.1` | Camera tangential distortion coefficient P1 |
| `fP2` | `number` | Yes | - | `1.4.1` | Camera tangential distortion coefficient P2 |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `(params: Object) => void` ↓see below | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### success callback parameters

| Property | Type | Since | Description |
| --- | --- | --- | --- |
| `outputImagePath` | `string` | `1.4.1` | Image URL |
| `enhanceSuccess` | `boolean` | `1.4.1` | Whether processing succeeded |
| `enhanceFaileReason` | `string` | `1.4.1` | Failure reason |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Valid Values

##### `interpolationType` valid values

| Value | Description |
| --- | --- |
| `1` | Default, BILINEAR |
| `2` | BILINEAR |
| `3` | BICUBIC |
| `4` | LANZCOS |
| `5` | EDGE |


### Examples

#### Basic usage

```tsx
import { ai } from '@ray-js/ray'

const { enhanceCalibrationForImage } = ai;

enhanceCalibrationForImage({
  trace_id: 'example',
  device_id: 'device_001',
  scene_type: 'example',
  inputImagePath: 'example',
  outputImagePath: 'example',
  ratio: 0,
  fCx: 0,
  fCy: 0,
  fFx: 0,
  fFy: 0,
  fK1: 0,
  fK2: 0,
  fK3: 0,
  fP1: 0,
  fP2: 0,
  success: (result) => {
    console.log('enhanceCalibrationForImage success', result);
  },
  fail: (error) => {
    console.log('enhanceCalibrationForImage fail', error.errorMsg);
  },
});
```
