Skip to content
Snippets Groups Projects
Commit 654de071 authored by kshell's avatar kshell
Browse files

laptop->pc sync

parent 0a20e43a
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,8 @@ class App extends Component {
return (
<div>
<Header />
<GameUI />
<WebcamImage />
<GameUI />
</div>
);
}
......
import React, { useState, useRef, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import * as mobilenet from '@tensorflow-models/mobilenet';
import loadVideo from '../utilities/camera';
......@@ -16,12 +16,12 @@ function WebcamImage() {
console.log("toimii");
}
const predictVideo = async(image) =>{
async function predictVideo(image) {
if (model) {
const prediction = await model.predict(image, 4)
const predictType = prediction[0].className
setPredict(predictType)
console.log(predictType);
const prediction = await model.predict(image, 4);
setPredict(prediction)
console.log(prediction)
predictVideo(userWebCam)
}
}
......@@ -43,10 +43,17 @@ function WebcamImage() {
}
}, [])
// make prediction (as userWebCam and model is set)
useEffect(() => {
if (userWebCam) {
predictVideo(userWebCam)
}
}, [userWebCam, model])
return (
<div>
<div>
<video id="userWebCam"></video>
<video alignment="middle" id="userWebCam"></video>
</div>
<h3>{predict}</h3>
</div>
......
......@@ -6,8 +6,8 @@
import isMobile from './deviceDetect'
const canvasWidth = window.innerWidth * 0.15
const canvasHeight = window.innerHeight * 0.125
const canvasWidth = window.innerWidth * 0.33
const canvasHeight = window.innerHeight * 0.74
export async function setupCamera(videoElement) {
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment