Compare commits
No commits in common. "master" and "dev_6.5.1" have entirely different histories.
@ -1,12 +1,12 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'img-optimizer'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply from: "../package_config.gradle"
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
|
||||
android {
|
||||
namespace "com.yunbao.faceunity"
|
||||
compileSdk rootProject.ext.android.compileSdkVersion
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
packagingOptions {
|
||||
pickFirst "lib/armeabi/libyuvutils.so"
|
||||
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
||||
@ -34,7 +34,6 @@ android {
|
||||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
// abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
|
||||
}
|
||||
}
|
||||
aaptOptions {
|
||||
@ -49,8 +48,8 @@ android {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_18
|
||||
targetCompatibility JavaVersion.VERSION_18
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
@ -59,15 +58,15 @@ repositories {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
api fileTree(dir: 'libs', include: ['*.jar'])
|
||||
api rootProject.ext.dependencies["appcompat-androidx"]
|
||||
api rootProject.ext.dependencies["recyclerview-androidx"]
|
||||
api "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies["appcompat-androidx"]
|
||||
implementation rootProject.ext.dependencies["recyclerview-androidx"]
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
//common
|
||||
api project(path: ':common')
|
||||
implementation project(path: ':common')
|
||||
|
||||
api 'com.faceunity:core:8.7.0'
|
||||
api 'com.faceunity:model:8.7.0'
|
||||
implementation 'com.faceunity:core:8.3.1'
|
||||
implementation 'com.faceunity:model:8.3.1'
|
||||
//implementation 'com.faceunity:nama:8.3.1' //底层库-标准版
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.yunbao.faceunity;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.Instrimport com.yunbao.common.utils.MobclickAgent;ntationRegistry;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.yunbao.faceunity"
|
||||
>
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
@ -38,6 +38,9 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCVideoOutputFrameListener;
|
||||
import cn.rongcloud.rtc.base.RCRTCVideoFrame;
|
||||
|
||||
/**
|
||||
* 美颜模块管理类
|
||||
@ -93,17 +96,11 @@ public class FaceManager implements SensorEventListener {
|
||||
faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() {
|
||||
@Override
|
||||
public void onPause() {
|
||||
if(onMirrorChanged!=null){
|
||||
onMirrorChanged.onChange(false);
|
||||
}
|
||||
pauseFace = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
if(onMirrorChanged!=null){
|
||||
onMirrorChanged.onChange(true);
|
||||
}
|
||||
pauseFace = false;
|
||||
}
|
||||
});
|
||||
@ -175,6 +172,44 @@ public class FaceManager implements SensorEventListener {
|
||||
private static final int CAMERA_SWITCH_SKIP_FRAME = 0;
|
||||
private volatile boolean mSkip;
|
||||
|
||||
/**
|
||||
* 渲染融云视频帧
|
||||
*/
|
||||
public void drawRongFrame(Context context) {
|
||||
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(new IRCRTCVideoOutputFrameListener() {
|
||||
@Override
|
||||
public RCRTCVideoFrame processVideoFrame(RCRTCVideoFrame callVideoFrame) {
|
||||
//Log.i(TAG, "processVideoFrame: egl context " + EGL14.eglGetCurrentContext());
|
||||
if (pauseFace) {
|
||||
return callVideoFrame;
|
||||
}
|
||||
int width = callVideoFrame.getWidth();
|
||||
int height = callVideoFrame.getHeight();
|
||||
|
||||
if (mIsFirstFrame) {
|
||||
mIsFirstFrame = false;
|
||||
//initCsvUtil(context);
|
||||
mFURenderer.prepareRenderer(mFURendererListener);
|
||||
}
|
||||
//long start = System.nanoTime();
|
||||
mFURenderer.setInputOrientation(callVideoFrame.getRotation());
|
||||
FURenderOutputData data = mFURenderer.onDrawFrameInputWithReturn(callVideoFrame.getData(), width, height);
|
||||
/* long time = System.nanoTime() - start;
|
||||
if (mCSVUtils != null) {
|
||||
mCSVUtils.writeCsv(null, time);
|
||||
}*/
|
||||
if (mSkippedFrames > 0 || mSkip) {
|
||||
--mSkippedFrames;
|
||||
return callVideoFrame;
|
||||
}
|
||||
if (data != null && data.getImage() != null && data.getImage().getBuffer() != null) {
|
||||
callVideoFrame.setData(data.getImage().getBuffer());
|
||||
}
|
||||
return callVideoFrame;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录渲染工具,调试用,在processVideoFrame里使用
|
||||
@ -237,6 +272,12 @@ public class FaceManager implements SensorEventListener {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 离开渲染界面时注销融云监听器,不然会绿屏
|
||||
*/
|
||||
public void onClose() {
|
||||
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoFrameListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放资源
|
||||
@ -254,18 +295,7 @@ public class FaceManager implements SensorEventListener {
|
||||
|
||||
}
|
||||
|
||||
OnMirrorChanged onMirrorChanged;
|
||||
|
||||
public void setOnMirrorChanged(OnMirrorChanged onMirrorChanged) {
|
||||
this.onMirrorChanged = onMirrorChanged;
|
||||
}
|
||||
|
||||
public interface FaceStatusChanged {
|
||||
void onFaceChanged(int num);
|
||||
}
|
||||
|
||||
|
||||
public interface OnMirrorChanged{
|
||||
void onChange(boolean falg);
|
||||
}
|
||||
}
|
||||
|
@ -52,11 +52,11 @@ public class FURenderer extends IFURenderer {
|
||||
|
||||
|
||||
/* 特效FURenderKit*/
|
||||
public FURenderKit mFURenderKit;
|
||||
private FURenderKit mFURenderKit;
|
||||
|
||||
/* AI道具*/
|
||||
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
|
||||
public static String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
|
||||
private String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
|
||||
private String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
|
||||
|
||||
/* GL 线程 ID */
|
||||
private Long mGlThreadId = 0L;
|
||||
|
@ -15,7 +15,7 @@ public class FaceUnityConfig {
|
||||
|
||||
/************************** 算法Model ******************************/
|
||||
// 人脸识别
|
||||
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
|
||||
public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
|
||||
// 手势
|
||||
public static String BUNDLE_AI_HAND = "model" + File.separator + "ai_hand_processor.bundle";
|
||||
|
||||
|
@ -314,35 +314,6 @@ public class FileUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String copyAssetsFile(Context context, String assetsPath, String fileName, String saveFileDir) {
|
||||
File fileDir = new File(saveFileDir);
|
||||
if (!fileDir.exists()) {
|
||||
fileDir.mkdirs();
|
||||
}
|
||||
File file = new File(fileDir, fileName);
|
||||
if (file.exists()) {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
try {
|
||||
InputStream inputStream = context.getAssets().open(assetsPath);
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
BufferedInputStream bis = new BufferedInputStream(inputStream);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos);
|
||||
byte[] byteArray = new byte[1024];
|
||||
int bytes = bis.read(byteArray);
|
||||
while (bytes > 0) {
|
||||
bos.write(byteArray, 0, bytes);
|
||||
bos.flush();
|
||||
bytes = bis.read(byteArray);
|
||||
}
|
||||
bos.close();
|
||||
fos.close();
|
||||
return file.getAbsolutePath();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Uri文件绝对路径
|
||||
@ -551,7 +522,6 @@ public class FileUtils {
|
||||
|
||||
/**
|
||||
* 遍历一个文件夹获取改文件夹下所有文件名
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.yunbao.common.utils;
|
||||
package com.yunbao.faceunity.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -152,36 +151,16 @@ public class ZipUtils {
|
||||
* @param zipFileString 解压完成的Zip路径
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void zipFolder(List<String> srcFileString, String zipFileString, List<String> filters, Runnable runnable) throws Exception {
|
||||
if (filters == null) {
|
||||
filters = new ArrayList<>();
|
||||
}
|
||||
filters.add(new File(zipFileString).getAbsolutePath());
|
||||
final List<String> tmp = new ArrayList<>(filters);
|
||||
public static void zipFolder(String srcFileString, String zipFileString) throws Exception {
|
||||
//创建ZIP
|
||||
ZipOutputStream outZip = new ZipOutputStream(new FileOutputStream(zipFileString));
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (String src : srcFileString) {
|
||||
File file = new File(src);
|
||||
//压缩
|
||||
zipFiles(file.getParent() + File.separator, file.getName(), outZip, tmp);
|
||||
}
|
||||
//创建文件
|
||||
File file = new File(srcFileString);
|
||||
//压缩
|
||||
zipFiles(file.getParent() + File.separator, file.getName(), outZip);
|
||||
//完成和关闭
|
||||
outZip.finish();
|
||||
outZip.close();
|
||||
runnable.run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,15 +171,9 @@ public class ZipUtils {
|
||||
* @param zipOutputSteam
|
||||
* @throws Exception
|
||||
*/
|
||||
private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam, List<String> filters) throws Exception {
|
||||
private static void zipFiles(String folderString, String fileString, ZipOutputStream zipOutputSteam) throws Exception {
|
||||
if (zipOutputSteam == null)
|
||||
return;
|
||||
for (String filter : filters) {
|
||||
if (fileString.startsWith(filter)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("压缩文件:" + folderString + "|" + fileString);
|
||||
File file = new File(folderString + fileString);
|
||||
if (file.isFile()) {
|
||||
ZipEntry zipEntry = new ZipEntry(fileString);
|
||||
@ -223,7 +196,7 @@ public class ZipUtils {
|
||||
}
|
||||
//子文件和递归
|
||||
for (int i = 0; i < fileList.length; i++) {
|
||||
zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam, filters);
|
||||
zipFiles(folderString, fileString + File.separator + fileList[i], zipOutputSteam);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import com.google.gson.JsonObject;
|
||||
import com.yunbao.faceunity.entity.net.FineStickerEntity;
|
||||
import com.yunbao.faceunity.utils.FaceUnityData;
|
||||
import com.yunbao.faceunity.utils.FileUtils;
|
||||
import com.yunbao.common.utils.ZipUtils;
|
||||
import com.yunbao.faceunity.utils.ZipUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_animoji.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_beauty.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.3 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_beauty_body.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_big_head.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_fine_sticker.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.2 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_makeup.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/ico_home_sticker.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 1.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_baihu.png
Normal file
After Width: | Height: | Size: 276 KiB |
Before Width: | Height: | Size: 58 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_baimao.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 163 KiB |
Before Width: | Height: | Size: 131 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_douniuquan.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_frog_st.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 7.9 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_hashiqi.png
Normal file
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_hetun.png
Normal file
After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.1 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_huangya.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_kaola.png
Normal file
After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 14 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_kuloutou.png
Normal file
After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 9.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_qgirl.png
Normal file
After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 5.8 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_animoji_wuxia.png
Normal file
After Width: | Height: | Size: 128 KiB |
Before Width: | Height: | Size: 107 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_baozi.png
Normal file
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 19 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_bluebird.png
Normal file
After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 8.7 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_fenhudie.png
Normal file
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 9.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_lanhudie.png
Normal file
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 9.5 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger.png
Normal file
After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 19 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger_bai.png
Normal file
After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_tiger_huang.png
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_ar_xiongmao.png
Normal file
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 16 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_avatar_female.png
Normal file
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB |
BIN
FaceUnity/src/main/res/mipmap-xxhdpi/icon_avatar_male.png
Normal file
After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 3.6 KiB |