|
@@ -20,16 +20,20 @@ import com.arcsoft.face.enums.DetectFaceOrientPriority
|
|
|
import com.arcsoft.face.enums.DetectMode
|
|
import com.arcsoft.face.enums.DetectMode
|
|
|
import com.grkj.iscs_mars.R
|
|
import com.grkj.iscs_mars.R
|
|
|
import com.grkj.iscs_mars.extentions.isInCenterArea
|
|
import com.grkj.iscs_mars.extentions.isInCenterArea
|
|
|
|
|
+import com.grkj.iscs_mars.model.ArcSoftLicenseConfig
|
|
|
import com.grkj.iscs_mars.model.Constants
|
|
import com.grkj.iscs_mars.model.Constants
|
|
|
import com.grkj.iscs_mars.util.log.LogUtil
|
|
import com.grkj.iscs_mars.util.log.LogUtil
|
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.CameraHelper
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.CameraHelper
|
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.CameraListener
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.CameraListener
|
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.NV21ToBitmap
|
|
import com.grkj.iscs_mars.view.activity.test.face.arcsoft.NV21ToBitmap
|
|
|
import com.grkj.iscs_mars.view.widget.FaceOverlayView
|
|
import com.grkj.iscs_mars.view.widget.FaceOverlayView
|
|
|
-import com.sik.sikcore.thread.ThreadUtils
|
|
|
|
|
-import kotlinx.coroutines.Runnable
|
|
|
|
|
|
|
+import com.sik.sikcore.extension.file
|
|
|
|
|
+import com.sik.sikcore.extension.toJson
|
|
|
|
|
+import com.sik.sikcore.file.FileStorageUtils
|
|
|
|
|
+import java.io.File
|
|
|
|
|
|
|
|
object ArcSoftUtil {
|
|
object ArcSoftUtil {
|
|
|
|
|
+ private val configFileName = "ArcSoftConfig.json"
|
|
|
private var cameraHelper: CameraHelper? = null
|
|
private var cameraHelper: CameraHelper? = null
|
|
|
private var previewSize: Camera.Size? = null
|
|
private var previewSize: Camera.Size? = null
|
|
|
private val rgbCameraId = Camera.CameraInfo.CAMERA_FACING_BACK
|
|
private val rgbCameraId = Camera.CameraInfo.CAMERA_FACING_BACK
|
|
@@ -38,7 +42,7 @@ object ArcSoftUtil {
|
|
|
private val cameraHeight: Int = 480
|
|
private val cameraHeight: Int = 480
|
|
|
private var afCode = -1
|
|
private var afCode = -1
|
|
|
private val processMask: Int =
|
|
private val processMask: Int =
|
|
|
- FaceEngine.ASF_AGE or FaceEngine.ASF_FACE3DANGLE or FaceEngine.ASF_GENDER or FaceEngine.ASF_LIVENESS
|
|
|
|
|
|
|
+ FaceEngine.ASF_AGE or FaceEngine.ASF_GENDER or FaceEngine.ASF_LIVENESS
|
|
|
private var startDetectFaceTime = 0L
|
|
private var startDetectFaceTime = 0L
|
|
|
private val faceNotDetectTip: () -> Unit = {
|
|
private val faceNotDetectTip: () -> Unit = {
|
|
|
ToastUtils.tip(CommonUtils.getStr(R.string.not_detect_face))
|
|
ToastUtils.tip(CommonUtils.getStr(R.string.not_detect_face))
|
|
@@ -56,7 +60,31 @@ object ArcSoftUtil {
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
fun checkActiveStatus(context: Context) {
|
|
fun checkActiveStatus(context: Context) {
|
|
|
- val activeCode = FaceEngine.activeOnline(context, Constants.APP_ID, Constants.SDK_KEY)
|
|
|
|
|
|
|
+ val arcSoftLicenseFile =
|
|
|
|
|
+ "${FileUtil.getRootFolder(context)?.absolutePath}${FileUtil.CONFIG_DIR}${File.separator}${configFileName}".file()
|
|
|
|
|
+ val configJson = if (arcSoftLicenseFile.exists()) {
|
|
|
|
|
+ arcSoftLicenseFile.readText()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ val defaultJson = ArcSoftLicenseConfig(
|
|
|
|
|
+ Constants.APP_ID,
|
|
|
|
|
+ Constants.SDK_KEY,
|
|
|
|
|
+ Constants.ACTIVE_KEY
|
|
|
|
|
+ ).toJson()
|
|
|
|
|
+ FileStorageUtils.writeText(
|
|
|
|
|
+ "${FileUtil.getRootFolder(context)?.absolutePath}${FileUtil.CONFIG_DIR}",
|
|
|
|
|
+ "$configFileName",
|
|
|
|
|
+ defaultJson
|
|
|
|
|
+ )
|
|
|
|
|
+ defaultJson
|
|
|
|
|
+ }
|
|
|
|
|
+ val arcSoftLicenseConfig: ArcSoftLicenseConfig =
|
|
|
|
|
+ gson.fromJson(configJson, ArcSoftLicenseConfig::class.java)
|
|
|
|
|
+ val activeCode = FaceEngine.activeOnline(
|
|
|
|
|
+ context,
|
|
|
|
|
+ arcSoftLicenseConfig.activeKey,
|
|
|
|
|
+ arcSoftLicenseConfig.appId,
|
|
|
|
|
+ arcSoftLicenseConfig.sdkKey
|
|
|
|
|
+ )
|
|
|
when (activeCode) {
|
|
when (activeCode) {
|
|
|
ErrorInfo.MOK -> {
|
|
ErrorInfo.MOK -> {
|
|
|
isActivated = true
|
|
isActivated = true
|
|
@@ -87,9 +115,8 @@ object ArcSoftUtil {
|
|
|
context,
|
|
context,
|
|
|
DetectMode.ASF_DETECT_MODE_VIDEO,
|
|
DetectMode.ASF_DETECT_MODE_VIDEO,
|
|
|
DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
|
DetectFaceOrientPriority.ASF_OP_0_ONLY,
|
|
|
- 16,
|
|
|
|
|
1,
|
|
1,
|
|
|
- FaceEngine.ASF_FACE_DETECT or FaceEngine.ASF_AGE or FaceEngine.ASF_FACE3DANGLE or FaceEngine.ASF_GENDER or FaceEngine.ASF_LIVENESS or FaceEngine.ASF_FACE_RECOGNITION
|
|
|
|
|
|
|
+ FaceEngine.ASF_FACE_DETECT or FaceEngine.ASF_AGE or FaceEngine.ASF_GENDER or FaceEngine.ASF_LIVENESS or FaceEngine.ASF_FACE_RECOGNITION
|
|
|
)
|
|
)
|
|
|
LogUtil.i("initEngine: init: $afCode")
|
|
LogUtil.i("initEngine: init: $afCode")
|
|
|
if (afCode != ErrorInfo.MOK) {
|
|
if (afCode != ErrorInfo.MOK) {
|
|
@@ -173,12 +200,11 @@ object ArcSoftUtil {
|
|
|
val faceLivenessInfoList: List<LivenessInfo> = ArrayList()
|
|
val faceLivenessInfoList: List<LivenessInfo> = ArrayList()
|
|
|
val ageCode = faceEngine!!.getAge(ageInfoList)
|
|
val ageCode = faceEngine!!.getAge(ageInfoList)
|
|
|
val genderCode = faceEngine!!.getGender(genderInfoList)
|
|
val genderCode = faceEngine!!.getGender(genderInfoList)
|
|
|
- val face3DAngleCode = faceEngine!!.getFace3DAngle(face3DAngleList)
|
|
|
|
|
val livenessCode = faceEngine!!.getLiveness(faceLivenessInfoList)
|
|
val livenessCode = faceEngine!!.getLiveness(faceLivenessInfoList)
|
|
|
|
|
|
|
|
// 有其中一个的错误码不为ErrorInfo.MOK,return
|
|
// 有其中一个的错误码不为ErrorInfo.MOK,return
|
|
|
- if ((ageCode or genderCode or face3DAngleCode or livenessCode) != ErrorInfo.MOK) {
|
|
|
|
|
- LogUtil.d("人脸检测结果:年龄、性别、角度、获取验证失败")
|
|
|
|
|
|
|
+ if ((ageCode or genderCode or livenessCode) != ErrorInfo.MOK) {
|
|
|
|
|
+ LogUtil.d("人脸检测结果:年龄、性别、角度、活体验证失败")
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|