|
@@ -26,6 +26,8 @@ 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
|
|
|
|
|
|
|
|
object ArcSoftUtil {
|
|
object ArcSoftUtil {
|
|
|
private var cameraHelper: CameraHelper? = null
|
|
private var cameraHelper: CameraHelper? = null
|
|
@@ -37,6 +39,10 @@ object ArcSoftUtil {
|
|
|
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_FACE3DANGLE or FaceEngine.ASF_GENDER or FaceEngine.ASF_LIVENESS
|
|
|
|
|
+ private var startDetectFaceTime = 0L
|
|
|
|
|
+ private val faceNotDetectTip: () -> Unit = {
|
|
|
|
|
+ ToastUtils.tip(CommonUtils.getStr(R.string.not_detect_face))
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private const val ACTION_REQUEST_PERMISSIONS: Int = 0x001
|
|
private const val ACTION_REQUEST_PERMISSIONS: Int = 0x001
|
|
|
var isActivated = false
|
|
var isActivated = false
|
|
@@ -117,6 +123,7 @@ object ArcSoftUtil {
|
|
|
isMirror: Boolean
|
|
isMirror: Boolean
|
|
|
) {
|
|
) {
|
|
|
LogUtil.i("onCameraOpened: $cameraId $displayOrientation $isMirror")
|
|
LogUtil.i("onCameraOpened: $cameraId $displayOrientation $isMirror")
|
|
|
|
|
+ startDetectFaceTime = System.currentTimeMillis()
|
|
|
previewSize = camera.parameters.previewSize
|
|
previewSize = camera.parameters.previewSize
|
|
|
faceOverlayView?.setCameraPreviewSize(previewSize!!.width, previewSize!!.height)
|
|
faceOverlayView?.setCameraPreviewSize(previewSize!!.width, previewSize!!.height)
|
|
|
}
|
|
}
|
|
@@ -132,6 +139,13 @@ object ArcSoftUtil {
|
|
|
faceInfoList
|
|
faceInfoList
|
|
|
)
|
|
)
|
|
|
faceOverlayView?.setFaceRect(faceInfoList.map { it.rect })
|
|
faceOverlayView?.setFaceRect(faceInfoList.map { it.rect })
|
|
|
|
|
+ if (faceInfoList.isEmpty()) {
|
|
|
|
|
+ if (System.currentTimeMillis() - startDetectFaceTime > 3000) {
|
|
|
|
|
+ faceNotDetectTip()
|
|
|
|
|
+ startDetectFaceTime = System.currentTimeMillis()
|
|
|
|
|
+ }
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if (!needCheckCenter || (faceInfoList[0].rect.isInCenterArea(
|
|
if (!needCheckCenter || (faceInfoList[0].rect.isInCenterArea(
|
|
|
previewSize!!.width,
|
|
previewSize!!.width,
|
|
|
previewSize!!.height
|
|
previewSize!!.height
|