🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More →
Socket
Book a DemoInstallSign in
Socket

react-shape-detect

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-shape-detect

![CI](https://github.com/sam-parsons/react-shape-detect/workflows/Node.js%20CI/badge.svg)

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

react-shape-detect (v0.2)

CI

A React component integration with the Shape Detection API. Provides coordinate data and overlay capabilites.

Install

$ npm i react-shape-detect

Usage

import ShapeDetect from 'react-shape-detect';

const path = 'path-or-url-to-image';
const overlay = 'path-or-url-to-overlay';

const func = function(data) {
  console.log('objects detected: ', data);
}

export default function App() {
  return (
    <ShapeDetect 
      image={path} 
      onRender={func} 
      options={{ 
        type: 'face', 
        overlay: { 
          input: overlay
          options: {
            width: '70%'
          }
        }
      }} 
    />
  );
}

Basic Props

image

string | required

Path to image - network or local.

onRender

function(data: any) | defaults to: (data) => void

Callback is executed with the onLoad event of the <img/> tag.
Returns coordinate data from matches on criteria defined in options object.

options

object

Detector type, custom Shape Detector API options, and HTML img tag attributes

{
  type?: string // 'barcode', 'text' // default 'face'
  attributes?: React.CSSProperties,
  resizeDebounce?: number // default 250(ms)
  overlay?: {
    input: string || ReactComponent,
    options?: {
      width?: string, // auto height or set height independently
      height?: string,
      offset?: { // in pixels
        top?: number,
        left?: number
      }
    }
  }
}

License

MIT © Sam Parsons

Keywords

React

FAQs

Package last updated on 06 Feb 2021

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