Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-073
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-073
2022-073
Commits
2970f966
Commit
2970f966
authored
Oct 04, 2022
by
Nilan Meegoda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attention_demo_intergration_i
parent
7d363434
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
250 additions
and
1 deletion
+250
-1
web-app/frontend/package.json
web-app/frontend/package.json
+1
-0
web-app/frontend/src/App.js
web-app/frontend/src/App.js
+2
-1
web-app/frontend/src/pages/attention_demo/attentionspan.css
web-app/frontend/src/pages/attention_demo/attentionspan.css
+44
-0
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
+202
-0
web-app/frontend/src/pages/index.js
web-app/frontend/src/pages/index.js
+1
-0
No files found.
web-app/frontend/package.json
View file @
2970f966
...
...
@@ -21,6 +21,7 @@
"react-circular-progressbar"
:
"^2.0.4"
,
"react-countdown-circle-timer"
:
"^3.0.9"
,
"react-dom"
:
"^18.2.0"
,
"react-record-webcam"
:
"^0.0.14"
,
"react-image-crop"
:
"^10.0.7"
,
"react-router-dom"
:
"^6.3.0"
,
"react-scripts"
:
"5.0.1"
,
...
...
web-app/frontend/src/App.js
View file @
2970f966
import
React
from
"
react
"
;
import
"
./App.css
"
;
import
{
BrowserRouter
as
BRouter
,
Routes
,
Route
}
from
"
react-router-dom
"
;
import
{
Home
,
Admin
,
Student
,
Welcome_screen
,
Features_screen
,
StdReg_screen
}
from
"
./pages/index
"
;
import
{
Home
,
Admin
,
Student
,
Welcome_screen
,
Features_screen
,
StdReg_screen
,
AttentionSpan_screen
}
from
"
./pages/index
"
;
const
App
=
()
=>
{
return
(
...
...
@@ -13,6 +13,7 @@ const App = () => {
<
Route
path
=
"
/welcome
"
element
=
{
<
Welcome_screen
/>
}
/
>
<
Route
path
=
"
/features
"
element
=
{
<
Features_screen
/>
}
/
>
<
Route
path
=
"
/stdReg
"
element
=
{
<
StdReg_screen
/>
}
/
>
<
Route
path
=
"
/attentionDemo
"
element
=
{
<
AttentionSpan_screen
/>
}
/
>
<
/Routes
>
<
/BRouter
>
);
...
...
web-app/frontend/src/pages/attention_demo/attentionspan.css
0 → 100644
View file @
2970f966
html
,
body
{
font-size
:
16px
;
font-family
:
Arial
,
Helvetica
,
sans-serif
;
/* ff 3.6+ */
background
:
-moz-radial-gradient
(
circle
at
5%
5%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
);
/* safari 5.1+,chrome 10+ */
background
:
-webkit-radial-gradient
(
circle
at
5%
5%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
);
/* global 92%+ browsers support */
background
:
radial-gradient
(
circle
at
5%
5%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
rgb
(
255
,
255
,
255
)
33%
,
);
}
.demo-section
{
padding-bottom
:
2rem
;
border-bottom
:
2px
solid
;
}
.demo-section
:last-child
{
border
:
none
;
}
video
{
width
:
60%
;
height
:
40%
;
}
web-app/frontend/src/pages/attention_demo/attentionspan.jsx
0 → 100644
View file @
2970f966
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
axios
from
"
axios
"
;
import
"
./attentionspan.css
"
;
import
{
useRecordWebcam
,
CAMERA_STATUS
}
from
"
react-record-webcam
"
;
import
type
{
RecordWebcamOptions
,
RecordWebcamHook
,
}
from
"
react-record-webcam
"
;
const
OPTIONS
:
RecordWebcamOptions
=
{
filename
:
"
test-filename
"
,
fileType
:
"
mp4
"
,
width
:
1920
,
height
:
1080
,
};
const
AttentionSpan_screen
=
()
=>
{
//attention prediction scores
const
[
attention
,
setattention
]
=
useState
([
0
,
0
,
0
]);
// object for storing and using data
const
recordWebcam
:
RecordWebcamHook
=
useRecordWebcam
(
OPTIONS
);
const
getRecordingFileHooks
=
async
()
=>
{
const
blob
=
await
recordWebcam
.
getRecording
();
console
.
log
({
blob
});
};
const
handleUploadImage
=
(
ev
)
=>
{
ev
.
preventDefault
();
};
const
saveFile
=
async
()
=>
{
const
blob
=
await
recordWebcam
.
getRecording
();
console
.
log
(
"
testing
"
,
blob
);
const
data
=
new
FormData
();
data
.
append
(
"
file
"
,
blob
);
// fetch("/upload", {
// method: "POST",
// body: data,
// }).then((res) => {
// res.json().then((data) => {
// console.log("Test", data);
// setattention(data);
// });
// });
await
axios
.
post
(
"
http://127.0.0.1:5000/upload
"
,
data
)
.
then
((
res
)
=>
{
setattention
(
res
.
data
)
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
});
};
return
(
<>
<
div
>
<
div
>
<
div
class=
"p-8 pb-2"
>
{
"
"
}
<
h1
class=
"text-4xl font-medium text-white text-center mt-2"
>
{
"
"
}
Attention level evaluation
{
"
"
}
</
h1
>
{
"
"
}
</
div
>
<
div
className=
"demo-section px-4"
>
<
p
class=
"m-2"
>
Camera status:
{
"
"
}
{
<
span
class=
"inline-flex items-center bg-green-600 rounded-full px-2 text-sm text-white py-1 font-medium"
>
<
svg
xmlns=
"http://www.w3.org/2000/svg"
class=
"fill-current mr-1.5 text-white"
viewBox=
"0 0 16 16"
width=
"10"
height=
"10"
>
<
path
d=
"M8 9.5a1.5 1.5 0 100-3 1.5 1.5 0 000 3z"
></
path
>
<
path
fill
-
rule=
"evenodd"
d=
"M8 0a8 8 0 100 16A8 8 0 008 0zM1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0z"
></
path
>
</
svg
>
{
recordWebcam
.
status
}
</
span
>
}
</
p
>
<
div
class=
"m-3"
>
<
div
class=
"bg-gray-50 inline-flex border border-gray-200 rounded-lg text-gray-900 select-none divide-x"
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
===
CAMERA_STATUS
.
OPEN
||
recordWebcam
.
status
===
CAMERA_STATUS
.
RECORDING
||
recordWebcam
.
status
===
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
recordWebcam
.
open
}
>
Open camera
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
===
CAMERA_STATUS
.
CLOSED
||
recordWebcam
.
status
===
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
recordWebcam
.
close
}
>
Close camera
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
===
CAMERA_STATUS
.
CLOSED
||
recordWebcam
.
status
===
CAMERA_STATUS
.
RECORDING
||
recordWebcam
.
status
===
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
recordWebcam
.
start
}
>
Start recording
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
!==
CAMERA_STATUS
.
RECORDING
}
onClick=
{
recordWebcam
.
stop
}
>
Stop recording
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
!==
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
recordWebcam
.
retake
}
>
Retake
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
!==
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
recordWebcam
.
download
}
>
Download
</
button
>
{
"
"
}
<
button
class=
"py-1.5 px-4 bg-gray-50 hover:bg-gray-100 active:bg-gray-200 first:rounded-l-lg last:rounded-r-lg"
disabled=
{
recordWebcam
.
status
!==
CAMERA_STATUS
.
PREVIEW
}
onClick=
{
saveFile
}
>
Predict
</
button
>
{
"
"
}
</
div
>
</
div
>
<
div
class=
"mx-4"
>
<
video
ref=
{
recordWebcam
.
webcamRef
}
style=
{
{
display
:
`${
recordWebcam.status === CAMERA_STATUS.OPEN ||
recordWebcam.status === CAMERA_STATUS.RECORDING
? "block"
: "none"
}`
,
}
}
autoPlay
muted
/>
</
div
>
<
div
class=
"mx-4"
>
<
video
ref=
{
recordWebcam
.
previewRef
}
style=
{
{
display
:
`${
recordWebcam.status === CAMERA_STATUS.PREVIEW
? "block"
: "none"
}`
,
}
}
autoPlay
muted
loop
/>
</
div
>
</
div
>
</
div
>
<
div
className=
"m-8"
>
<
header
className=
"App-header text-white"
>
{
/* Calling a data from setdata for showing */
}
<
p
>
Low level attention :
{
attention
[
0
]
*
100
}
</
p
>
<
p
>
Mid level attention :
{
attention
[
1
]
*
100
}
</
p
>
<
p
>
High level attention :
{
attention
[
2
]
*
100
}
</
p
>
</
header
>
</
div
>
</
div
>
</>
);
};
export
default
AttentionSpan_screen
;
web-app/frontend/src/pages/index.js
View file @
2970f966
...
...
@@ -4,3 +4,4 @@ export { default as Student } from "./student/Student";
export
{
default
as
Welcome_screen
}
from
"
./student/welcome_screen
"
;
export
{
default
as
Features_screen
}
from
"
./student/features
"
;
export
{
default
as
StdReg_screen
}
from
"
./student/student_reg
"
;
export
{
default
as
AttentionSpan_screen
}
from
"
./attention_demo/attentionspan
"
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment