diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..c3481a7
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,4 @@
+{
+ "singleQuote": true,
+ "semi": false
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index c65d3fe..ffe4bc7 100755
--- a/package.json
+++ b/package.json
@@ -1,11 +1,13 @@
{
- "name": "tensorflowjs-object-detection",
+ "name": "object-detection-react",
"version": "1.0.0",
- "description": "",
+ "description": "Real-time custom object detection with TensorFlow.js",
"keywords": [],
+ "repository":"https://github.com/cloud-annotations/object-detection-react",
+ "license":"MIT",
"main": "src/index.js",
"dependencies": {
- "@cloud-annotations/models": "^0.1.0",
+ "@cloud-annotations/models": "^0.1.7",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1"
diff --git a/public/index.html b/public/index.html
index 402dd6a..9b1814f 100755
--- a/public/index.html
+++ b/public/index.html
@@ -16,7 +16,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
-
React App
+ Object Detection
diff --git a/src/styles.module.css b/src/index.css
old mode 100755
new mode 100644
similarity index 53%
rename from src/styles.module.css
rename to src/index.css
index c37f335..5a5fdaa
--- a/src/styles.module.css
+++ b/src/index.css
@@ -1,5 +1,7 @@
-.fixed {
+.fillPage {
position: fixed;
top: 0;
left: 0;
+ right: 0;
+ bottom: 0;
}
diff --git a/src/index.js b/src/index.js
index ac06ae1..d881503 100755
--- a/src/index.js
+++ b/src/index.js
@@ -1,40 +1,55 @@
-import React, { useRef } from 'react'
+import React from 'react'
import ReactDOM from 'react-dom'
-import useWebcam from './useWebcam'
import useModel from './useModel'
-import useBoxRenderer from './useBoxRenderer'
+import ObjectDetectionVideo from './object-detection-video/ObjectDetectionVideo'
-import styles from './styles.module.css'
+import './index.css'
-const MODEL_PATH = process.env.PUBLIC_URL + '/model_web'
+const handlePrediction = (predictions) => {
+ console.timeEnd('detect')
+ console.time('detect')
+ console.log(predictions)
+}
-const App = () => {
- const videoRef = useRef()
- const canvasRef = useRef()
+const render = (ctx, predictions) => {
+ predictions.forEach((prediction) => {
+ const x = prediction.bbox[0]
+ const y = prediction.bbox[1]
+ const width = prediction.bbox[2]
+ const height = prediction.bbox[3]
+
+ ctx.setStrokeStyle('#0062ff')
+ ctx.setLineWidth(4)
+ ctx.strokeRect(
+ Math.round(x),
+ Math.round(y),
+ Math.round(width),
+ Math.round(height)
+ )
+ })
+}
- const cameraLoaded = useWebcam(videoRef)
- const model = useModel(MODEL_PATH)
- useBoxRenderer(model, videoRef, canvasRef, cameraLoaded)
+const App = () => {
+ const model = useModel(process.env.PUBLIC_URL + '/model_web')
return (
- <>
-
-