npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-vision-camera-spoof-detector

v1.0.12

Published

High-performance face anti-spoofing and liveness detection module for React Native Vision Camera. Uses TensorFlow Lite with GPU acceleration and optimized YUV processing.

Readme

React Native Vision Camera Face Anti-Spoofing Detector

npm version License: MIT

High-performance face anti-spoofing and liveness detection module for React Native with Vision Camera integration. Uses TensorFlow Lite with GPU acceleration for real-time detection.

Features

Real-time Face Liveness Detection - Distinguish between live faces and spoofed images/videos
GPU Acceleration - TensorFlow Lite GPU delegate support
NNAPI Support - Hardware acceleration fallback for older devices
Multi-Threading - Non-blocking background processing
Optimized YUV Processing - Direct frame processing without Bitmap conversion
TypeScript Support - Full type definitions included
Lightweight - Only 20.92 MB (optimized build)
Production Ready - Tested and stable

Installation

npm install react-native-vision-camera-spoof-detector
# or
yarn add react-native-vision-camera-spoof-detector

Peer Dependencies

This module requires the following peer dependencies:

npm install react-native-vision-camera react-native-reanimated react-native-worklets-core

Quick Start

1. Initialize the Module

import { initializeFaceAntiSpoof } from 'react-native-vision-camera-spoof-detector';

// In your app initialization
useEffect(() => {
  initializeFaceAntiSpoof()
    .then(() => console.log('Face anti-spoof initialized'))
    .catch(err => console.error('Init failed:', err));
}, []);

2. Use in Frame Processor

import { useFrameProcessor } from 'react-native-vision-camera';
import { faceAntiSpoofFrameProcessor } from 'react-native-vision-camera-spoof-detector';

export function CameraScreen() {
  const frameProcessor = useFrameProcessor((frame) => {
    'worklet';
    
    const result = runAsync(frame, () => {
      'worklet';
      return faceAntiSpoofFrameProcessor(frame);
    });
    
    // Use the result
    if (result?.isLive) {
      console.log('Live face detected:', result.label);
    }
  }, []);

  return (
    <Camera
      device={device}
      frameProcessor={frameProcessor}
      // ... other props
    />
  );
}

API Reference

initializeFaceAntiSpoof(): Promise<boolean>

Initializes the face anti-spoofing module. Must be called before using the frame processor.

Returns: Promise<boolean> - true if initialization was successful

const isInitialized = await initializeFaceAntiSpoof();

faceAntiSpoofFrameProcessor(frame): FaceAntiSpoofingResult | null

Process a camera frame for face anti-spoofing detection.

Parameters:

  • frame (Frame) - Vision Camera frame object

Returns:

{
  isLive: boolean;           // true if face is live
  label: string;             // "Live Face" or "Spoof Face"
  neuralNetworkScore: number; // 0.0-1.0 (lower = more likely live)
  laplacianScore: number;    // Image quality metric
  combinedScore: number;     // 0.0-1.0 weighted score
  error?: string;            // Error message if any
}

isFaceAntiSpoofAvailable(): boolean

Check if the native module is available.

const available = isFaceAntiSpoofAvailable();

Performance

Optimization Techniques

  • Multi-Threading: Heavy processing runs on a dedicated background thread, keeping camera smooth
  • GPU Acceleration: Uses TensorFlow Lite GPU delegate when available
  • NNAPI Support: Falls back to NNAPI for hardware acceleration on older devices
  • YUV Direct Processing: No Bitmap conversion - works directly with camera frame data
  • Reusable Buffers: Allocates buffers once, reuses for each frame
  • Single-Frame Processing: Only processes one frame at a time to prevent queue overflow

Benchmark

| Metric | Value | |--------|-------| | Processing Time | ~50-100ms per frame | | Memory Usage | <30 MB (runtime) | | Package Size | 20.92 MB | | Support | Android 21+ |

Architecture

VisionCamera (30fps callback)
        ↓
faceAntiSpoofFrameProcessor()
        ↓
Submit to background executor
        ↓
Non-blocking return
        ↓
Latest result available

Processing happens on:

  • Single-threaded Executors.newSingleThreadExecutor()
  • Daemon thread for proper lifecycle
  • Non-blocking callback returns immediately

Configuration

Accelerator Types

The module automatically selects the best available accelerator:

  1. GPU - TensorFlow Lite GPU delegate (fastest)
  2. NNAPI - Android Neural Networks API
  3. CPU - Fallback for older devices

Check which accelerator is in use:

import FaceAntiSpoof from 'react-native-vision-camera-spoof-detector';

FaceAntiSpoof.checkModelStatus()
  .then(status => console.log('Accelerator:', status.accelerator));

Troubleshooting

Module Not Available

if (!isFaceAntiSpoofAvailable()) {
  console.error('Face anti-spoof not available on this device');
}

Initialization Fails

try {
  await initializeFaceAntiSpoof();
} catch (error) {
  console.error('Init error:', error.message);
}

Frame Processing Too Slow

  • Ensure you're using a physical device (emulators are slow)
  • Check if GPU acceleration is working
  • Reduce frame processor workload
  • Consider skipping some frames

License

MIT © JESCON TECHNOLOGIES PVT LTD

Support

For issues and feature requests, visit: GitHub Issues

Changelog

See CHANGELOG.md for version history and updates.


Package Version: 1.0.0
Last Updated: November 18, 2025