Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI-Powered Real-Time License Plate Recognition
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
2
Merge Requests
2
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
2023-281
AI-Powered Real-Time License Plate Recognition
Commits
de57d05b
Commit
de57d05b
authored
Sep 07, 2023
by
Karunarathna P.M.J.I.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload main.py
parent
01a0ab68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
main.py
main.py
+49
-0
No files found.
main.py
0 → 100644
View file @
de57d05b
import
uvicorn
from
fastapi
import
FastAPI
,
File
,
UploadFile
from
fastapi.middleware.cors
import
CORSMiddleware
from
tempfile
import
NamedTemporaryFile
import
os
os
.
environ
[
"KMP_DUPLICATE_LIB_OK"
]
=
"TRUE"
import
cv2
from
cv2CCTV
import
read_vid
app
=
FastAPI
()
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
[
"*"
],
allow_methods
=
[
"*"
],
allow_headers
=
[
"*"
],
)
# change to speed
@
app
.
post
(
"/video/detect-faces"
)
def
detect_faces
(
file
:
UploadFile
=
File
(
...
)):
temp
=
NamedTemporaryFile
(
delete
=
False
)
try
:
try
:
contents
=
file
.
file
.
read
()
with
temp
as
f
:
f
.
write
(
contents
)
except
Exception
:
return
{
"message"
:
"There was an error uploading the file"
}
finally
:
file
.
file
.
close
()
res
=
process_video
(
temp
.
name
)
# Pass temp.name to VideoCapture()
except
Exception
:
return
{
"message"
:
"There was an error processing the file"
}
finally
:
#temp.close() # the `with` statement above takes care of closing the file
os
.
remove
(
temp
.
name
)
return
res
def
process_video
(
vid
):
data
=
read_vid
(
vid
)
print
(
data
)
# cap = cv2.VideoCapture(vid)
return
{
"results"
:
data
}
if
__name__
==
"__main__"
:
uvicorn
.
run
(
"main:app"
,
host
=
"127.0.0.1"
,
port
=
8000
,
log_level
=
"info"
)
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