Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@biopassid/face-sdk-react-native

Package Overview
Dependencies
Maintainers
5
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@biopassid/face-sdk-react-native

BioPass ID React Native module.

  • 0.1.21
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
490
increased by89.92%
Maintainers
5
Weekly downloads
 
Created
Source

BioPass ID Face SDK React Native

Table of Contents

  • Quick Start Guide
  • FaceConfig
  • FaceEvent
  • Changelog
  • License

Quick Start Guide

First, you will need a license key to use the SDK. You can acquire a license key when subscribing to a BioPass ID plan.

Check out our official documentation for more in depth information on BioPass ID.

1. Prerequisites:

Android
SupportSDK 21+
- A device with a camera

2. Installation

npm install @biopassid/face-sdk-react-native

Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

Change the compile Android sdk version to 31 (or higher) in your android/app/build.gradle file.

compileSdkVersion 31

3. How to use

To call Face Capture in your React Native project is as easy as follow:

import React from "react";
import { StyleSheet, View, Button } from "react-native";
import {
  FaceConfigPreset,
  FaceConfigType,
  FaceEvent,
  buildCameraView,
  FaceCameraLensDirection,
} from "@biopassid/face-sdk-react-native";

const App = () => {
  const config = FaceConfigPreset.getConfig(
    FaceConfigType.FACE_CAPTURE
  )
    .setLicenseKey("your-license-key")
    .setDefaultCameraPosition(FaceCameraLensDirection.FRONT)
    .setShowFlipCameraButton(true)
    .setStringsScreenTitle("Capturando Face")
    .setStylesOverlayColor("#CC000000");

  const callback = (event: FaceEvent) => {
    // handle Face return
    console.log(event.photo);
  };

  const handleButton = () => {
    buildCameraView(config, callback);
  };

  return (
    <View style={styles.container}>
      <Button onPress={handleButton} title="Capture Face" />
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: "center",
    justifyContent: "center",
    backgroundColor: '#FFFFFF',
  },
});

FaceConfig

You can also use pre-build configurations on your application, so you can automatically start using multiples services and features that better suit your application. You can instantiate each one and use it's default properties, or if you prefer you can change every config available. Here are the types that are supported right now:

FaceCaptureConfig

Variable nameTypeDefault value
licenseKeystring""
cameraPresetFaceCameraPresetFaceCameraPreset.FACE_CAPTURE
defaultCameraPositionFaceCameraLensDirectionFaceCameraLensDirection.FRONT
outputFormatFaceOutputFormatFaceOutputFormat.JPEG
captureButtonTypeFaceCaptureButtonTypeFaceCaptureButtonType.DEFAULT
showFlashButtonbooleanfalse
showFlipCameraButtonbooleantrue
flashEnabledByDefaultbooleanfalse
showHelpTextbooleantrue
showScreenTitlebooleantrue
autoCapturebooltrue
stringsFaceStrings
stylesFaceStyles

ContinuousCaptureConfig

Variable nameTypeDefault value
licenseKeystring""
cameraPresetFaceCameraPresetFaceCameraPreset.FACE_CAPTURE
defaultCameraPositionFaceCameraLensDirectionFaceCameraLensDirection.FRONT
outputFormatFaceOutputFormatFaceOutputFormat.JPEG
captureButtonTypeFaceCaptureButtonTypeFaceCaptureButtonType.DEFAULT
showFlashButtonbooleanfalse
showFlipCameraButtonbooleanfalse
flashEnabledByDefaultbooleanfalse
showHelpTextbooleantrue
showScreenTitlebooleantrue
autoCapturebooltrue
stringsFaceStrings
stylesFaceStyles

FaceStrings

Variable nameTypeDefault value
screenTitlestring"Capturando Face"
helpTextstring"Encaixe seu rosto no formato acima e aguarde o sinal verde"
loadingstring"Processando..."
customCaptureButtonText (Android only)string"Capture Face"
noFaceDetectedMessage (Android only)string"Nenhuma face detectada"
multipleFacesDetectedMessage (Android only)string"Múltiplas faces detectadas"
detectedFaceIsCenteredMessage (Android only)string"Mantenha o celular parado"
detectedFaceIsCloseMessage (Android only)string"Afaste o rosto da câmera"
detectedFaceIsDistantMessage (Android only)string"Aproxime o rosto da câmera"
detectedFaceIsOnTheLeftMessage (Android only)string"Mova o celular para a direita"
detectedFaceIsOnTheRightMessage (Android only)string"Mova o celular para a esquerda"
detectedFaceIsTooUpMessage (Android only)string"Mova o celular para baixo"
detectedFaceIsTooDownMessage (Android only)string"Mova o celular para cima"

FaceStyles

Variable nameTypeDefault value
faceColorstring"#FFFFFF"
faceEnabledColor (Android only)string"#16AC81"
faceDisabledColor (Android only)string"#E25353"
overlayColorstring"#CC000000"
backButtonIcon (Android only)stringnull
backButtonColor (Android only)string"#FFFFFF"
backButtonSize (Android only)FaceSizeFaceSize(24, 24)
flashButtonIcon (Android only)stringnull
flashButtonSize (Android only)FaceSizeFaceSize(24, 24)
flashButtonEnabledColorstring"#FFCC01"
flashButtonDisabledColor (Android only)string"#FFFFFF"
flipCameraButtonIcon (Android only)stringnull
flipCameraButtonColor (Android only)string"#FFFFFF"
flipCameraButtonSize (Android only)FaceSizeFaceSize(65, 43)
textColor (Android only)string"#FFFFFF"
textSize (Android only)number20
customFont (Android only)stringnull
captureButtonIcon (Android only)stringnull
captureButtonColorstring"#D9D9D9"
captureButtonSize (Android only)FaceSizeFaceSize(76, 76)
customCaptureButtonBackgroundColor (Android only)string"#D6A262"
customCaptureButtonSize (Android only)FaceSizeFaceSize(300, 45)
customCaptureButtonTextColor (Android only)string"#FFFFFF"
customCaptureButtonTextSize (Android only)number20

Changing Font Family

You can use the default font family or set a font you prefer. To set a font, create a folder font under res directory in your android/app/src/main/res. Download the font which ever you want and paste it inside font folder. All font names must be only: lowercase a-z, 0-9, or underscore. The structure should be some thing like below.

Then, just set the font passing the name of the font file.

const config = FaceConfigPreset.getConfig(FaceConfigType.FACE_CAPTURE)
  .setStylesFontFamily("roboto_mono_bold_italic");

Changing Icon

You can use the default icon or set a icon you prefer. To set a icon, download the icon which ever you want and paste it inside drawable folder in your android/app/src/main/res. The structure should be some thing like below.

Then, just set the font passing the name of the icon file.

const config = FaceConfigPreset.getConfig(FaceConfigType.FACE_CAPTURE)
  // changing back button icon
  .setStylesBackButtonIcon("ic_baseline_camera")
  // changing flash button icon
  .setStylesFlashButtonIcon("ic_baseline_camera")
  // changing flip camera button icon
  .setStylesFlipCameraButtonIcon("ic_baseline_camera")
  // changing capture button icon
  .setStylesCaptureButtonIcon("ic_baseline_camera");

FaceSize

Variable nameType
widthnumber
heightnumber

FaceCameraPreset (enum)

Preset TypeResolution
FaceCameraPreset.FACE_CAPTURE640x480
FaceCameraPreset.CONTINUOUS_CAPTURE640x480

FaceCameraLensDirection (enum)

Name
FaceCameraLensDirection.FRONT
FaceCameraLensDirection.BACK

FaceCaptureFormat (enum)

Name
FaceCaptureFormat.JPEG
FaceCaptureFormat.PNG

FaceCaptureButtonType (enum)

Name
FaceCaptureButtonType.CUSTOM
FaceCaptureButtonType.ICON

Using Custom Capture Button

const config = FaceConfigPreset.getConfig(FaceConfigType.FACE_CAPTURE)
  .setCaptureButtonType(FaceCaptureButtonType.CUSTOM)
  .setStylesCustomButtonBackgroundColor("#FFFF00")
  .setStylesCustomButtonTextColor("#FF00FF")
  .setStringsCustomButtonText("Capture");

Using Icon Capture Button

const config = FaceConfigPreset.getConfig(FaceConfigType.FACE_CAPTURE)
    .setCaptureButtonType(FaceCaptureButtonType.ICON)
    .setStylesCaptureButtonIcon("ic_baseline_camera")
    .setStylesCaptureButtonColor("#FF0000")
    .setStylesCaptureButtonSize({width: 76, height: 76});

How to instantiate and functionalities

To instantiate it's easy as to do one function call (as we have seen previously on the example). You only need to specify which type of config you want using a ENUM FaceConfigType. Every type however can have different features implemented, here are the supported types:

Config TypeEnumfeature
Face CaptureFaceConfigType.FACE_CAPTURECapture still image and detects face
Continuous CaptureFaceConfigType.CONTINUOUS_CAPTURECapture every frame per second

FaceEvent

On your Face callback function, you receive a FaceEvent.

FaceEvent

NameType
photoUint8Array

Changelog

v0.1.21

  • Bug fixes

v0.1.20

  • New licensing feature

v0.1.19

  • Bug fix

v0.1.18

  • Bug fixes
  • Flash mode fixes
  • Face detection improvement
  • New feature automatic capture
  • UI customization improvements
  • New feature face detection
  • Camera preset fix
  • Camera preview fix
  • New icon capture button
  • Fix in requesting permissions
  • Fix in performance of ContinuousCapture
  • Parameterizable screenTitle
  • New option to set text color
  • New custom capture button
  • Class name standardization
  • New option to set the font

v0.1.13

  • Face Capture SDK for Android and iOS

License

This project is under the MIT license. See the LICENSE for more information.

Keywords

FAQs

Package last updated on 29 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc