Skip to content
Snippets Groups Projects
Commit 70a4aa05 authored by kshell's avatar kshell
Browse files

Camera linked with game

parent 3b750dcc
No related branches found
No related tags found
No related merge requests found
...@@ -16,13 +16,12 @@ class App extends Component { ...@@ -16,13 +16,12 @@ class App extends Component {
}, },
matchId: 1 matchId: 1
} }
this.updateMatch = this.updateMatch.bind(this)
} }
updateMatch = (e) => { updateMatch = (e) => {
this.setState({ this.setState({
match: e match: e,
})
this.setState({
matchId: this.state.matchId + 1 matchId: this.state.matchId + 1
}) })
} }
......
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react' ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
import * as tmImage from '@teachablemachine/image' import * as tmImage from '@teachablemachine/image'
import loadVideo from '../utilities/camera' import loadVideo from '../utilities/camera'
function AiCamera() { function AiCamera(props) {
// the link to your model provided by Teachable Machine export panel // the link to your model provided by Teachable Machine export panel
// without empty class // without empty class
...@@ -33,7 +33,7 @@ function AiCamera() { ...@@ -33,7 +33,7 @@ function AiCamera() {
// registers players mark and plays a turn // registers players mark and plays a turn
async function makeMove() { async function makeMove() {
this.props.handlePlay("Paper") props.handlePlay("Paper")
} }
...@@ -63,12 +63,12 @@ function AiCamera() { ...@@ -63,12 +63,12 @@ function AiCamera() {
return ( return (
<div> <div>
<button onClick={predictVideo}>Ennusta</button> <button onClick={makeMove}>Ennusta</button>
<video alignment="middle" id="userWebCam"></video> <video alignment="middle" id="userWebCam"></video>
<ul> <ul>
{results.map(({ className, probability }) => ( {results.map(({ className, probability }) => (
<li key={className}> <li key={className}>
{`${className}: %${(probability * 100).toFixed(2)}`} {`${className}: ${(probability * 100).toFixed(2)}%`}
</li> </li>
))} ))}
</ul> </ul>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment