Skip to content

Commit c635d18

Browse files
doggycoderaiyaapp
authored andcommitted
update to v3.4.0 (#30)
* add the func to remove filter * change interface and update so * change interface and update so * change so,update to v3.4.0alpha * fix smooth bug. etc * fix smooth bug. etc * Update readme.md * Update readme_en.md * refresh config data when version update * update to v3.4.0 * update readme
1 parent 3b3cd05 commit c635d18

File tree

11 files changed

+97
-80
lines changed

11 files changed

+97
-80
lines changed

AiyaEffectsSDK/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ android {
1414
versionName rootProject.ext.vName
1515

1616
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17-
17+
buildConfigField("String","AiyaSDKVersionName","\""+rootProject.ext.vName+"\"")
1818
}
1919
buildTypes {
2020
release {

AiyaEffectsSDK/src/main/java/com/aiyaapp/camera/sdk/AiyaEffects.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.concurrent.Semaphore;
1616

1717
import android.content.Context;
18+
import android.content.SharedPreferences;
1819
import android.os.Handler;
1920
import android.os.HandlerThread;
2021
import android.telephony.TelephonyManager;
@@ -29,6 +30,7 @@
2930
import com.aiyaapp.camera.sdk.base.ActionObservable;
3031
import com.aiyaapp.camera.sdk.base.ActionObserver;
3132
import com.aiyaapp.camera.sdk.base.TrackCallback;
33+
import com.aiyaapp.sticker.sdk.BuildConfig;
3234

3335
/**
3436
* Sdk的核心接口,将工作线程、GL线程、人脸追踪线程分开,
@@ -120,10 +122,17 @@ private void cInit(){
120122
mTrackExecutor= Executors.newFixedThreadPool(1);
121123
}
122124

123-
private boolean prepareResource(Context context,String licensePath){
124-
Log.d("prepare Resource");
125-
Assets assets=new Assets(context,licensePath);
126-
return assets.doCopy();
125+
private boolean prepareResource(Context context,String licensePath) {
126+
Assets assets = new Assets(context, licensePath);
127+
SharedPreferences sp = context.getSharedPreferences("AiyaSDKVersion", Context.MODE_PRIVATE);
128+
Log.d("last sdk version:"+sp.getString("v","none"));
129+
Log.d("now sdk version:"+BuildConfig.AiyaSDKVersionName);
130+
if (!sp.getString("v", "").equals(BuildConfig.AiyaSDKVersionName)) {
131+
assets.clearCache();
132+
sp.edit().putString("v", BuildConfig.AiyaSDKVersionName).apply();
133+
}
134+
return new File(licensePath).exists() || assets.doCopy();
135+
127136
}
128137

129138
@SuppressLint("HardwareIds")
@@ -142,12 +151,7 @@ public void init(final Context context,final String configPath,final String appK
142151
@Override
143152
public void run() {
144153
Log.e("start prepare resource");
145-
boolean pb;
146-
if(new File(configPath).exists()){
147-
pb=true;
148-
}else{
149-
pb=prepareResource(context,configPath);
150-
}
154+
boolean pb=prepareResource(context,configPath);
151155
Log.e("prepare resource success:"+pb);
152156
if(pb){
153157
mObservable.notifyState(new Event(Event.RESOURCE_READY,Event.RESOURCE_READY,"资源准备完成",null));

AiyaEffectsSDK/src/main/java/com/aiyaapp/camera/sdk/base/Assets.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ public boolean doCopy() {
6767
return a;
6868
}
6969

70+
public void clearCache(){
71+
deleteFile(rootDir);
72+
}
73+
7074
private boolean copyForSticker(){
7175
Log.d("check data for sticker");
7276
return copyFileFromAssets("modelsticker",getSD()+"/AiyaCamera/model_sticker");

AiyaEffectsSDK/src/main/java/com/aiyaapp/camera/sdk/filter/GroupFilter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.ArrayList;
1111
import java.util.List;
1212
import java.util.Queue;
13+
import java.util.Vector;
1314
import java.util.concurrent.ConcurrentLinkedQueue;
1415

1516
import android.content.res.Resources;
@@ -25,7 +26,7 @@ public class GroupFilter extends AFilter{
2526

2627
public GroupFilter(Resources res) {
2728
super(res);
28-
mFilters=new ArrayList<>();
29+
mFilters=new Vector<>();
2930
mFilterQueue=new ConcurrentLinkedQueue<>();
3031
}
3132

@@ -67,7 +68,8 @@ public void draw(){
6768
updateFilter();
6869
textureIndex=0;
6970
GLES20.glViewport(0,0,width,height);
70-
for (AFilter filter:mFilters){
71+
for (int i=0;i<mFilters.size();i++){
72+
AFilter filter=mFilters.get(i);
7173
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fFrame[0]);
7274
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
7375
GLES20.GL_TEXTURE_2D, fTexture[textureIndex%2], 0);

AiyaEffectsSDK/src/main/java/com/aiyaapp/camera/sdk/widget/AiyaCameraView.java

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ public class AiyaCameraView extends GLSurfaceView implements GLSurfaceView.Rende
6464
private int[] fFrame = new int[1];
6565
private int[] fTexture = new int[1];
6666

67+
private Runnable callbackIfCameraOpenFailed;
68+
6769
public AiyaCameraView(Context context) {
6870
this(context,null);
6971
}
@@ -101,6 +103,10 @@ public void onResume() {
101103
}
102104
}
103105

106+
public void setCameraOpenFaildCallback(Runnable runnable){
107+
callbackIfCameraOpenFailed=runnable;
108+
}
109+
104110
public AiyaCamera getCamera(){
105111
return mCamera;
106112
}
@@ -124,36 +130,42 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
124130

125131
private void open(final int cameraId){
126132
mCamera.close();
127-
mCamera.open(cameraId);
128-
mEffectFilter.setFlag(cameraId);
129-
final Point previewSize=mCamera.getPreviewSize();
130-
dataWidth=previewSize.x;
131-
dataHeight=previewSize.y;
132-
//预览大小被更改时,回调不为空,需要重新计算最后的导出矩阵
133-
if(mFrameCallback!=null){
134-
setFrameCallback(frameCallbackWidth,frameCallbackHeight,mFrameCallback);
135-
}
136-
if(cameraBuffer==null){
137-
cameraBuffer=new byte[3][dataWidth*dataHeight*4];
138-
}
139-
for (int i=0;i<3;i++){
140-
mCamera.addBuffer(cameraBuffer[i]);
141-
}
142-
mCamera.setOnPreviewFrameCallbackWithBuffer(new AiyaCamera.PreviewFrameCallback() {
143-
144-
@Override
145-
public void onPreviewFrame(byte[] bytes, int width, int height) {
146-
EData.data.setCameraCallbackTime(System.currentTimeMillis());
147-
if(isSetParm){
148-
mBytesQueue.add(bytes);
149-
requestRender();
150-
}else{
151-
mCamera.addBuffer(bytes);
133+
try {
134+
mCamera.open(cameraId);
135+
mEffectFilter.setFlag(cameraId);
136+
final Point previewSize=mCamera.getPreviewSize();
137+
dataWidth=previewSize.x;
138+
dataHeight=previewSize.y;
139+
//预览大小被更改时,回调不为空,需要重新计算最后的导出矩阵
140+
if(mFrameCallback!=null){
141+
setFrameCallback(frameCallbackWidth,frameCallbackHeight,mFrameCallback);
142+
}
143+
if(cameraBuffer==null){
144+
cameraBuffer=new byte[3][dataWidth*dataHeight*4];
145+
}
146+
for (int i=0;i<3;i++){
147+
mCamera.addBuffer(cameraBuffer[i]);
148+
}
149+
mCamera.setOnPreviewFrameCallbackWithBuffer(new AiyaCamera.PreviewFrameCallback() {
150+
151+
@Override
152+
public void onPreviewFrame(byte[] bytes, int width, int height) {
153+
EData.data.setCameraCallbackTime(System.currentTimeMillis());
154+
if(isSetParm){
155+
mBytesQueue.add(bytes);
156+
requestRender();
157+
}else{
158+
mCamera.addBuffer(bytes);
159+
}
152160
}
161+
});
162+
mCamera.setPreviewTexture(mEffectFilter.getTexture());
163+
mCamera.preview();
164+
}catch (Exception e){
165+
if(callbackIfCameraOpenFailed!=null){
166+
callbackIfCameraOpenFailed.run();
153167
}
154-
});
155-
mCamera.setPreviewTexture(mEffectFilter.getTexture());
156-
mCamera.preview();
168+
}
157169
}
158170

159171
public void switchCamera(){

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ buildscript {
1717
}
1818

1919
ext{
20-
vCode=334
21-
vName="v3.4.0beta"
20+
vCode=340
21+
vName="v3.4.0"
2222
}
2323

2424

demo/src/main/assets/modelsticker/fadai/fadai_blue.mtl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@ Ka 0.00 0.00 0.00
55
Tf 1.00 1.00 1.00
66
map_Kd fadai_000.png
77
Ni 1.00
8-
newmtl initialShadingGroup
9-
illum 4
10-
Kd 0.50 0.50 0.50
11-
Ka 0.00 0.00 0.00
12-
Tf 1.00 1.00 1.00
13-
Ni 1.00

demo/src/main/assets/modelsticker/fadai/fadai_blue.obj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
mtllib fadai_blue.mtl
44
g default
5-
v -0.076437 0.061274 -0.040172
6-
v 0.107236 0.061274 -0.040172
7-
v -0.076437 0.170142 -0.040172
8-
v 0.107236 0.170142 -0.040172
5+
v -0.080437 0.061274 -0.040172
6+
v 0.103236 0.061274 -0.040172
7+
v -0.080437 0.170142 -0.040172
8+
v 0.103236 0.170142 -0.040172
99
vt 0.000000 0.000000
1010
vt 1.000000 0.000000
1111
vt 1.000000 1.000000

demo/src/main/assets/modelsticker/giraffe/giraffe.obj

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
mtllib giraffe.mtl
44
g default
5-
v -0.154348 -0.132939 -0.072972
6-
v 0.178348 -0.132939 -0.072972
7-
v -0.154348 0.060025 -0.072972
8-
v 0.178348 0.060025 -0.072972
5+
v -0.018623 -0.047069 0.018714
6+
v 0.026623 -0.047069 0.018714
7+
v -0.018623 -0.007145 0.018714
8+
v 0.026623 -0.007145 0.018714
99
vt 0.000000 0.000000
1010
vt 1.000000 0.000000
1111
vt 1.000000 1.000000
@@ -15,14 +15,14 @@ vn 0.000000 0.000000 1.000000
1515
vn 0.000000 0.000000 1.000000
1616
vn 0.000000 0.000000 1.000000
1717
s off
18-
g giraffe:pPlane4
19-
usemtl giraffe:lambert3SG
18+
g bizi
19+
usemtl giraffe:phong1SG
2020
f 1/1/1 2/2/2 4/3/3 3/4/4
2121
g default
22-
v -0.154348 0.023378 -0.054608
23-
v 0.178348 0.023378 -0.054608
24-
v -0.154348 0.168433 -0.054608
25-
v 0.178348 0.168433 -0.054608
22+
v -0.076345 -0.054438 -0.000141
23+
v 0.072703 -0.054438 -0.000141
24+
v -0.076345 -0.001206 -0.000141
25+
v 0.072703 -0.001206 -0.000141
2626
vt 0.000000 0.000000
2727
vt 1.000000 0.000000
2828
vt 1.000000 1.000000
@@ -32,14 +32,14 @@ vn 0.000000 0.000000 1.000000
3232
vn 0.000000 0.000000 1.000000
3333
vn 0.000000 0.000000 1.000000
3434
s off
35-
g giraffe:pPlane6
36-
usemtl giraffe:lambert5SG
35+
g saihong
36+
usemtl giraffe:lambert4SG
3737
f 5/5/5 6/6/6 8/7/7 7/8/8
3838
g default
39-
v -0.062524 -0.054438 -0.000141
40-
v 0.086524 -0.054438 -0.000141
41-
v -0.062524 -0.001206 -0.000141
42-
v 0.086524 -0.001206 -0.000141
39+
v -0.162348 0.023378 -0.054608
40+
v 0.170348 0.023378 -0.054608
41+
v -0.162348 0.168433 -0.054608
42+
v 0.170348 0.168433 -0.054608
4343
vt 0.000000 0.000000
4444
vt 1.000000 0.000000
4545
vt 1.000000 1.000000
@@ -49,14 +49,14 @@ vn 0.000000 0.000000 1.000000
4949
vn 0.000000 0.000000 1.000000
5050
vn 0.000000 0.000000 1.000000
5151
s off
52-
g giraffe:pPlane5
53-
usemtl giraffe:lambert4SG
52+
g erduo
53+
usemtl giraffe:lambert5SG
5454
f 9/9/9 10/10/10 12/11/11 11/12/12
5555
g default
56-
v -0.010623 -0.047069 0.018714
57-
v 0.034623 -0.047069 0.018714
58-
v -0.010623 -0.007145 0.018714
59-
v 0.034623 -0.007145 0.018714
56+
v -0.162348 -0.132939 -0.072972
57+
v 0.170348 -0.132939 -0.072972
58+
v -0.162348 0.060025 -0.072972
59+
v 0.170348 0.060025 -0.072972
6060
vt 0.000000 0.000000
6161
vt 1.000000 0.000000
6262
vt 1.000000 1.000000
@@ -66,6 +66,6 @@ vn 0.000000 0.000000 1.000000
6666
vn 0.000000 0.000000 1.000000
6767
vn 0.000000 0.000000 1.000000
6868
s off
69-
g giraffe:pPlane3
70-
usemtl giraffe:phong1SG
69+
g mian
70+
usemtl giraffe:lambert3SG
7171
f 13/13/13 14/14/14 16/15/15 15/16/16

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See [English Document](readme_en.md)
1111
宝宝特效 AiyaEffectsSDK 涵盖Android、iOS两个平台,基于自主研发的人脸识别模块,作为一款动态贴纸和动画特效高效渲染的解决方案
1212

1313
### 1.1 版本信息
14-
**当前版本:AiyaEffects SDK V3.3.0** [查看历史版本](https://github.com/aiyaapp/AiyaEffectsAndroid/wiki/%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC)
14+
**当前版本:AiyaEffects SDK V3.4.0** [查看历史版本](https://github.com/aiyaapp/AiyaEffectsAndroid/wiki/%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC)
1515

1616
### 1.2 集成示例
1717
* [集成到金山云的示例](https://github.com/aiyaapp/AiyaEffectsWithKSVCAndroid)
@@ -47,6 +47,6 @@ Android版AiyaEffectsSDK minSdkVersion为18,即Android4.3以上可用。
4747
## 8. 反馈与建议
4848
- 主页: [宝宝特效](http://www.bbtexiao.com)
4949
- 邮箱: <liudawei@aiyaapp.com>
50-
- QQ讨论群: 建设中
50+
- QQ讨论群: 650242833
5151

5252
<a href="http://www.bbtexiao.com/"><img src="doc/logo.png" border="0" alt="宝宝特效" /></a>

0 commit comments

Comments
 (0)