Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
baby-face-expression-detect-model
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
R24-145
baby-face-expression-detect-model
Commits
b117ac95
Commit
b117ac95
authored
Oct 28, 2024
by
Ishankha K.C
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use multiple devices
parent
7418010a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
main_test.py
main_test.py
+9
-6
No files found.
main_test.py
View file @
b117ac95
...
...
@@ -4,10 +4,11 @@ import traceback
import
cv2
import
numpy
as
np
import
logging
from
fastapi
import
FastAPI
,
WebSocket
from
fastapi
import
FastAPI
,
WebSocket
,
WebSocketDisconnect
from
keras.models
import
load_model
from
keras.utils
import
img_to_array
import
urllib.request
from
urllib.error
import
URLError
# Configure logging
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(asctime)
s -
%(levelname)
s -
%(message)
s'
)
...
...
@@ -31,12 +32,13 @@ for class_name, index in class_indices.items():
face_cascade
=
cv2
.
CascadeClassifier
(
cv2
.
data
.
haarcascades
+
'haarcascade_frontalface_default.xml'
)
# Replace with your IP camera stream URL
url
=
'http://192.168.1.7/cam-hi.jpg'
base_dev_url
=
'http://192.168.1.7/'
img_endpoint
=
'/cam-hi.jpg'
@
app
.
websocket
(
"/ws/emotion"
)
async
def
websocket_endpoint
(
websocket
:
WebSocket
):
@
app
.
websocket
(
"/ws/emotion/{device_uid}"
)
async
def
websocket_endpoint
(
websocket
:
WebSocket
,
device_uid
:
str
):
await
websocket
.
accept
()
url
=
base_dev_url
+
device_uid
+
img_endpoint
try
:
while
True
:
try
:
...
...
@@ -87,7 +89,8 @@ async def websocket_endpoint(websocket: WebSocket):
"y"
:
int
(
y
),
"width"
:
int
(
w
),
"height"
:
int
(
h
)
}
},
"error"
:
False
})
logging
.
info
(
f
"Detected emotions: {emotions}"
)
...
...
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