<h2 id="Image Distortion Correction">Image Distortion Correction <span className="tag_h2">On-App AI</span></h2>

<div style="display: flex; align-items: center; justify-content: flex-start; margin-top: 20px;">
<img alt="Pet image quality detection" src="https://images.tuyacn.com/rms-static/7a7c6b30-8e1f-11f0-9fb9-e1834df84344-1757492629859.jpg?tyName=c76b13b2c06dc0f737cb5ca7e51cd3e3.jpg" width="250" style="margin-right: 10px;">
<img alt="Pet image quality detection" src="https://images.tuyacn.com/rms-static/7a6c3e90-8e1f-11f0-9fb9-e1834df84344-1757492629753.jpg?tyName=b35342b007049f299246e4695cbb9fbb.jpg" width="250">
</div>

### Features

After optimizing a web image for clarity enhancement, you can then perform distortion correction.

### How it works

1. **Download the image data** to the local device.

2. **Enhancement** (it must be performed in the following order):
   - Step 1: Perform clarity enhancement on the image.
   - Step 2: Apply distortion correction to the image.

### Interaction process

```mermaid
sequenceDiagram
    participant Cloud
    participant User
    participant Panel
    participant AI Engine

    rect rgb(200, 34, 255)
        Note over Panel: Download image remotely
        User ->> Panel: Tap "Optimize"
        Panel ->> Cloud: downloadFile()
        Cloud ->> Panel: Download the image
        Panel -->> Panel: Return local image path
    end

    rect rgb(84, 163, 119)
        Note over Panel,AI Engine: Image processing
        Panel ->> AI Engine: enhanceClarityForImage (Original URI)
        AI Engine ->> AI Engine: AI analytics <br>and clarity enhancement
        AI Engine ->> Panel: Return a temporary URI
        Panel ->> AI Engine: enhanceCalibrationForImage <br>(temporary URI of the clarity-enhanced image)
        AI Engine ->> AI Engine: AI analytics <br>and clarity enhancement
        AI Engine ->> Panel: Return final temporary URI

    end

    rect rgb(255, 62, 130)
        Note over Panel,User: Return the result
        Panel ->> Panel: Get cache path
        Panel ->> User: Display enhanced preview image
    end
```
