|
1 | | -import { useEffect, useRef, useState, useCallback } from "react"; |
| 1 | +import { useEffect, useState } from "react"; |
2 | 2 | import * as mpHolistic from "@mediapipe/holistic"; |
3 | 3 | import * as tf from '@tensorflow/tfjs'; |
4 | | -import { Camera } from '@mediapipe/camera_utils'; |
5 | 4 | import { onResults } from "./helperFunctions"; |
6 | 5 | import LoadingComponent from './LoadingComponent'; |
| 6 | +import VideoContainer from "./VideoContainer"; |
| 7 | +import { DetectorContainer } from "./detectorStyles"; |
| 8 | +import { IconButton, Avatar, Tooltip } from "@mui/material"; |
| 9 | +import PlayArrowIcon from '@mui/icons-material/PlayArrow'; |
| 10 | +import UploadFileIcon from '@mui/icons-material/UploadFile'; |
7 | 11 |
|
8 | 12 | function Detector() { |
9 | 13 |
|
10 | 14 | const [loadingStates, setLoadingStates] = useState(0) |
11 | | - const videoElementRef = useRef(); |
12 | 15 | const [holisticModel, setHolisticModel] = useState(null); |
13 | 16 |
|
14 | | - const initCamera = useCallback(() => { |
15 | | - // Start the camera using mediapipe camera utility |
16 | | - if (typeof videoElementRef.current !== "undefined" && videoElementRef.current !== null && holisticModel !== null) { |
17 | | - const camera = new Camera(videoElementRef.current, { |
18 | | - onFrame: async () => { |
19 | | - await holisticModel.send({ image: videoElementRef.current }); |
20 | | - }, |
21 | | - width: 480, |
22 | | - height: 480 |
23 | | - }); |
24 | | - camera.start(); |
25 | | - } |
26 | | - // -------------------------------------------------- |
27 | | - }, [videoElementRef, holisticModel]) |
28 | | - |
29 | | - console.log(initCamera) |
30 | | - |
31 | 17 | useEffect(() => { |
32 | 18 | // load our custom model and set it |
33 | 19 | const speechSynthesisUtterance = new SpeechSynthesisUtterance(); |
@@ -62,9 +48,22 @@ function Detector() { |
62 | 48 | ) |
63 | 49 | else |
64 | 50 | return ( |
65 | | - <div style={{ width: "100%", background: "linear-gradient(-25deg, #fdcb6c 50%, #7d8dc1 50%)" }}> |
66 | | - <video ref={videoElementRef} ></video> |
67 | | - </div> |
| 51 | + <DetectorContainer> |
| 52 | + {/* <div className="navbar"> |
| 53 | + <img src="/logo512.png" alt="logo" height="50px" width="50px" /> |
| 54 | + <Typography component="h4" style={{color:"white", fontSize:"1.5rem"}}>Sign-it ASL Translator</Typography> |
| 55 | + </div> */} |
| 56 | + <VideoContainer holisticModel={holisticModel} /> |
| 57 | + <div class="buttonsContainer"> |
| 58 | + <Tooltip title="Play"> |
| 59 | + <IconButton color="primary" variant="outlined" ><PlayArrowIcon sx={{ height: "40px", width: "40px" }} /></IconButton> |
| 60 | + </Tooltip> |
| 61 | + <Avatar src="/logo512.png" sx={{ height: "100px", width: "100px" }} /> |
| 62 | + <Tooltip title="Upload File"> |
| 63 | + <IconButton color="primary" variant="outlined" ><UploadFileIcon sx={{ height: "40px", width: "40px" }} /></IconButton> |
| 64 | + </Tooltip> |
| 65 | + </div> |
| 66 | + </DetectorContainer> |
68 | 67 | ) |
69 | 68 | } |
70 | 69 |
|
|
0 commit comments