Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-235 Vehicle parking system
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
3
Merge Requests
3
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-235
2022-235 Vehicle parking system
Commits
2ee7f4df
Commit
2ee7f4df
authored
Nov 09, 2022
by
chamodya99
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Component 2 to the GitLab
parent
c398f80d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
0 deletions
+47
-0
component_2/__pycache__/parking_violation.cpython-38.pyc
component_2/__pycache__/parking_violation.cpython-38.pyc
+0
-0
component_2/parking_violation.py
component_2/parking_violation.py
+47
-0
component_2/sample_data/test.png
component_2/sample_data/test.png
+0
-0
component_2/sample_data/tt.jpeg
component_2/sample_data/tt.jpeg
+0
-0
component_2/yolov5s.pt
component_2/yolov5s.pt
+0
-0
No files found.
component_2/__pycache__/parking_violation.cpython-38.pyc
0 → 100644
View file @
2ee7f4df
File added
component_2/parking_violation.py
0 → 100644
View file @
2ee7f4df
import
torch
import
json
import
cv2
import
math
import
os
import
random
model_vehicle
=
torch
.
hub
.
load
(
'ultralytics/yolov5'
,
'yolov5s'
)
guide_line_database
=
[
527
,
215
,
611
,
345
]
# sample guideline
def
is_inside
(
x1
,
y1
,
x1b
,
y1b
,
x2
,
y2
,
x2b
,
y2b
):
if
x1
>=
x2
and
y1
>=
y2
and
x1b
<=
x2b
and
y1b
<=
y2b
:
return
True
else
:
return
False
def
is_vehicle_parked_correctly
(
slot_index
=
0
):
sample_imgs
=
os
.
listdir
(
'component_2/sample_data'
)
img
=
cv2
.
imread
(
'component_2/sample_data/'
+
str
(
random
.
choice
(
sample_imgs
)))
result
=
model_vehicle
(
img
)
json_string
=
result
.
pandas
()
.
xyxy
[
0
]
.
to_json
(
orient
=
'records'
)
json_obj
=
json
.
loads
(
json_string
)
object_list
=
[]
for
i
in
json_obj
:
x
=
int
(
i
[
"xmin"
])
y
=
int
(
i
[
"ymin"
])
w
=
int
(
i
[
"xmax"
])
h
=
int
(
i
[
"ymax"
])
object_list
.
append
([
x
,
y
,
w
,
h
])
if
len
(
json_obj
)
==
0
:
return
True
return
is_inside
(
object_list
[
slot_index
][
0
],
object_list
[
slot_index
][
1
],
object_list
[
slot_index
][
2
],
object_list
[
slot_index
][
3
],
guide_line_database
[
0
],
guide_line_database
[
1
],
guide_line_database
[
2
],
guide_line_database
[
3
])
# print(is_vehicle_parked_correctly())
component_2/sample_data/test.png
0 → 100644
View file @
2ee7f4df
68 KB
component_2/sample_data/tt.jpeg
0 → 100644
View file @
2ee7f4df
41.9 KB
component_2/yolov5s.pt
0 → 100644
View file @
2ee7f4df
File added
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