Docs / API reference
API reference
One vocabulary on every platform: the same parameter names, presets, shades, filters, props, licence features and statuses, spelled for Kotlin, Swift, TypeScript, Dart and TSX.
Names of parameters, presets, filters, lipstick shades, licence features and statuses, error codes and prop anchors come from one shared specification and are spelled the same everywhere: camelCase parameters, beauty.basic-style features, VALID-style statuses. The code tabs below remember the platform you pick.
Naming across platforms
| Android | iOS | Web | Flutter | React Native | |
|---|---|---|---|---|---|
| Package | com.knight98:facevity | pod Facevity | @facevity/web | facevity_flutter | react-native-facevity |
| Import | com.knight98.facevity | import Facevity | from '@facevity/web' | package:facevity_flutter/facevity_flutter.dart | from 'react-native-facevity' |
| Version | 0.3.3 | 0.4.0-alpha | 0.4.0-alpha | 0.4.0-alpha | 0.4.0-alpha |
| Calls | synchronous | synchronous | synchronous, initialize async | async (Future) | async (Promise) |
| Presets | BeautyParams.NATURAL | .NATURAL | BeautyParams.NATURAL | BeautyParams.natural | Beauty.NATURAL |
| Shades | BeautyColors.LIP_ROSE | BeautyColors.lipRose | BeautyColors.LIP_ROSE | BeautyColors.rose | BeautyColors.ROSE |
| Camera view | your renderer | your renderer | createProcessedTrack | FacevityPreview | <FacevityCameraView> |
| App ID | package name | bundle ID | web domain | package name, bundle ID | package name, bundle ID |
Create the engine
val fv = Facevity.initialize(context, FacevityOptions.Builder()
.maxFaces(1)
.licenseToken(token)
.build())let o = FacevityOptions()
o.maxFaces = 1
o.licenseToken = token
let fv = try Facevity.initialize(o)import { Facevity } from '@facevity/web';
const fv = await Facevity.initialize({ licenseToken, assetsBaseUrl: '/facevity/', maxFaces: 1 });final fv = await Facevity.initialize(
licenseToken: token,
options: const FacevityOptions(maxFaces: 1),
);const fv = await Facevity.initialize({ licenseToken, options: { maxFaces: 1 } });One engine per camera pipeline (web: per processed stream). Flutter and React Native keep one native engine per process; later initialize calls return it.
Presets and levels
fv.setParams(BeautyParams.NATURAL) // NATURAL, GLAM, DEFAULT, NONE
fv.setSmoothIntensity(60)
fv.setParams(fv.params.toBuilder().smooth(70).bigEyes(20).build())
fv.setBeautyEnabled(false) // exact pass-throughfv.setParams(.NATURAL) // .NATURAL, .GLAM, .DEFAULT, .NONE
fv.setSmoothIntensity(60)
fv.setParams(fv.params.with { $0.smooth(70).bigEyes(20) })
fv.setBeautyEnabled(false) // exact pass-throughfv.setParams(BeautyParams.NATURAL); // NATURAL, GLAM, DEFAULT, NONE
fv.setSmoothIntensity(60);
fv.setParams({ smooth: 70, bigEyes: 20 }); // partial update
fv.setBeautyEnabled(false); // exact pass-throughawait fv.setParams(BeautyParams.natural); // natural, glam, defaults, none
await fv.updateParams({'smooth': 70, 'bigEyes': 20});
await fv.setOverall(80);
await fv.setBeautyEnabled(false); // exact pass-throughawait fv.setParams(Beauty.NATURAL); // NATURAL, GLAM, DEFAULT, NONE
await fv.updateParams({ smooth: 70, bigEyes: 20 });
await fv.setOverall(80);
await fv.setBeautyEnabled(false); // exact pass-throughEvery 0..100 level follows one scale: 0 = off, 50 = natural, 100 = strong but still realistic. Values are clamped. Single-level setters on Android, iOS and Web: setSmoothIntensity, setBrightness, setSkinTone, setRosy, setEvenTone, setOverallIntensity. All parameters: BeautyParams.
Makeup, teeth and backlight
fv.setLipstick(BeautyColors.LIP_ROSE, 60) // shade, level
fv.setParams(fv.params.toBuilder().lipGloss(70).build())
fv.setTeethWhitening(50)
fv.setBacklightFix(50) // automatic, 0 = offfv.setLipstick(BeautyColors.lipRose, level: 60)
fv.setParams(fv.params.with { $0.lipGloss(70) })
fv.setTeethWhitening(50)
fv.setBacklightFix(50) // automatic, 0 = offfv.setLipstick(BeautyColors.LIP_ROSE, 60);
fv.setParams({ lipGloss: 70 });
fv.setTeethWhitening(50);
fv.setBacklightFix(50); // automatic, 0 = offawait fv.setLipstick(BeautyColors.rose, 60, gloss: 70);
await fv.updateParams({'teethWhitening': 50, 'backlightFix': 50});
await fv.clearLipstick();await fv.setLipstick(BeautyColors.ROSE, 60, 70); // shade, level, gloss
await fv.updateParams({ teethWhitening: 50, backlightFix: 50 });
await fv.clearLipstick();Shades: nude, rose, red, berry, coral, plum, or any colour with BeautyColors.rgb(r, g, b). The natural shade (0) enriches the lips' own colour. The lip region is computed from the current frame's lip contours, so the tint follows the mouth while the user speaks.
Colour filters
fv.setParams(fv.params.toBuilder().filter("warm", 50).build())fv.setParams(fv.params.with { $0.filter("warm", level: 50) })fv.setFilter('warm', 50);await fv.setFilter(BeautyFilters.warm, 50);await fv.setFilter('warm', 50);Filters: origin (none), natural, warm, cool, fresh, vivid, soft, rose, mono.
AR accessories
val props = fv.availableProps() // PropInfo(id, name, anchor)
fv.setProp("aviator") // false for an unknown id
fv.clearProp()
val icon = fv.propIcon("aviator") // 128x128 bitmap
fv.addPropsDirectory(File(filesDir, "props")) // your own packlet props = fv.availableProps()
fv.setProp("aviator")
fv.clearProp()
let icon = fv.propIconURL("aviator")
fv.addPropsDirectory(propsURL)const props = fv.availableProps(); // { id, name, anchor, iconUrl }
fv.setProp('aviator');
fv.clearProp();
await fv.addPropsPack('/my-props/');final props = await fv.availableProps();
await fv.setProp('aviator');
await fv.clearProp();
final icon = await fv.propIcon('aviator'); // PNG bytesconst props = await fv.availableProps();
await fv.setProp('aviator');
await fv.clearProp();
const uri = await fv.propIconUri('aviator'); // data URI for <Image>
await fv.addPropsDirectory(path);Built-in ids: aviator, wayfarer, sport_goggles, round_glasses, heart_glasses, crown, flower_headband, cat_ears, earring. Anchors: eyes, forehead, head_top, nose, ears, face. A prop is a folder with prop.json, prop.png and icon.png. Licence feature ar.props.
Capabilities
val caps = fv.capabilities()
fv.prepareCapabilities() // loads the segmenter early
fv.addCapabilitiesListener { c -> runOnUiThread { lipstickButton.isVisible = c.lipstickSupported } }let caps = fv.capabilities()
fv.prepareCapabilities()
fv.addCapabilitiesListener { c in DispatchQueue.main.async { self.lipstick.isHidden = !c.lipstickSupported } }const caps = fv.capabilities();
fv.addCapabilitiesListener((c) => { lipstickButton.hidden = !c.lipstickSupported; });final caps = await fv.capabilities();
fv.capabilityChanges.listen((c) => setState(() => _caps = c));const caps = await fv.capabilities();
const sub = fv.onCapabilitiesChange(setCaps); // sub.remove() on unmountFields: lipstickSupported (beauty.makeup), teethWhiteningSupported, backlightSupported, reshapeSupported (beauty.reshape), propsSupported (ar.props). Use them to hide controls the licence does not cover.
Frames
Android, iOS and Web take frames directly. Flutter and React Native process frames natively in their camera views and RTC hooks, so there is no frame call in Dart or JavaScript.
// texture path, on the GL thread
val out: Int = fv.processTexture(TextureFrame(oesTex, isOes = true, w, h, rotation, mirrored = front, ts, matrix))
// buffer path, any thread, in place
val changed: Boolean = fv.processBuffer(BufferFrame(bytes, PixelFormat.NV21, w, h, rotation, false, ts))// CVPixelBuffer (BGRA, NV12) in place, any thread
let changed = fv.processPixelBuffer(pixelBuffer, rotation: 90, timestampNs: ts)
fv.processPixelBuffer(input, into: output, rotation: 0, timestampNs: ts)
// Metal
let out: MTLTexture = fv.processTexture(texture, rotation: 0, commandBuffer: cmd)
// NV21 / NV12 / I420 bytes
fv.processBuffer(ptr, format: .i420, width: w, height: h, rotation: 0, timestampNs: ts)// a processed copy of a camera track
const processed: MediaStreamTrack = fv.createProcessedTrack(camera, { mirror: false });
// one frame: <video>, VideoFrame, ImageBitmap, canvas, image or ImageData
fv.processFrame(video, { output: canvas, mirror: true });
const out: VideoFrame = fv.processVideoFrame(frame);// camera preview
FacevityPreview(fit: BoxFit.cover)
// video calls: native hooks
await fv.rtc.agora.attach(appId: agoraAppId);
await fv.rtc.zego.attach();
await fv.rtc.webrtc.attachTrack(trackId);
await fv.rtc.livekit.attachTrack(trackId);// camera preview
<FacevityCameraView style={{ flex: 1 }} facing="front" />
// video calls: native hooks
await fv.rtc.agora.attach({ appId });
await fv.rtc.zego.attach();
await fv.rtc.webrtc.attachTrack(track);
await fv.rtc.livekit.attachTrack(track);- Rotation is how far the raw frame must turn clockwise to be upright. The output keeps the input orientation.
- Android texture path returns the input id when nothing was done, otherwise an engine-owned 2D texture (identity matrix, valid until the call after next).
OutputLayout.SAME_AS_INPUTkeeps theSurfaceTexturelayout.FrameOrientationhasuprightRotation,displayMatrixand camera-transform helpers;YuvPlanes.packI420/unpackI420handle strided planes. - Pass-through: when
isActiveis false (beauty off, all levels 0) frames come back untouched; skip conversions.
Licence
fv.setLicenseToken(token)
fv.setLicenseFile(context.assets.open("facevity.fvl"))
fv.activateLicense("FV-XXXX-XXXX-XXXX-XXXX") { info -> Log.i("App", "${info.status}") }
fv.addLicenseListener { info -> /* refresh, expiry, revocation */ }
val status = fv.licenseInfo.statusfv.setLicenseToken(token)
fv.setLicenseFile(url: Bundle.main.url(forResource: "facevity", withExtension: "fvl")!)
fv.activateLicense("FV-XXXX-XXXX-XXXX-XXXX") { info in print(info.status.name) }
fv.addLicenseListener { info in /* … */ }
let status = fv.licenseInfo.statusawait fv.setLicenseToken(token);
await fv.setLicenseFile(fvlContents);
await fv.activateLicense('FV-XXXX-XXXX-XXXX-XXXX');
fv.addLicenseListener((info) => console.log(info.status));
const status = fv.licenseInfo.status;await fv.setLicenseToken(token);
await fv.setLicenseFileFromAsset('assets/facevity/license.fvl');
await fv.activateLicense('FV-XXXX-XXXX-XXXX-XXXX');
fv.licenseChanges.listen((l) => print(l.status));
final info = await fv.licenseInfo();await fv.setLicenseToken(token);
await fv.setLicenseFile(fvlContents);
await fv.activateLicense('FV-XXXX-XXXX-XXXX-XXXX');
fv.onLicenseChange((l) => console.log(l.status));
const info = await fv.licenseInfo();A token that verifies replaces the cached one at once, so a freshly minted token with more features applies to the running engine. See Licensing.
Diagnostics and lifecycle
val s = fv.stats() // framesIn, framesProcessed, framesDropped, framesRepeated, avgProcessMs, processFps, …
fv.resetTracking() // after a camera switch
fv.onGlContextDestroyed() // on the GL thread, before the context goes away
fv.release()let s = fv.stats() // FacevityStats; lastError
fv.trackingMode = .sync // .sync, .tracked, .trackedRigid
fv.resetTracking()
fv.release()const s = fv.stats();
fv.resetTracking();
fv.setDebugMaskView(3); // 0 = off
fv.release();final s = await fv.stats(); // fps, ms per frame, faces, drops
await fv.resetTracking();
final rtc = await fv.rtc.status();
await fv.release();const s = await fv.stats();
await fv.resetTracking();
const rtc = await fv.rtc.status();
await fv.release();Debug views (setDebugMaskView(0..7)): 3 = final skin weight, 4 = segmentation, 5 = lipstick weight, 6 = backlight region, 7 = lip region.
BeautyParams
The same 21 parameters on every platform. Immutable and clamped on Android, iOS and Flutter; a plain object on Web and React Native.
| Parameter | Range | Default | Effect |
|---|---|---|---|
smooth | 0..100 | 55 | Skin smoothing |
brightness | 0..100 | 40 | Skin-only mid-tone lift |
skinTone | -100..100 | 0 | Cooler to warmer skin |
rosy | 0..100 | 42 | Healthy tint on mid-tones |
sharpen | 0..100 | 40 | Clarity on eyes, brows and hair |
eyeBrighten | 0..100 | 0 | Iris lift, whites cleared |
underEye | 0..100 | 43 | Dark circles |
evenTone | 0..100 | 30 | Redness and blotches |
foldSoften | 0..100 | 0 | Smile lines |
teethWhitening | 0..100 | 0 | Acts only while teeth show |
teethBrighten | 0..100 | 40 | Extra lift on whitened teeth |
backlightFix | 0..100 | 50 | Automatic; 0 = off |
lipColor | 0..100 | 0 | Natural lip boost, or lipstick opacity with a shade |
lipShade | 0xRRGGBB | natural | Lipstick shade (licence beauty.makeup) |
lipGloss | 0..100 | 30 | 0 matte to 100 gloss |
slimFace | 0..100 | 0 | Cheek slimming (beauty.reshape) |
jawSlim | 0..100 | 0 | Jaw, V-line (beauty.reshape) |
bigEyes | 0..100 | 0 | Eye enlarging (beauty.reshape) |
filter | id | origin | origin, natural, warm, cool, fresh, vivid, soft, rose, mono |
filterLevel | 0..100 | 54 | Filter strength |
overall | 0..100 | 100 | Scales every level at once |
Helpers: isIdentity, usesReshape, usesMakeup; Android toBuilder(), BeautyParams.Builder, fromUnit(Float); iOS with { }, BeautyParams.Builder; Flutter copyWith, withLipstick, withFilter; React Native Beauty.with, Beauty.withLipstick, Beauty.withFilter. NONE also turns backlight off.
Options
| Option | Values | Default | Platforms |
|---|---|---|---|
maxFaces | 1..4 | 1 | all |
detectionLongSide | 160..640 px | 320 | all |
segmentation | auto (GPU only), on, off | auto | all |
unlicensedBehavior | watermark, passthrough | watermark | all |
offlineGraceDays | 1..30 | 7 | all |
allowDevLicenses | unset = debug builds or dev hosts only | unset | all |
licenseToken, licenseServerUrl | token, URL (Web: licenseServer, licenseKey) | all | |
bufferBudgetMs, adaptiveBufferBudget, maxBufferBudgetMs, bufferPipelining | buffer-path timing | 40, on, 80, on | Android, Flutter, RN |
yuvFullRange | BT.601 full or video range | full | Android, iOS, Flutter, RN |
licenseAsset / licenseResource | bundled .fvl | facevity/license.fvl, facevity-license.fvl | Android / iOS |
detectorProvider | your own landmark provider | MediaPipe | iOS |
assetsBaseUrl, wasmBaseUrl, faceModelUrl, propsBaseUrl, faceSource | asset locations, your own landmarks | assets/ | Web |
Licence types
- LicenseStatus:
VALIDandOFFLINE_GRACEare licensed. Not licensed:NONE,EXPIRED,OFFLINE_GRACE_EXCEEDED,NOT_YET_VALID,INVALID_SIGNATURE,UNKNOWN_KEY,MALFORMED,WRONG_ISSUER,WRONG_AUDIENCE,WRONG_DEVICE,WRONG_CERTIFICATE,WRONG_ENVIRONMENT,SUSPENDED,REVOKED. Dart uses lowerCamelCase (LicenseStatus.wrongAudience). - LicenseInfo: status, type (
TRIAL,PRODUCTION,INTERNAL), environment, licence id, customer, features, issue and expiry dates, watermark, offline flag. - Features:
beauty.basic,beauty.reshape,buffer.path,beauty.segmentation,beauty.makeup,ar.props. See Licensing.
FaceUnity-style kit
On Android (com.knight98.facevity.kit), iOS and Web, the kit follows FaceUnity's call flow over the same engine:
FVRenderManager.setup(context, licenseToken, callback)
val kit = FVRenderKit.getInstance()
kit.aiKit.loadAIProcessor()
kit.faceBeauty = FVFaceBeauty().apply { smoothIntensity = 3.0 } // 0..6, 3.0 = natural
val out = kit.renderWithInput(input) // FVRenderInputData -> FVRenderOutputDataFVRenderManager.setup(licenseToken: token, callback: callback)
let kit = FVRenderKit.shared
kit.aiKit.loadAIProcessor()
kit.faceBeauty = FVFaceBeauty()
let out = kit.renderWithInput(input) // texture, CVPixelBuffer or bytesFVRenderManager.setup(token, callback);
const kit = FVRenderKit.getInstance();
kit.faceBeauty = new FVFaceBeauty();
kit.renderWithInput({ source: video, timestamp, mirror: true, output: canvas });Members: FVRenderManager.setup / setupWithKey, FVRenderKit (faceBeauty, aiKit, renderWithInput, setProp, capabilities(), release()), FVAIKit (loadAIProcessor, setMaxFaces, isTracking(), resetTrackStatus()), FVFaceBeauty with FaceUnity's value ranges, FVRenderInputData / FVRenderOutputData, FVCodes. Full mapping: Migrating from FaceUnity.
Need help with an integration? Contact the Facevity team. We answer integration questions during trials.