Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
20b26012
Commit
20b26012
authored
May 24, 2021
by
宋永孟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 完成活体检测的业务逻辑
parent
9815d536
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
14 deletions
+62
-14
ToolsUtil.kt
...Common/src/main/java/com/yidian/common/utils/ToolsUtil.kt
+12
-4
IdentifyIdOcrVerifyBean.kt
...quan/newscontent/http/httpbean/IdentifyIdOcrVerifyBean.kt
+1
-1
AliveTestActivity.kt
...an/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
+48
-4
IDCardResultActivity.kt
...henghuoquan/newscontent/ui/idcard/IDCardResultActivity.kt
+1
-5
No files found.
CommonLib/Common/src/main/java/com/yidian/common/utils/ToolsUtil.kt
View file @
20b26012
...
@@ -24,7 +24,9 @@ import com.yidian.xarc.xevent.XBaseEvent
...
@@ -24,7 +24,9 @@ import com.yidian.xarc.xevent.XBaseEvent
import
com.yidian.xpage.XPageManager
import
com.yidian.xpage.XPageManager
import
com.yidian.yac.ftdevicefinger.core.FtDeviceFingerManager
import
com.yidian.yac.ftdevicefinger.core.FtDeviceFingerManager
import
org.json.JSONObject
import
org.json.JSONObject
import
java.io.*
import
java.io.File
import
java.io.FileNotFoundException
import
java.io.FileOutputStream
import
java.util.*
import
java.util.*
...
@@ -205,4 +207,10 @@ object ToolsUtil {
...
@@ -205,4 +207,10 @@ object ToolsUtil {
return
false
return
false
}
}
fun
randomName
():
String
{
val
randomNum
=
(
Math
.
random
()
*
1000
).
toInt
()
return
"lifeCircle$randomNum"
}
}
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/IdentifyIdOcrVerifyBean.kt
View file @
20b26012
package
com.yidian.shenghuoquan.newscontent.http.httpbean
package
com.yidian.shenghuoquan.newscontent.http.httpbean
class
IdentifyIdOcrVerifyBean
(
var
request
:
Request
,
val
response
:
Response
)
{
class
IdentifyIdOcrVerifyBean
(
var
request
:
Request
,
val
response
:
Response
)
{
data class
Request
(
var
biz_token
:
String
,
var
meglive_
data
:
String
)
data class
Request
(
var
biz_token
:
String
,
var
meglive_
objectid
:
String
)
data class
Response
(
val
biz_token
:
String
)
data class
Response
(
val
biz_token
:
String
)
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
View file @
20b26012
...
@@ -9,12 +9,14 @@ import com.megvii.meglive_sdk.manager.MegLiveManager
...
@@ -9,12 +9,14 @@ import com.megvii.meglive_sdk.manager.MegLiveManager
import
com.yidian.common.AppConfig
import
com.yidian.common.AppConfig
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.http.HttpResult
import
com.yidian.common.http.HttpResult
import
com.yidian.common.utils.ToolsUtil
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBinding
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyCallback
import
com.yidian.shenghuoquan.newscontent.http.httpbean.IdentifyIdOcrVerifyCallback
import
com.yidian.shenghuoquan.newscontent.utils.KS3Core
import
java.io.File
import
java.io.File
import
java.io.FileOutputStream
import
java.io.FileOutputStream
import
java.io.InputStream
import
java.io.InputStream
...
@@ -29,6 +31,7 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
...
@@ -29,6 +31,7 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
private
var
bizToken
=
""
private
var
bizToken
=
""
private
var
megLiveManager
:
MegLiveManager
?
=
null
private
var
megLiveManager
:
MegLiveManager
?
=
null
private
var
modelPath
=
""
// 模型本地存放路径
private
var
modelPath
=
""
// 模型本地存放路径
private
var
dataPath
=
""
// 模型本地存放路径
private
var
mProgressDialog
:
ProgressDialog
?
=
null
private
var
mProgressDialog
:
ProgressDialog
?
=
null
private
val
VERIFY_URL
=
"https://api.megvii.com/faceid/v3/sdk/verify"
private
val
VERIFY_URL
=
"https://api.megvii.com/faceid/v3/sdk/verify"
...
@@ -136,19 +139,60 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
...
@@ -136,19 +139,60 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
override
fun
onDetectFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?,
data
:
String
?)
{
override
fun
onDetectFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?,
data
:
String
?)
{
if
(
errorCode
==
1000
)
{
if
(
errorCode
==
1000
)
{
token
?.
let
{
verify
(
it
,
data
!!
.
toByteArray
())
}
token
?.
let
{
verify
(
it
,
data
!!
.
toByteArray
())
}
val
requestParams
:
IdentifyIdOcrVerifyBean
.
Request
=
IdentifyIdOcrVerifyBean
.
Request
(
bizToken
,
data
!!
)
ApiService
.
identifyIdOcrVerify
(
identifyIdOcrVerifyCallback
,
requestParams
)
}
}
}
}
private
fun
verify
(
token
:
String
,
data
:
ByteArray
)
{
private
fun
verify
(
token
:
String
,
data
:
ByteArray
)
{
showDialogDismiss
()
showDialogDismiss
()
saveFile
(
ToolsUtil
.
randomName
(),
data
)
}
}
private
val
identifyIdOcrVerifyCallback
=
object
:
IdentifyIdOcrVerifyCallback
{
private
val
identifyIdOcrVerifyCallback
=
object
:
IdentifyIdOcrVerifyCallback
{
override
fun
identifyIdOcrVerifySuccess
(
t
:
HttpResult
<
Any
?
>?)
{
override
fun
identifyIdOcrVerifySuccess
(
t
:
HttpResult
<
Any
?
>?)
{
//人脸验证成功
progressDialogDismiss
()
}
}
// 将字节流转换成文件
@Throws
(
Exception
::
class
)
fun
saveFile
(
filename
:
String
,
data
:
ByteArray
?)
{
if
(
data
!=
null
)
{
val
sdcardPath
=
System
.
getenv
(
"EXTERNAL_STORAGE"
)
dataPath
=
"$sdcardPath/life_circle_business/meglive"
val
file
=
File
(
dataPath
)
if
(
file
.
exists
())
{
file
.
delete
()
}
val
fos
=
FileOutputStream
(
file
)
fos
.
write
(
data
,
0
,
data
.
size
)
fos
.
flush
()
fos
.
close
()
KS3Core
.
INSTANCE
.
uploadObject
(
file
,
object
:
KS3Core
.
OnKS3TaskListener
{
override
fun
onTaskStart
()
{
}
override
fun
onTaskProgress
(
progress
:
Double
)
{
}
override
fun
onTaskFinish
()
{
}
override
fun
onTaskCancel
()
{
}
override
fun
onTaskSuccess
(
bucket
:
String
?,
objectKey
:
String
?)
{
val
requestParams
:
IdentifyIdOcrVerifyBean
.
Request
=
IdentifyIdOcrVerifyBean
.
Request
(
bizToken
,
objectKey
!!
)
ApiService
.
identifyIdOcrVerify
(
identifyIdOcrVerifyCallback
,
requestParams
)
}
override
fun
onTaskFailure
(
statesCode
:
Int
,
message
:
String
?)
{
}
})
}
}
}
}
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/idcard/IDCardResultActivity.kt
View file @
20b26012
...
@@ -37,12 +37,8 @@ class IDCardResultActivity:BaseActivity<ActivityIdcardResultBinding>() {
...
@@ -37,12 +37,8 @@ class IDCardResultActivity:BaseActivity<ActivityIdcardResultBinding>() {
if
(
iDCardImg
!=
null
)
{
if
(
iDCardImg
!=
null
)
{
val
bmpIDCardImg
=
BitmapFactory
.
decodeByteArray
(
iDCardImg
,
0
,
iDCardImg
.
size
)
val
bmpIDCardImg
=
BitmapFactory
.
decodeByteArray
(
iDCardImg
,
0
,
iDCardImg
.
size
)
viewBind
.
resultIdcardImage
.
setImageBitmap
(
bmpIDCardImg
)
viewBind
.
resultIdcardImage
.
setImageBitmap
(
bmpIDCardImg
)
ToolsUtil
.
saveImage
(
bmpIDCardImg
,
randomName
()
+
".jpg"
,
this
)
ToolsUtil
.
saveImage
(
bmpIDCardImg
,
ToolsUtil
.
randomName
()
+
".jpg"
,
this
)
}
}
}
}
private
fun
randomName
():
String
{
val
randomNum
=
(
Math
.
random
()
*
1000
).
toInt
()
return
"lifeCircle$randomNum"
}
}
}
\ No newline at end of file
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