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

react-native-vision-camera

Package Overview
Dependencies
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-vision-camera

A powerful, high-performance React Native Camera library.

  • 4.6.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
136K
increased by1.69%
Maintainers
1
Weekly downloads
 
Created

What is react-native-vision-camera?

The react-native-vision-camera package is a powerful and flexible camera library for React Native applications. It provides high-performance camera functionalities, including real-time frame processing, barcode scanning, and more. It is designed to be highly customizable and performant, making it suitable for a wide range of camera-related tasks in mobile applications.

What are react-native-vision-camera's main functionalities?

Basic Camera Usage

This code demonstrates the basic usage of the react-native-vision-camera package. It sets up a camera view using the back camera of the device and displays it full-screen.

import { Camera, useCameraDevices } from 'react-native-vision-camera';
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';

const App = () => {
  const devices = useCameraDevices();
  const device = devices.back;

  if (device == null) return <View />;

  return (
    <View style={styles.container}>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

Frame Processing

This code demonstrates how to set up frame processing with the react-native-vision-camera package. The frameProcessor function is called for each frame captured by the camera, allowing for real-time processing.

import { Camera, useCameraDevices } from 'react-native-vision-camera';
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';

const App = () => {
  const devices = useCameraDevices();
  const device = devices.back;

  const frameProcessor = (frame) => {
    // Process the frame here
    console.log('Processing frame:', frame);
  };

  if (device == null) return <View />;

  return (
    <View style={styles.container}>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
        frameProcessor={frameProcessor}
        frameProcessorFps={1}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

Barcode Scanning

This code demonstrates how to use the react-native-vision-camera package for barcode scanning. It uses the vision-camera-code-scanner package to scan QR codes and logs the detected barcodes.

import { Camera, useCameraDevices } from 'react-native-vision-camera';
import React, { useEffect } from 'react';
import { View, StyleSheet } from 'react-native';
import { useScanBarcodes, BarcodeFormat } from 'vision-camera-code-scanner';

const App = () => {
  const devices = useCameraDevices();
  const device = devices.back;
  const [frameProcessor, barcodes] = useScanBarcodes([BarcodeFormat.QR_CODE]);

  useEffect(() => {
    if (barcodes.length > 0) {
      console.log('Barcodes:', barcodes);
    }
  }, [barcodes]);

  if (device == null) return <View />;

  return (
    <View style={styles.container}>
      <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={true}
        frameProcessor={frameProcessor}
        frameProcessorFps={5}
      />
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default App;

Other packages similar to react-native-vision-camera

Keywords

FAQs

Package last updated on 25 Nov 2024

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