Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better experiences #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/smart-brain.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17,934 changes: 10,691 additions & 7,243 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-dom": "^16.13.1",
"react-particles-js": "^2.1.0",
"react-scripts": "1.0.17",
"react-scripts": "^3.4.1",
"react-tilt": "^0.1.4",
"tachyons": "^4.9.0"
},
Expand All @@ -15,5 +15,17 @@
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
56 changes: 30 additions & 26 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const particlesOptions = {
}
}
}
}
};

const initialState = {
input: '',
imageUrl: '',
box: {},
route: 'signin',
boxes: [],
route: 'home',
isSignedIn: false,
user: {
id: '',
Expand All @@ -34,7 +34,7 @@ const initialState = {
entries: 0,
joined: ''
}
}
};

class App extends Component {
constructor() {
Expand All @@ -50,28 +50,32 @@ class App extends Component {
entries: data.entries,
joined: data.joined
}})
}
};

calculateFaceLocation = (data) => {
const clarifaiFace = data.outputs[0].data.regions[0].region_info.bounding_box;
const image = document.getElementById('inputimage');
const width = Number(image.width);
const height = Number(image.height);
return {
leftCol: clarifaiFace.left_col * width,
topRow: clarifaiFace.top_row * height,
rightCol: width - (clarifaiFace.right_col * width),
bottomRow: height - (clarifaiFace.bottom_row * height)
}
}
calculateFaceLocations = (data) => {
console.log(data.outputs[0].data);
return data.outputs[0].data.regions.map(face=>{
const clarifaiFace=face.region_info.bounding_box;
const image = document.getElementById('inputimage');
const width = Number(image.width);
const height = Number(image.height);
return {
leftCol: clarifaiFace.left_col * width,
topRow: clarifaiFace.top_row * height,
rightCol: width - (clarifaiFace.right_col * width),
bottomRow: height - (clarifaiFace.bottom_row * height)
}
})

displayFaceBox = (box) => {
this.setState({box: box});
}
};

displayFaceBox = (boxes) => {
this.setState({boxes: boxes});
};

onInputChange = (event) => {
this.setState({input: event.target.value});
}
};

onButtonSubmit = () => {
this.setState({imageUrl: this.state.input});
Expand Down Expand Up @@ -99,10 +103,10 @@ class App extends Component {
.catch(console.log)

}
this.displayFaceBox(this.calculateFaceLocation(response))
this.displayFaceBox(this.calculateFaceLocations(response))
})
.catch(err => console.log(err));
}
};

onRouteChange = (route) => {
if (route === 'signout') {
Expand All @@ -111,10 +115,10 @@ class App extends Component {
this.setState({isSignedIn: true})
}
this.setState({route: route});
}
};

render() {
const { isSignedIn, imageUrl, route, box } = this.state;
const { isSignedIn, imageUrl, route, boxes } = this.state;
return (
<div className="App">
<Particles className='particles'
Expand All @@ -132,7 +136,7 @@ class App extends Component {
onInputChange={this.onInputChange}
onButtonSubmit={this.onButtonSubmit}
/>
<FaceRecognition box={box} imageUrl={imageUrl} />
<FaceRecognition boxes={boxes} imageUrl={imageUrl} />
</div>
: (
route === 'signin'
Expand Down
12 changes: 8 additions & 4 deletions src/components/FaceRecognition/FaceRecognition.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React from 'react';
import './FaceRecognition.css';

const FaceRecognition = ({ imageUrl, box }) => {
const FaceRecognition = ({ imageUrl, boxes }) => {
return (
<div className='center ma'>
<div className='absolute mt2'>
<img id='inputimage' alt='' src={imageUrl} width='500px' heigh='auto'/>
<div className='bounding-box' style={{top: box.topRow, right: box.rightCol, bottom: box.bottomRow, left: box.leftCol}}></div>
<img id='inputimage' alt='' src={imageUrl} width='500px' height='auto'/>
{
boxes.map(box=>(
<div className='bounding-box' style={{top: box.topRow, right: box.rightCol, bottom: box.bottomRow, left: box.leftCol}}/>
))
}
</div>
</div>
);
}
};

export default FaceRecognition;
2 changes: 1 addition & 1 deletion src/components/ImageLinkForm/ImageLinkForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ const ImageLinkForm = ({ onInputChange, onButtonSubmit }) => {
</div>
</div>
);
}
};

export default ImageLinkForm;
5 changes: 4 additions & 1 deletion src/components/Rank/Rank.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ const Rank = ({ name, entries }) => {
return (
<div>
<div className='white f3'>

{`${name}, your current entry count is...`}

</div>
<div className='white f1'>
{entries}
</div>

</div>
);
}
};

export default Rank;