# 在线音乐教学 API (/zh-CN/api-reference/online-music-teaching/android/api/fish-eye)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

声网为在线音乐场景提供鱼眼镜头画面畸变矫正功能，本文提供相关的 API 参考。

除了在线音乐教学相关的 API，你还需要使用 RTC API 来实现实时音视频互动功能。你可以参考 [RTC API](/zh-CN/api-reference/rtc/android/rtc-api-overview) 文档来了解详细的 RTC API 用法。

:::info[信息]
鱼眼镜头畸变矫正与分离显示 API 仅存在于声网为在线音乐教学解决方案提供的声网 RTC 教育特殊版 SDK 中。声网官网的视频 SDK v4.x 版本尚不支持该功能。你可以[提交工单](https://ticket.shengwang.cn)联系我们获取声网 RTC 4.0.0 教育特殊版 SDK。
:::

此外，你还可以参考如下 API 文档，在场景实现中添加相应的功能：

- [RTM SDK](/zh-CN/api-reference/rtm/android/configuration)，实现实时消息相关功能
- [互动白板 SDK](/zh-CN/api-reference/whiteboard/fastboard/android)，实现在线课堂中的白板功能
- [云端录制](/zh-CN/api-reference/api-ref/cloud-recording/acquire)，为实时音视频和互动白板提供录制功能

<a id="enablefishcorrection"></a>
## 方法 [#方法]
### enableFishCorrection [#enablefishcorrection]

```java
public abstract int enableFishCorrection(boolean enable, FishCorrectionParams config);
```

开启或关闭鱼眼镜头画面畸变矫正。

#### 参数 [#参数]

| 参数 | 说明 |
| --- | --- |
| `enabled` | [fish-eye-android-html-0-1-1 details](#table-slot-fish-eye-android-html-0-1-1) |
| `config` | 畸变矫正参数。详见 [`FishCorrectionParams`](/zh-CN/api-reference/online-music-teaching/android/api/fish-eye#fishcorrectionparams)。 |

<a id="table-slot-fish-eye-android-html-0-1-1"></a>

**fish-eye-android-html-0-1-1 details**

是否开启鱼眼镜头画面矫正。

- `YES`：开启鱼眼镜头画面畸变矫正。
- `NO`：关闭鱼眼镜头画面畸变矫正。

#### 返回值 [#返回值]

- 0：方法调用成功。
- &lt; 0：方法调用失败。

<a id="enablevideomultirenderer"></a>
### enableVideoMultiRenderer [#enablevideomultirenderer]

```java
public abstract int enableVideoMultiRenderer(boolean enabled);
```

开启或关闭多渲染功能。

#### 参数 [#参数-1]
| 参数 | 说明 |
| --- | --- |
| `enabled` | [fish-eye-android-html-1-1-1 details](#table-slot-fish-eye-android-html-1-1-1) |

<a id="table-slot-fish-eye-android-html-1-1-1"></a>

**fish-eye-android-html-1-1-1 details**

是否开启多渲染功能。

- `true`：开启多渲染功能。
- `false`：关闭多渲染功能。

#### 返回值 [#返回值-1]

- 0：方法调用成功。
- &lt; 0：方法调用失败。

<a id="setuplocalvideo"></a>
### setupLocalVideo [#setuplocalvideo]

```java
public abstract int setupLocalVideo(VideoCanvas local, Constants.VideoViewSetupMode mode);
```

（多渲染功能）设置本地渲染画面。

#### 参数 [#参数-2]

| 参数 | 说明 |
| --- | --- |
| `local` | 视频渲染画布。详见 [`VideoCanvas`](/zh-CN/api-reference/rtc/android/class-videocanvas)。 |
| `mode` | 视频渲染模式。详见 [`VideoViewSetupMode`](/zh-CN/api-reference/online-music-teaching/android/api/fish-eye#videoviewsetupmode)。 |

#### 返回值 [#返回值-2]

- 0：方法调用成功。
- &lt; 0：方法调用失败。

<a id="setupremotevideo"></a>
### setupRemoteVideo [#setupremotevideo]

```java
public abstract int setupRemoteVideo(VideoCanvas remote, Constants.VideoViewSetupMode mode);
```

（多渲染功能）设置远端渲染画面。

#### 参数 [#参数-3]

| 参数 | 说明 |
| --- | --- |
| `remote` | 视频渲染画布。详见 [`VideoCanvas`](/zh-CN/api-reference/rtc/android/class-videocanvas)。 |
| `mode` | 视频渲染模式。详见 [`VideoViewSetupMode`](/zh-CN/api-reference/online-music-teaching/android/api/fish-eye#videoviewsetupmode)。 |

#### 返回值 [#返回值-3]

- 0：方法调用成功。
- &lt; 0：方法调用失败。

<a id="setupremotevideoex"></a>
### setupRemoteVideoEx [#setupremotevideoex]

```java
public abstract int setupRemoteVideoEx(
      VideoCanvas canvas, Constants.VideoViewSetupMode mode, RtcConnection connection)
```

（多频道场景）设置远端渲染画面。

#### 参数 [#参数-4]

| 参数 | 说明 |
| --- | --- |
| `remote` | 视频渲染画布。详见 [`VideoCanvas`](/zh-CN/api-reference/rtc/android/class-videocanvas)。 |
| `mode` | 视频渲染模式。详见 [`VideoViewSetupMode`](/zh-CN/api-reference/online-music-teaching/android/api/fish-eye#videoviewsetupmode)。 |
| `connection` | Connection 信息。详见 [`RtcConnection`](/zh-CN/api-reference/rtc/android/class-rtcconnection)。 |

#### 返回值 [#返回值-4]

- 0：方法调用成功。
- &lt; 0：方法调用失败。

<a id="fishcorrectionparams"></a>
## 数据类型 [#数据类型]
### FishCorrectionParams [#fishcorrectionparams]

```java
public class FishCorrectionParams {
  public float xCenter;
  public float yCenter;
  public float scaleFactor;
  public float focalLength;
  public float polFocalLength;
  public float splitHeight;
  public float ss[] = new float[5];

  public FishCorrectionParams() {
    this.xCenter = 0.49f;
    this.yCenter = 0.48f;
    this.scaleFactor = 4.5f;
    this.focalLength = 31.0f;
    this.polFocalLength = 31.0f;
    this.splitHeight = 1.0f;
    this.ss[0] = 0.9375f;
    this.ss[1] = 0.0f;
    this.ss[2] = -2.9440f;
    this.ss[3] = 5.7344f;
    this.ss[4] = -4.4564f;
  }

  public FishCorrectionParams(float xCenter, float yCenter, float scaleFactor, float focalLength,
      float polFocalLength, float splitHeight, float ss[]) {
    this.xCenter = xCenter;
    this.yCenter = yCenter;
    this.scaleFactor = scaleFactor;
    this.focalLength = focalLength;
    this.polFocalLength = polFocalLength;
    this.splitHeight = splitHeight;
    this.ss[0] = ss[0];
    this.ss[1] = ss[1];
    this.ss[2] = ss[2];
    this.ss[3] = ss[3];
    this.ss[4] = ss[4];
  }

  @CalledByNative
  float getXCenter() {
    return xCenter;
  }

  @CalledByNative
  float getYCenter() {
    return yCenter;
  }

  @CalledByNative
  float getScaleFactor() {
    return scaleFactor;
  }

  @CalledByNative
  float getFocalLength() {
    return focalLength;
  }

  @CalledByNative
  float getPolFocalLength() {
    return polFocalLength;
  }

  @CalledByNative
  float getSplitHeight() {
    return splitHeight;
  }

  @CalledByNative
  float[] getSS() {
    return ss;
  }
}
```

鱼眼镜头画面畸变校正参数。

#### 参数 [#参数-5]

| 参数 | 说明 |
| --- | --- |
| `xCenter` | 鱼眼图像处理的中心位置 X 坐标。取值范围 [0.4,0.6]。 |
| `yCenter` | 鱼眼图像处理的中心位置 Y 坐标。取值范围 [0.4,0.6]。 |
| `scaleFactor` | 鱼眼镜头成像的区域大小。取值范围 [1,5]。1 为镜头最内圈，5 为镜头最外圈。 |
| `focalLength` | 镜头焦距。取值范围 [20,40]。 |
| `polFocalLength` | 标定鱼眼镜头的参数，通过镜头焦距计算。取值范围 [20,40]。 |
| `splitHeight` | 鱼眼校正效果切分高度。取值范围 [0,1]。在切分线以上的画面有鱼眼校正效果，在切分线以下的画面无鱼眼校正效果。 |
| `ss` | 镜头的一组参数，通过多项式拟合得到。不同类型的鱼眼镜头会有不同的值。 |

<a id="crop"></a>
### Crop [#crop]

```java
public static class Crop {
    public int left;
    public int top;
    public int width;
    public int height;

    @CalledByNative("Crop")
    int getLeft() {
      return left;
    }

    @CalledByNative("Crop")
    int getTop() {
      return top;
    }

    @CalledByNative("Crop")
    int getWidth() {
      return width;
    }

    @CalledByNative("Crop")
    int getHeight() {
      return height;
    }
  }
```

需要截取的视频画面区域。参数使用屏幕坐标系，原点在屏幕左上角(0, 0)。

#### 参数 [#参数-6]

| 参数 | 说明 |
| --- | --- |
| `left` | 屏幕坐标系中图像左上角顶点的 X 坐标。单位为像素。 |
| `top` | 屏幕坐标系中图像左上角顶点的 Y 坐标。单位为像素。 |
| `width` | 以图像左上角顶点为起始点，截取画面的宽度。单位为像素。 |
| `height` | 以图像左上角顶点为起始点，截取画面的高度。单位为像素。 |

图像的截取方式如下图所示：

![截图方式](https://web-cdn.agora.io/docs-files/1645427490815)

<a id="videoviewsetupmode"></a>
### VideoViewSetupMode [#videoviewsetupmode]

- `VIDEO_VIEW_SETUP_ADD(1)`：添加指定视图。
- `VIDEO_VIEW_SETUP_REMOVE(2)`：删除指定视图。
