# 在线音乐教学 API (/zh-CN/api-reference/online-music-teaching/ios/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/ios/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/ios/configuration)，实现实时消息相关功能

- [互动白板 SDK](/zh-CN/api-reference/whiteboard/fastboard/ios)，实现在线课堂中的白板功能

- [云端录制](/zh-CN/api-reference/api-ref/cloud-recording/acquire)，为实时音视频和互动白板提供录制功能

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

```objc
- (int) enableFishCorrection:(BOOL)enable
                      params:(AgoraFishCorrectionParams *_Nullable)params;
```

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

#### 参数 [#参数]

| 参数 | 说明 |
| --- | --- |
| `enable` | [fish-eye-ios-macos-html-0-1-1 details](#table-slot-fish-eye-ios-macos-html-0-1-1) |
| `params` | 畸变矫正参数。详见 [`AgoraFishCorrectionParams`](/zh-CN/api-reference/online-music-teaching/ios/api/fish-eye#agorafishcorrectionparams)。 |

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

**fish-eye-ios-macos-html-0-1-1 details**

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

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

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

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

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

```objc
- (int)enableVideoMultiRenderer:(BOOL)enabled;
```

开启或关闭多渲染功能。

#### 参数 [#参数-1]

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

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

**fish-eye-ios-macos-html-1-1-1 details**

是否开启多渲染功能。

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

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

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

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

```objc
- (int)setupLocalVideo:(AgoraRtcVideoCanvas * _Nullable)local
                  mode:(AgoraVideoViewSetupMode)mode;
```

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

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

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

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

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

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

```objc
- (int)setupRemoteVideo:(AgoraRtcVideoCanvas * _Nonnull)remote
                   mode:(AgoraVideoViewSetupMode)mode;
```

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

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

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

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

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

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

```objc
- (int)setupRemoteVideoEx:(AgoraRtcVideoCanvas* _Nonnull)remote
                     mode:(AgoraVideoViewSetupMode)mode
               connection:(AgoraRtcConnection * _Nonnull)connection;
```

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

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

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

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

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

<a id="agorafishcorrectionparams"></a>
## 数据类型 [#数据类型]
### AgoraFishCorrectionParams [#agorafishcorrectionparams]

```objc
__attribute__((visibility("default"))) @interface AgoraFishCorrectionParams : NSObject

@property (nonatomic, assign) float x_center;

@property (nonatomic, assign) float y_center;

@property (nonatomic, assign) float scale_factor;

@property (nonatomic, assign) float focal_length;

@property (nonatomic, assign) float pol_focal_length;

@property (nonatomic, assign) float split_height;

@property (nonatomic, copy) NSArray *_Nonnull ss;

@end
```

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

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

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

<a id="agoravideocroparea"></a>
### AgoraVideoCropArea [#agoravideocroparea]

```objc
__attribute__((visibility("default"))) @interface AgoraVideoCropArea : NSObject

@property (nonatomic, assign) int xPoint;

@property (nonatomic, assign) int yPoint;

@property (nonatomic, assign) int width;

@property (nonatomic, assign) int height;

@end
```

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

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

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

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

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

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

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