Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_yitu
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_yitu
Commits
990f2baf
Commit
990f2baf
authored
Aug 13, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
yitu bug fix
parent
c5789880
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
0 deletions
+136
-0
src/main/AndroidManifest.xml
+4
-0
src/main/java/com/oliveapp/liveness/sample/liveness/view_controller/LivenessDetectionActivity.java
+120
-0
src/main/java/com/oliveapp/liveness/sample/liveness/view_controller/LivenessDetectionMainActivity.java
+1
-0
src/main/res/values/oliveapp_strings.xml
+11
-0
No files found.
src/main/AndroidManifest.xml
View file @
990f2baf
...
...
@@ -40,6 +40,10 @@
android:name=
".idcard_captor.SampleIdcardResult"
android:screenOrientation=
"portrait"
/>
<activity
android:name=
".liveness.view_controller.LivenessDetectionActivity"
android:screenOrientation=
"portrait"
/>
<meta-data
android:name=
"io.fabric.ApiKey"
android:value=
"a5743d4d09caed055bc5d622e1bfe69a509d1add"
/>
...
...
src/main/java/com/oliveapp/liveness/sample/liveness/view_controller/LivenessDetectionActivity.java
0 → 100644
View file @
990f2baf
package
com
.
oliveapp
.
liveness
.
sample
.
liveness
.
view_controller
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.text.TextUtils
;
import
android.util.Base64
;
import
com.oliveapp.face.livenessdetectorsdk.livenessdetector.datatype.LivenessDetectionFrames
;
import
com.oliveapp.face.livenessdetectorsdk.livenessdetector.datatype.OliveappFaceInfo
;
import
com.oliveapp.liveness.sample.R
;
import
java.util.ArrayList
;
/**
* Created by SiKang on 2019-08-12.
*/
public
class
LivenessDetectionActivity
extends
LivenessDetectionMainActivity
{
private
static
final
String
SP_NAME
=
"yitu_liveness"
;
private
static
final
String
FACE_DATA
=
"face_data"
;
SharedPreferences
.
Editor
spEditor
;
@Override
public
void
onLivenessSuccess
(
OliveappFaceInfo
oliveappFaceInfo
)
{
LivenessDetectionFrames
pkg
=
this
.
getLivenessDetectionPackage
();
if
((
pkg
!=
null
?
pkg
.
verificationData
:
null
)
==
null
)
{
finishForResult
(
false
,
getResources
().
getString
(
R
.
string
.
faceid_detect_fail
));
}
else
{
if
(
pkg
.
verificationData
!=
null
)
{
spEditor
.
putString
(
FACE_DATA
,
Base64
.
encodeToString
(
pkg
.
verificationData
,
Base64
.
NO_WRAP
));
}
else
{
spEditor
.
putString
(
FACE_DATA
,
""
);
}
spEditor
.
commit
();
finishForResult
(
true
,
""
);
}
}
public
static
final
String
FAILED_MSG
=
"failed_msg"
;
/**
* 初始化活体检测
*/
@Override
public
void
onInitializeSucc
()
{
super
.
onInitializeSucc
();
super
.
startVerification
();
spEditor
=
getSharedPreferences
(
SP_NAME
,
Context
.
MODE_PRIVATE
).
edit
();
}
@Override
public
void
onInitializeFail
(
Throwable
e
)
{
super
.
onInitializeFail
(
e
);
finishForResult
(
false
,
getResources
().
getString
(
R
.
string
.
initialize_fail
));
}
/**
* 活体检测结果回调
*/
@Override
public
void
onLivenessSuccess
(
LivenessDetectionFrames
livenessDetectionFrames
,
OliveappFaceInfo
faceInfo
)
{
super
.
onLivenessSuccess
(
livenessDetectionFrames
,
faceInfo
);
if
(
livenessDetectionFrames
==
null
||
livenessDetectionFrames
.
verificationData
==
null
)
{
finishForResult
(
false
,
getResources
().
getString
(
R
.
string
.
faceid_detect_fail
));
}
else
{
if
(
livenessDetectionFrames
.
verificationData
!=
null
)
{
spEditor
.
putString
(
FACE_DATA
,
Base64
.
encodeToString
(
livenessDetectionFrames
.
verificationData
,
Base64
.
NO_WRAP
));
}
else
{
spEditor
.
putString
(
FACE_DATA
,
""
);
}
spEditor
.
commit
();
finishForResult
(
true
,
""
);
}
}
@Override
public
void
onLivenessFail
(
int
result
,
LivenessDetectionFrames
livenessDetectionFrames
)
{
super
.
onLivenessFail
(
result
,
livenessDetectionFrames
);
finishForResult
(
false
,
getResources
().
getString
(
R
.
string
.
faceid_detect_fail
));
}
/**
* 活体检测帧回调
*/
@Override
public
void
onFrameDetected
(
int
currentActionType
,
int
actionState
,
int
sessionState
,
int
remainingTimeoutMilliSecond
,
OliveappFaceInfo
faceInfo
,
ArrayList
<
Integer
>
errorCodeOfInAction
)
{
super
.
onFrameDetected
(
currentActionType
,
actionState
,
sessionState
,
remainingTimeoutMilliSecond
,
faceInfo
,
errorCodeOfInAction
);
if
(
remainingTimeoutMilliSecond
/
1000
<=
0
)
{
// 活体检测超时
finishForResult
(
false
,
getResources
().
getString
(
R
.
string
.
faceid_detect_fail
));
}
}
/**
* 返回结果
*/
private
void
finishForResult
(
final
boolean
isLivenessSuccess
,
final
String
msg
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
isLivenessSuccess
)
{
setResult
(
Activity
.
RESULT_OK
);
finish
();
}
else
{
if
(!
TextUtils
.
isEmpty
(
msg
))
{
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
FAILED_MSG
,
msg
);
setResult
(
Activity
.
RESULT_CANCELED
,
intent
);
}
else
{
setResult
(
Activity
.
RESULT_CANCELED
);
}
finish
();
}
}
});
}
}
src/main/java/com/oliveapp/liveness/sample/liveness/view_controller/LivenessDetectionMainActivity.java
View file @
990f2baf
...
...
@@ -265,6 +265,7 @@ public abstract class LivenessDetectionMainActivity extends Activity implements
if
(
cameraInfo
.
facing
==
expectCameraFacing
)
{
getIntent
().
putExtra
(
CameraUtil
.
EXTRAS_CAMERA_FACING
,
camIdx
);
// 设置需要打开的摄像头ID
getIntent
().
putExtra
(
CameraUtil
.
TARGET_PREVIEW_RATIO
,
CAMERA_RATIO_16_9
);
// 设置Preview长宽比,默认是16:9
break
;
}
}
mPhotoModule
=
new
PhotoModule
();
...
...
src/main/res/values/oliveapp_strings.xml
View file @
990f2baf
...
...
@@ -2,4 +2,15 @@
<string
name=
"oliveapp_app_name"
>
活体检测sample
</string>
<string
name=
"initialize_fail"
>
Gagal Inisialisasi
</string>
<string
name=
"tips_title"
>
Tips
</string>
<string
name=
"retry"
>
Mencoba Kembali
</string>
<string
name=
"take_id_photo_header_right"
>
Tampilan Benar
</string>
<string
name=
"take_id_photo_wrong"
>
Tampilan Salah
</string>
<string
name=
"take_id_photo_wrong_left"
>
Jangan menutupi KTP dengan jari Anda
</string>
<string
name=
"take_id_photo_wrong_middle"
>
Sesuaikan posisi KTP dalam garis kolom yang tersedia
</string>
<string
name=
"take_id_photo_wrong_right"
>
Hindari pantulan cahaya
</string>
<string
name=
"faceid_detect_fail"
>
Gagal deteksi wajah, mohon mencobanya sekali lagi
</string>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment