Skip to content

Commit

Permalink
Improve loading etc
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinhenderson committed Nov 11, 2021
1 parent 1907a7d commit b6d297a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/react-app/blink-detection-with-sliders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const BlinkDetectionWithSliders = ({
onBlink,
children,
sx = {},
paperSx = {},
}) => {
const distanceHistory = useRef(
Array(KEEP_NUMBER_OF_VALUES).fill({ time: Infinity, value: 0 })
Expand Down Expand Up @@ -121,10 +122,11 @@ export const BlinkDetectionWithSliders = ({

<Paper
sx={{
display: "grid",
display: "flex",
gap: "1rem",
flexDirection: "column",
padding: "1rem",
...paperSx,
}}
>
{!loadingBlinkThreshold && (
Expand Down
9 changes: 8 additions & 1 deletion src/react-app/blink-training.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,15 @@ export const BlinkTraining = ({ prevTask, forceReload }) => {
sx={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: "1rem" }}
faceInFrame={setAllowNext}
onBlink={onBlink}
paperSx={{ minHeight: "296px" }}
>
<Box sx={{ display: "flex", justifyContent: "space-between" }}>
<Box
sx={{
display: "flex",
justifyContent: "space-between",
marginTop: "auto",
}}
>
<Button onClick={prevTask} size="large">
Previous step
</Button>
Expand Down
24 changes: 21 additions & 3 deletions src/react-app/camera-with-highlights.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { useFaceMesh } from "./hooks/use-face-mesh";
import { SelectedWebcam } from "./selected-webcam.jsx";
import { useStoreValue } from "./hooks/use-store";
import { REVERSE_CAMERA } from "./lib/store-consts";
import { CircularProgress } from "@mui/material";
import { Box } from "@mui/system";

const LOADING_TIME = 2000;

Expand Down Expand Up @@ -82,20 +84,36 @@ export const CameraWithHighlights = ({ onFrame = () => {} }) => {

useFaceMesh({ loading: loading || reverseLoading, webcamRef }, onResults);

const showIndicator = loading || reverseLoading;

return (
<>
<Box sx={{ position: "relative" }}>
<SelectedWebcam sx={{ display: "none" }} webcamRef={webcamRef} />
<Box
sx={{
position: "absolute",
width: "100%",
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
{showIndicator && <CircularProgress />}
</Box>

<canvas
style={{
...canvasFlip,
width: "100%",
height: "100%",
borderRadius: "4px",
background: "white",
boxShadow:
"0px 2px 1px -1px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%)",
}}
ref={canvasRef}
/>
</>
></canvas>
</Box>
);
};
1 change: 1 addition & 0 deletions src/react-app/face-framer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const FaceFramer = ({ nextTask, prevTask }) => {
width: "100%",
margin: "0 auto",
maxWidth: "540px",
minHeight: "296px",
}}
>
{!allowNext ? (
Expand Down
5 changes: 3 additions & 2 deletions src/react-app/main-screen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MainScreen = () => {
);
const reloadTrigger = useReload([reloadPlaySound]);
const [play] = useSound("./public/notif.mp3");
const [isFaceInFrame, setIsFaceInFrame] = useState(false);
const [isFaceInFrame, setIsFaceInFrame] = useState(true);
const sendBlinkToBackend = useBlinkAction();
const openSettings = useOpenSettings();

Expand All @@ -51,6 +51,7 @@ export const MainScreen = () => {
onBlink={onBlink}
faceInFrame={setIsFaceInFrame}
sx={{ display: "grid", gridTemplateColumns: "1fr 1fr" }}
paperSx={{ minHeight: "296px" }}
>
<>
{!isFaceInFrame && (
Expand All @@ -59,7 +60,7 @@ export const MainScreen = () => {
the screen and well lit.
</Typography>
)}
<Box>
<Box sx={{ marginTop: "auto" }}>
<CustomWidthTooltip
title="Change the settings including controlling the output."
placement="bottom"
Expand Down
2 changes: 2 additions & 0 deletions src/react-app/welcome-screen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ const WebcamDeviceSelector = ({ nextTask }) => {
>
<Webcam
style={{
minHeight: "242px",
background: "white",
width: "100%",
borderRadius: "4px",
boxShadow:
Expand Down

0 comments on commit b6d297a

Please sign in to comment.