Skip to content

Commit

Permalink
Updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime committed Apr 12, 2020
1 parent 9ed62bd commit ab03473
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,47 @@ import React, { useRef, useState } from "react";
import { useFaceApi, } from 'react-use-faceapi';

const myFaceApiConfig = {
input: 'my-image',
refreshRate: 250
input: 'my-image',
refreshRate: 250
}

const App = () => {

// Attributes
const imageRef = useRef();
const [image, setImage] = useState("");
const faces = useFaceApi(myFaceApiConfig);

// Rendering
return (
<div>

<img style={{ width: 500 }} ref={imageRef} id="my-image" src={image} />
<input type="file" onChange={(event) => setImage(URL.createObjectURL(event.target.files[0]))} />

{faces && faces.map((face) => {

// Attributes
const top = face.relativeBox.top * imageRef.current.offsetHeight;
const left = face.relativeBox.left * imageRef.current.offsetWidth;
const width = face.relativeBox.width * imageRef.current.offsetWidth;
const height = face.relativeBox.height * imageRef.current.offsetHeight;

// Rendering
return (
<div style={{
position: 'absolute',
width: width,
height: height,
left: left,
top: top,
border: '1px solid red',
}}
/>
);
})}

</div >
// Attributes
const imageRef = useRef();
const [image, setImage] = useState("");
const faces = useFaceApi(myFaceApiConfig);

// Rendering
return (
<div>

<img style={{ width: 500 }} ref={imageRef} id="my-image" src={image} />
<input type="file" onChange={(event) => setImage(URL.createObjectURL(event.target.files[0]))} />

{faces && faces.map((face) => {

// Attributes
const top = face.relativeBox.top * imageRef.current.offsetHeight;
const left = face.relativeBox.left * imageRef.current.offsetWidth;
const width = face.relativeBox.width * imageRef.current.offsetWidth;
const height = face.relativeBox.height * imageRef.current.offsetHeight;

// Rendering
return (
<div style={{
position: 'absolute',
width: width,
height: height,
left: left,
top: top,
border: '1px solid red',
}}
/>
);
})}

</div >
)
}

Expand Down

0 comments on commit ab03473

Please sign in to comment.