Skip to content

Commit 4fe7208

Browse files
committed
feat: update beauty sdk to 1.0.7
1 parent f2d34ef commit 4fe7208

18 files changed

Lines changed: 733 additions & 147 deletions

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/ByteDanceBeautySDK.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,20 @@ object ByteDanceBeautySDK {
3737
assetsPath = "beauty_bytedance"
3838

3939
// copy license
40-
licensePath = "$storagePath/beauty_bytedance/LicenseBag.bundle"
41-
FileUtils.copyFilesFromAssets(context, "$assetsPath/LicenseBag.bundle", licensePath)
42-
licensePath += "/$LICENSE_NAME"
40+
licensePath = "$storagePath/beauty_bytedance/LicenseBag.bundle/$LICENSE_NAME"
41+
FileUtils.copyAssets(context, "$assetsPath/LicenseBag.bundle/$LICENSE_NAME", licensePath)
4342
if (!File(licensePath).exists()) {
4443
return false
4544
}
4645

4746
// copy models
4847
modelsPath = "$storagePath/beauty_bytedance/ModelResource.bundle"
49-
FileUtils.copyFilesFromAssets(context, "$assetsPath/ModelResource.bundle", modelsPath)
48+
FileUtils.copyAssets(context, "$assetsPath/ModelResource.bundle", modelsPath)
5049

5150
// copy beauty node
5251
beautyNodePath =
5352
"$storagePath/beauty_bytedance/ComposeMakeup.bundle/ComposeMakeup/beauty_Android_lite"
54-
FileUtils.copyFilesFromAssets(
53+
FileUtils.copyAssets(
5554
context,
5655
"$assetsPath/ComposeMakeup.bundle/ComposeMakeup/beauty_Android_lite",
5756
beautyNodePath
@@ -60,7 +59,7 @@ object ByteDanceBeautySDK {
6059
// copy beauty 4items node
6160
beauty4ItemsNodePath =
6261
"$storagePath/beauty_bytedance/ComposeMakeup.bundle/ComposeMakeup/beauty_4Items"
63-
FileUtils.copyFilesFromAssets(
62+
FileUtils.copyAssets(
6463
context,
6564
"$assetsPath/ComposeMakeup.bundle/ComposeMakeup/beauty_4Items",
6665
beauty4ItemsNodePath
@@ -69,27 +68,27 @@ object ByteDanceBeautySDK {
6968
// copy resharp node
7069
reSharpNodePath =
7170
"$storagePath/beauty_bytedance/ComposeMakeup.bundle/ComposeMakeup/reshape_lite"
72-
FileUtils.copyFilesFromAssets(
71+
FileUtils.copyAssets(
7372
context,
7473
"$assetsPath/ComposeMakeup.bundle/ComposeMakeup/reshape_lite",
7574
reSharpNodePath
7675
)
7776

7877
// copy stickers
7978
stickerPath = "$storagePath/beauty_bytedance/StickerResource.bundle/stickers"
80-
FileUtils.copyFilesFromAssets(context, "$assetsPath/StickerResource.bundle/stickers", stickerPath)
79+
FileUtils.copyAssets(context, "$assetsPath/StickerResource.bundle/stickers", stickerPath)
8180

8281
return true
8382
}
8483

8584
// GL Thread
86-
fun initEffect(context: Context) {
85+
fun initEffect(context: Context) : Boolean{
8786
val ret = renderManager.init(
8887
context,
8988
modelsPath, licensePath, false, false, 0
9089
)
9190
if (!checkResult("RenderManager init ", ret)) {
92-
return
91+
return false
9392
}
9493
renderManager.useBuiltinSensor(true)
9594
renderManager.set3Buffer(false)
@@ -99,6 +98,7 @@ object ByteDanceBeautySDK {
9998
)
10099
renderManager.loadResourceWithTimeout(-1)
101100
beautyConfig.resume()
101+
return true
102102
}
103103

104104
// GL Thread
@@ -139,7 +139,7 @@ object ByteDanceBeautySDK {
139139
}
140140

141141
internal fun setBeautyAPI(beautyAPI: ByteDanceBeautyAPI?) {
142-
this.beautyAPI = beautyAPI
142+
ByteDanceBeautySDK.beautyAPI = beautyAPI
143143
}
144144

145145
private fun runOnBeautyThread(run: () -> Unit) {
@@ -411,7 +411,7 @@ object ByteDanceBeautySDK {
411411
if (value != null) {
412412
val nodePath =
413413
"$storagePath/beauty_bytedance/ComposeMakeup.bundle/ComposeMakeup/style_makeup/${value.style}"
414-
FileUtils.copyFilesFromAssets(
414+
FileUtils.copyAssets(
415415
value.context,
416416
"$assetsPath/ComposeMakeup.bundle/ComposeMakeup/style_makeup/${value.style}",
417417
nodePath

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/FaceUnityBeautySDK.kt

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ object FaceUnityBeautySDK {
3131

3232
private var beautyAPI: FaceUnityBeautyAPI? = null
3333

34+
private var authSuccess = false
35+
3436
fun initBeauty(context: Context): Boolean {
3537
val auth = try {
3638
getAuth()
@@ -45,13 +47,14 @@ object FaceUnityBeautySDK {
4547
override fun onSuccess(code: Int, msg: String) {
4648
Log.i(TAG, "FURenderManager onSuccess -- code=$code, msg=$msg")
4749
if (code == OPERATE_SUCCESS_AUTH) {
48-
faceunity.fuSetUseTexAsync(1)
50+
authSuccess = true
51+
faceunity.fuSetUseTexAsync(0)
4952
FUAIKit.getInstance()
5053
.loadAIProcessor(BUNDLE_AI_FACE, FUAITypeEnum.FUAITYPE_FACEPROCESSOR)
51-
FUAIKit.getInstance().loadAIProcessor(
52-
BUNDLE_AI_HUMAN,
53-
FUAITypeEnum.FUAITYPE_HUMAN_PROCESSOR
54-
)
54+
// FUAIKit.getInstance().loadAIProcessor(
55+
// BUNDLE_AI_HUMAN,
56+
// FUAITypeEnum.FUAITYPE_HUMAN_PROCESSOR
57+
// )
5558

5659
}
5760
}
@@ -63,9 +66,14 @@ object FaceUnityBeautySDK {
6366
return true
6467
}
6568

69+
fun isAuthSuccess(): Boolean {
70+
return authSuccess
71+
}
72+
6673
fun unInitBeauty() {
6774
beautyAPI = null
6875
beautyConfig.reset()
76+
authSuccess = false
6977
FUAIKit.getInstance().releaseAllAIProcessor()
7078
FURenderKit.getInstance().release()
7179
}
@@ -77,8 +85,9 @@ object FaceUnityBeautySDK {
7785
return aMethod.invoke(null) as? ByteArray
7886
}
7987

80-
internal fun setBeautyAPI(beautyAPI: FaceUnityBeautyAPI) {
81-
this.beautyAPI = beautyAPI
88+
internal fun setBeautyAPI(beautyAPI: FaceUnityBeautyAPI?) {
89+
FaceUnityBeautySDK.beautyAPI = beautyAPI
90+
beautyConfig.resume()
8291
}
8392

8493
private fun runOnBeautyThread(run: () -> Unit) {
@@ -312,6 +321,28 @@ object FaceUnityBeautySDK {
312321
sticker = null
313322
}
314323

324+
fun resume(){
325+
smooth = smooth
326+
whiten = whiten
327+
thinFace = thinFace
328+
enlargeEye = enlargeEye
329+
redden = redden
330+
shrinkCheekbone = shrinkCheekbone
331+
shrinkJawbone = shrinkJawbone
332+
whiteTeeth = whiteTeeth
333+
hairlineHeight = hairlineHeight
334+
narrowNose = narrowNose
335+
mouthSize = mouthSize
336+
chinLength = chinLength
337+
brightEye = brightEye
338+
darkCircles = darkCircles
339+
nasolabialFolds = nasolabialFolds
340+
faceThree = faceThree
341+
342+
makeUp = makeUp
343+
sticker = sticker
344+
}
345+
315346
}
316347

317348
data class MakeUpItem(

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/beauty/SenseTimeBeautySDK.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,25 @@ object SenseTimeBeautySDK {
5555

5656
private var beautyAPI: SenseTimeBeautyAPI? = null
5757

58+
private var authSuccess = false
59+
5860
fun initBeautySDK(context: Context): Boolean {
5961
if (checkLicense(context)) {
6062
initHumanAction(context)
63+
authSuccess = true
6164
return true
6265
}
66+
initHumanAction(context)
6367
return false
6468
}
6569

70+
fun isAuthSuccess(): Boolean {
71+
return authSuccess
72+
}
73+
6674
fun unInitBeautySDK() {
6775
beautyAPI = null
76+
authSuccess = false
6877
unInitHumanActionNative()
6978
beautyConfig.reset()
7079
}
@@ -78,6 +87,7 @@ object SenseTimeBeautySDK {
7887
_mobileEffectNative?.createInstance(context, STMobileEffectNative.EFFECT_CONFIG_NONE)
7988
_mobileEffectNative?.setParam(STMobileEffectParams.EFFECT_PARAM_QUATERNION_SMOOTH_FRAME, 5f)
8089
Log.d(TAG, "SenseTime >> STMobileEffectNative create result : $result")
90+
beautyConfig.resume()
8191
}
8292

8393
fun unInitMobileEffect() {
@@ -98,8 +108,8 @@ object SenseTimeBeautySDK {
98108
license,
99109
license.length
100110
)
101-
Log.d(TAG, "SenseTime >> checkLicense successfully! activeCode=$activeCode")
102-
return true
111+
Log.d(TAG, "SenseTime >> checkLicense activeCode=$activeCode")
112+
return activeCode.isNotEmpty()
103113
}
104114

105115
private fun initHumanAction(context: Context) {
@@ -147,8 +157,8 @@ object SenseTimeBeautySDK {
147157
}
148158

149159

150-
internal fun setBeautyAPI(beautyAPI: SenseTimeBeautyAPI){
151-
this.beautyAPI = beautyAPI
160+
internal fun setBeautyAPI(beautyAPI: SenseTimeBeautyAPI?){
161+
SenseTimeBeautySDK.beautyAPI = beautyAPI
152162
beautyConfig.resume()
153163
}
154164

Android/APIExample/app/src/main/java/io/agora/api/example/utils/FileUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public static void copyFilesFromAssets(Context context, String assetsPath, Strin
8686

8787
}
8888

89+
public static void copyAssets(Context context, String assetsPath, String storagePath) {
90+
copyFilesFromAssets(context, assetsPath, storagePath);
91+
}
92+
93+
8994
/**
9095
* 读取输入流中的数据写入输出流
9196
*

Android/APIExample/app/src/main/java/io/agora/beautyapi/bytedance/ByteDanceBeautyAPI.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import io.agora.base.VideoFrame
3131
import io.agora.rtc2.Constants
3232
import io.agora.rtc2.RtcEngine
3333

34-
const val VERSION = "1.0.6"
34+
const val VERSION = "1.0.7"
3535

3636
enum class CaptureMode{
3737
Agora, // 使用声网内部的祼数据接口进行处理

0 commit comments

Comments
 (0)