Basic AI Effects
Function Overview
ZEGO provides basic AI effects features to present good skin condition for users and create unique natural beauty effects. This feature is commonly used in video calls, live streaming, and other scenarios.
Developers can enable the AI effects switch, and then adjust the degree of whitening, smoothing, sharpening, and rosiness as needed to easily implement basic AI effects features.
Prerequisites
Before implementing AI effects features, please ensure:
- You have created a project in ZEGOCLOUD Console and applied for valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated ZEGO Express SDK in the project and implemented basic audio and video streaming functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
Initialize Basic AI Effects Environment
If you need to use basic AI effects features, you must call the StartEffectsEnv interface to initialize the AI effects environment before starting preview with StartPreview or publishing stream with StartPublishingStream.
// Create AI effects environment
engine.StartEffectsEnv();Enable/Disable Basic AI Effects Effects
There is no order requirement for calling the EnableEffectsBeauty interface and the SetEffectsBeautyParam interface.
After initializing the AI effects environment, you can call the EnableEffectsBeauty interface before or after publishing stream to enable or disable AI effects effects in real time.
// Enable/disable AI effects effects
engine.EnableEffectsBeauty(true);Set Basic AI Effects Effect Parameters
After initializing the AI effects environment, you can call the SetEffectsBeautyParam interface before or after publishing stream to set AI effects effect parameters in real time.
- smoothIntensity: Smoothing, performs smoothing while retaining facial details, such as retaining moles on the face.
- whitenIntensity: Whitening, whitens the face by increasing the overall brightness of the image.
- rosyIntensity: Rosiness, applies warm color processing to the overall image.
- sharpenIntensity: Sharpening, applies sharpening processing to the overall image. When the image is slightly blurry, you can slightly increase sharpening to make contours clear.
The value range of all four parameters above is 0 to 100. The larger the value, the higher the AI effects degree. The default value is 50.
ZegoEffectsBeautyParam beautyParam = new ZegoEffectsBeautyParam();
// Whitening, rosiness, smoothing, sharpening
beautyParam.whitenIntensity = 50;
beautyParam.rosyIntensity = 50;
beautyParam.smoothIntensity = 50;
beautyParam.sharpenIntensity = 50;
engine.SetEffectsBeautyParam(beautyParam);Destroy Basic AI Effects Environment
When the EnableEffectsBeauty interface is called and set to "false", the AI effects effects will be turned off, but the AI effects module will still occupy resources and consume performance. If you want to completely release resources and save performance consumption, you need to call the StopEffectsEnv interface to destroy the AI effects environment before preview and publishing stream.
When DestroyEngine is called to destroy the engine, the SDK will automatically destroy the AI effects environment.
// Destroy AI effects environment
engine.StopEffectsEnv();