react-native-vision-camera-spoof-detector 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ package com.faceantispoof
2
2
 
3
3
  import android.content.res.AssetManager
4
4
  import android.graphics.Bitmap
5
+ import android.graphics.Matrix
5
6
  import org.tensorflow.lite.Interpreter
6
7
  import org.tensorflow.lite.gpu.CompatibilityList
7
8
  import org.tensorflow.lite.gpu.GpuDelegate
@@ -201,13 +202,28 @@ class FaceAntiSpoofingAdvanced(private val assetManager: AssetManager) {
201
202
  width: Int,
202
203
  height: Int,
203
204
  rowStrides: IntArray,
204
- pixelStrides: IntArray
205
+ pixelStrides: IntArray,
206
+ rotationDegrees: Int = 0
205
207
  ): AntiSpoofingResult {
206
208
  if (planes.size < 3) {
207
209
  throw IllegalArgumentException("Expected Y, U and V planes")
208
210
  }
209
211
 
210
- val bitmap = yuv420ToBitmap(planes, width, height, rowStrides, pixelStrides)
212
+ val sourceBitmap = yuv420ToBitmap(planes, width, height, rowStrides, pixelStrides)
213
+ val rotation = ((rotationDegrees % 360) + 360) % 360
214
+ val bitmap = if (rotation == 0) {
215
+ sourceBitmap
216
+ } else {
217
+ Bitmap.createBitmap(
218
+ sourceBitmap,
219
+ 0,
220
+ 0,
221
+ sourceBitmap.width,
222
+ sourceBitmap.height,
223
+ Matrix().apply { postRotate(rotation.toFloat()) },
224
+ true
225
+ ).also { sourceBitmap.recycle() }
226
+ }
211
227
  return try {
212
228
  runBlocking { advancedAntiSpoofing(bitmap).getOrThrow() }
213
229
  } finally {
@@ -184,6 +184,7 @@ class HybridSpoofDetectorOutput(
184
184
  image.height,
185
185
  rowStrides,
186
186
  pixelStrides,
187
+ image.imageInfo.rotationDegrees,
187
188
  )
188
189
  val isLive = result.neuralNetworkScore < FaceAntiSpoofingAdvanced.BASE_THRESHOLD &&
189
190
  result.laplacianScore > FaceAntiSpoofingAdvanced.LAPLACIAN_THRESHOLD
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-vision-camera-spoof-detector",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "High-performance face anti-spoofing and liveness detection module for React Native Vision Camera. Uses TensorFlow Lite with GPU acceleration and optimized YUV processing.",
5
5
  "homepage": "https://github.com/dpraful/react-native-vision-camera-spoof-detector",
6
6
  "repository": {