zego-effects-reactnative
Zego Effects SDK for React Native.
Getting started
$ yarn add @zegocloud/zego-effects-reactnative
Usage
Download and Import Resources into the Project
Download the latest version of the Effects SDK from the SDK download site (iOS download link: https://doc-zh.zego.im/article/15898, Android download link: https://doc-zh.zego.im/article/15899). After extracting it, import the Resources
and Models
folders into your project.
Note: You only need to add the resources and models to your project; @zegocloud/zego-effects-reactnative
will automatically download the SDK itself.
- iOS: Add the
Resources
and Models
folders to your Xcode project and choose the Create folders
option in the Group
settings. Assuming your project name is example
and you place all resources in the Assets
folder, your project directory structure should look like this after importing:
# ios
├── example
│ ├── AppDelegate.h
│ ├── AppDelegate.mm
│ ├── Images.xcassets
├── Assets
│ ├── Models
│ │ ├── FaceDetectionModel.model
│ │ └── SegmentationModel.model
│ └── Resources
│ ├── ColorfulStyleResources
│ ├── CommonResources.bundle
│ ├── FaceWhiteningResources.bundle
│ ├── MakeupResources
│ ├── PendantResources.bundle
│ ├── RosyResources.bundle
│ └── TeethWhiteningResources.bundle
│
- Android: Add the
Resources
and Models
folders to the assets
directory in your Android project. Typically, the resources should be placed in the android/app/src/main/assets
directory, so your project directory structure should look like this after importing:
# android/app/src/main
├── AndroidManifest.xml
├── assets
│ ├── Models
│ │ ├── FaceDetectionModel.model
│ │ └── SegmentationModel.model
│ └── Resources
│ ├── ColorfulStyleResources
│ ├── CommonResources.bundle
│ ├── FaceWhiteningResources.bundle
│ ├── MakeupResources
│ ├── PendantResources.bundle
│ ├── RosyResources.bundle
│ └── TeethWhiteningResources.bundle
├── java
└── res
Code Invocation
import ZegoEffects from '@zegocloud/zego-effects-reactnative';
async function initEffects() {
await engine.enableCustomVideoProcessing(true, {}, ZegoPublishChannel.Main);
console.log(`Effects version=${await ZegoEffects.getVersion()}`);
const authInfo: string = await ZegoEffects.getAuthInfo(appSign);
const license: string = await getLicenseFromZegoServer(appID, authInfo);
const effects = new ZegoEffects(license);
effects.on('error', (errorCode: number, desc: string) => {
console.error(`Error code: ${errorCode}, Description: ${desc}`);
});
effects.enableImageProcessing(true);
effects.enableSmooth(true);
effects.setSmoothParam({ intensity: 100 });
effects.enableFaceLifting(true);
effects.setFaceLiftingParam({ intensity: 100 });
console.log('Beauty effects initialized successfully.');
}