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

react-vision-camera

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-vision-camera

Camera component for React. We can use this component for computer vision tasks like barcode scanning, text recognition, etc.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
185
increased by59.48%
Maintainers
1
Weekly downloads
 
Created
Source

React Vision Camera

Camera component for React using getUserMedia. We can use this component for computer vision tasks like barcode scanning, text recognition, etc.

Online demo

Installation

npm install react-vision-camera

Usage


import {VisionCamera} from 'react-vision-camera';

function App() {
  const [isActive,setIsActive] = React.useState(true); //whether the camera is active
  const [isPause,setIsPause] = React.useState(false); //whether the video is paused
  const onOpened = (cam:HTMLVideoElement,camLabel:string) => { // You can access the video element in the onOpened event
    console.log("opened"); 
  }

  const onClosed = () => {
    console.log("closed");
  }
  
  const onDeviceListLoaded = (devices:MediaDeviceInfo[]) => {
    console.log(devices);
  }
  
  return (
    <div>
      <VisionCamera 
        isActive={isActive}
        isPause={isPause}
        desiredCamera="back"
        desiredResolution={{width:1280,height:720}}
        onOpened={onOpened}
        onClosed={onClosed}
        onDeviceListLoaded={onDeviceListLoaded}
      >
      </VisionCamera>
    </div>
  )
}

FAQ

How to specify which camera to use?

  1. Use the desiredCamera prop. If one of the camera's name contains it, then it will be used. You can get the devices list in the onDeviceListLoaded event.
  2. Use the facingMode prop. Set it to environment to use the back camera. Set it to user to use the front camera. Please note that this is not supported on Desktop.

You can use the two props together. facingMode has a higher priority.

License

MIT

Keywords

FAQs

Package last updated on 13 Jul 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