Camera.setBeautifyParam 收藏我的收藏
收藏我的收藏
基础库 1.40.0 开始支持本方法,这是一个同步方法。
设置美颜参数。
| 前提条件 | 只有 Camera.start 开启摄像头美白后, 调用该接口  才能设置美白参数 | 
| 业务背景 | 无 | 
| 使用限制 | 无 | 
| 注意事项 | 无 | 
| 相关教程 | 无 | 
语法
Camera.setBeautifyParam(whiten, smoothen, enlargeEye, slimFace)
参数说明
whiten
| 类型 | 默认值 | 必填 | 说明 | 最低支持版本 | 
|---|---|---|---|---|
| number | 是 | 美白程度,范围[0-1] | 1.40.0 | 
smoothen
| 类型 | 默 认值 | 必填 | 说明 | 最低支持版本 | 
|---|---|---|---|---|
| number | 是 | 磨皮程度,范围[0-1] | 1.40.0 | 
enlargeEye
| 类型 | 默认值 | 必填 | 说明 | 最低支持版本 | 
|---|---|---|---|---|
| number | 是 | 大眼程度,范围[0-1] | 1.40.0 | 
slimFace
| 类型 | 默认值 | 必填 | 说明 | 最低支持版本 | 
|---|---|---|---|---|
| number | 是 | 瘦脸程度,范围[0-1] | 1.40.0 | 
返回值
无
代码示例
console.log("开发字节跳动小游戏过程中可以参考以下文档:"); console.log("https://developer.toutiao.com/docs/game/"); const canvas = tt.createCanvas(); const ctx = canvas.getContext("2d"); const camera = tt.createCamera(); console.log("camera", camera); camera.setBeautifyParam(0.8, 0.79, 0.4, 0.58); camera .start("front", true, { matting: true }) .then((video) => { draw(video); }) .catch((err) => { tt.showToast({ title: "相机需要授权", }); console.log(err); }); // 3s 后暂停摄像头视频画面 setTimeout(() => { camera.pause(); }, 3000); function draw(video) { let scale = video.videoHeight / video.videoWidth; video && ctx.drawImage( video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, canvas.width, canvas.width * scale, ); requestAnimationFrame(function () { draw(video); }); }
