Skip to main content

How can I enable image enhancement?

During a video call or live streaming, users often want to improve their on-screen appearance, which can help improve their confidence. The Agora Video SDK provides APIs to help you easily implement basic image enhancement. Users can enable this functionality and then adjust a number of image enhancement options including skin smoothing, acne removal, and a "rosy cheeks" effect to achieve natural-looking enhancements.

If the basic image enhancement function provided by the Agora Video SDK does not meet your needs and scenarios, you can integrate a third-party image enhancement SDK with the Agora Video SDK to implement real-time video interaction with advanced image enhancement functions. Agora provides an open-source sample project for your reference.

Implementation

  1. Ensure that you have implemented basic real-time functions in your project. See Start Interactive Live Video Streaming or Start a Video Call.
  2. Call setBeautyEffectOptions to enable image enhancement and set the image enhancement options.

As of v3.6.0, the Agora Video SDK for Native platforms and third-party frameworks updates the Agora image enhancement algorithm, which improves the image enhancement effects and supports sharpness adjustment. If you want to experience the optimized image enhancement effects or set the sharpness, upgrade your SDK and make sure the following dynamic libraries are integrated before you call setBeautyEffectOptions:

  • Android: libagora_video_process_extension.so
  • iOS: AgoraVideoProcessExtension.xcframework
  • macOS: AgoraVideoProcessExtension.framework or AgoraVideoProcessExtension.xcframework
  • Windows: libagora_video_process_extension.dll

Sample code

Java


_2
// Java
_2
mRtcEngine.setBeautyEffectOptions(true, new BeautyOptions(LIGHTENING_CONTRAST_NORMAL, 0.5F, 0.5F, 0.5F));

Swift


_8
// Swift
_8
let options = AgoraBeautyOptions()
_8
options.lighteningContrastLevel = .normal
_8
options.rednessLevel = 0
_8
options.smoothnessLevel = 0
_8
options.lighteningLevel = 0
_8
_8
agoraKit.setBeautyEffectOptions(true, options: options)

Objective-C


_8
// Objective-C
_8
AgoraBeautyOptions *options = [[AgoraBeautyOptions alloc] init];
_8
options.lighteningContrastLevel = AgoraLighteningContrastNormal;
_8
options.rednessLevel = 0;
_8
options.smoothnessLevel = 0;
_8
options.lighteningContrastLevel = 0;
_8
_8
[self.agoraKit setBeautyEffectOptions:YES options:options];

C++


_9
// C++
_9
bool enabled = true;
_9
agora::rtc::BeautyOptions options;
_9
options.lighteningContrastLevel = BeautyOptions::LIGHTENING_CONTRAST_NORMAL;
_9
options.lighteningLevel = 0.7;
_9
options.smoothnessLevel = 0.5;
_9
options.rednessLevel = 0.1;
_9
_9
m_lpAgoraEngine->setBeautyEffectOptions(enabled, options);

Web 3.x


_13
// Web 3.x
_13
// setBeautyEffectOptions is an asynchronous method and must be called with Promise or async/await keywords.
_13
// To enable image enhancement immediately after creating a video stream, you can call setBeautyEffectOptions in the Client.on("stream-published") callback.
_13
var streamPublishedHandler = async function () {
_13
await localStream.setBeautyEffectOptions(true, {
_13
lighteningContrastLevel: 1,
_13
lighteningLevel: 0.7,
_13
smoothnessLevel: 0.5,
_13
rednessLevel: 0.1
_13
});
_13
client.off('stream-published', streamPublishedHandler);
_13
};
_13
client.on('stream-published', streamPublishedHandler);

Web 4.x


_13
// Web 4.x
_13
// Call setBeautyEffect in LocalVideoTrack to set the basic image enhancement function.
_13
// The localVideoTrack in the following example is a local camera video track object created with AgoraRTC.createCameraVideoTrack.
_13
localVideoTrack
_13
.setBeautyEffect(true, {
_13
lighteningContrastLevel: 1,
_13
lighteningLevel: 0.7,
_13
smoothnessLevel: 0.5,
_13
rednessLevel: 0.1
_13
})
_13
.then(() => {
_13
console.log('set Beauty Effect Options success!');
_13
});

Agora also provides an Online Demo for you to experience the basic image enhancement function.

API reference

Native

Web

Third-party frameworks developed from Native

Considerations

  • The image enhancement function involves real-time processing that is resource intensive. Therefore, enabling this function can reduce the system performance of low-end devices below acceptable levels. Agora does not recommend enabling image enhancement for low-end devices where the user's video-encoding profile is 360P at 30 fps or 720P at 15 fps or higher.
  • The image enhancement function of the Agora Web SDK is not supported on mobile devices and only supported on certain browsers. See Web 3.x or 4.x API reference.
  • When you use the setBeautyEffectOptions method of the Agora Web 3.x SDK, note that this method has call sequence restrictions and image enhancement options are only available for high-quality video streams. See Web 3.x API reference.