Есть ли способ сохранить это изображение на Android во время проверки?
В примерах это делается так:
Код: Выделить всё
open class LivenessActivity : AppCompatActivity() {
...
override fun onResume() {
super.onResume()
if (mFaceAnalyzer == null) {
initializeConfig()
val visionSourceOptions = VisionSourceOptions(this, this as LifecycleOwner)
// preview on surfaceView
visionSourceOptions.setPreview(mSurfaceView)
mVisionSource = VisionSource.fromDefaultCamera(visionSourceOptions)
displayCameraOnLayout()
createFaceAnalyzer()
}
startAnalyzeOnce()
}
private fun displayCameraOnLayout() {
val previewSize = mVisionSource?.cameraPreviewFormat
val params = mCameraPreviewLayout.layoutParams as ConstraintLayout.LayoutParams
params.dimensionRatio = previewSize?.height.toString() + ":" + previewSize?.width
params.width = ConstraintLayout.LayoutParams.MATCH_CONSTRAINT
params.matchConstraintDefaultWidth = ConstraintLayout.LayoutParams.MATCH_CONSTRAINT_PERCENT
params.matchConstraintPercentWidth = 0.8f
mCameraPreviewLayout.layoutParams = params
}
private fun createFaceAnalyzer() {
FaceAnalyzerCreateOptions().use { createOptions ->
createOptions.setFaceAnalyzerMode(FaceAnalyzerMode.TRACK_FACES_ACROSS_IMAGE_STREAM)
mFaceAnalyzer = FaceAnalyzerBuilder()
.serviceOptions(mServiceOptions)
.source(mVisionSource)
.createOptions(createOptions)
.build().get()
}
mFaceAnalyzer?.apply {
this.analyzed.addEventListener(analyzedListener)
this.analyzing.addEventListener(analyzingListener)
this.stopped.addEventListener(stoppedListener)
}
}
...
}
Код: Выделить всё
private fun usePixelCopy(view: SurfaceView, callback: (String) -> Unit) {
val bmp = Bitmap.createBitmap(view.width, view.width, Bitmap.Config.ARGB_8888)
PixelCopy.request(view, bmp, {
callback(bitmapToBase64(bmp))
}, Handler(Looper.getMainLooper()))
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... ter-verify
Мобильная версия