Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-115
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
2021-115
2021-115
Commits
f900e5fe
Commit
f900e5fe
authored
Jun 27, 2021
by
Odhara Kodikara
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://gitlab.sliit.lk/2021-115/2021-115
into it18110708_kodikara
Conflicts: .idea/workspace.xml
parents
cfabc76c
0f324cce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
18 deletions
+99
-18
Hazardous_object_detection/Hot_objects/hotObject-detection.py
...rdous_object_detection/Hot_objects/hotObject-detection.py
+46
-0
Hazardous_object_detection/Sharp_objects/sharpObject-detection.py
...s_object_detection/Sharp_objects/sharpObject-detection.py
+53
-18
No files found.
Hazardous_object_detection/Hot_objects/hotObject-detection.py
View file @
f900e5fe
# IT18006308
# Import Libraries
from
imageai.Detection
import
ObjectDetection
,
VideoObjectDetection
import
os
import
pickle
import
time
import
cv2
import
sys
THRESHOLD_ITEM
=
0.5
THRESHOLD_PERSON
=
0.5
print
(
"Test 1 : Hot Object Detection Start"
)
detector
=
VideoObjectDetection
()
detector
.
setModelTypeAsYOLOv3
()
detector
.
setModelPath
(
"../model/yolo.h5"
)
detector
.
loadModel
()
def
forFrame
(
frame_number
,
output_array
,
outpun_count
,
returned_frame
):
kettle_count
=
0
kettles
=
[]
person_count
=
0
persons
=
[]
for
detection
in
output_array
:
print
(
str
(
detection
[
'name'
])
+
" - "
+
str
(
detection
[
'percentage_probability'
])
+
" - "
+
str
(
detection
[
'box_point'
]))
if
detection
[
'name'
]
==
'kettle'
and
detection
[
'percentage_probability'
]
>=
THRESHOLD_ITEM
:
kettle_count
=
kettle_count
+
1
kettles
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
'box_point'
])
if
detection
[
'name'
]
==
'person'
and
detection
[
'percentage_probability'
]
>=
THRESHOLD_PERSON
:
person_count
=
person_count
+
1
persons
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
'box_point'
])
# Check the person is in room
if
len
(
persons
)
==
0
:
print
(
"Person is not in room"
)
if
len
(
persons
)
>
1
:
print
(
"Person in room"
)
Hazardous_object_detection/Sharp_objects/sharpObject-detection.py
View file @
f900e5fe
# IT18006308
# Import Libraries
from
imageai.Detection
import
ObjectDetection
from
imageai.Detection
import
ObjectDetection
,
VideoObjectDetection
from
imageai.Detection.Custom
import
CustomObjectDetection
import
os
import
pickle
import
time
...
...
@@ -9,35 +11,68 @@ import cv2
import
sys
THRESHOLD_ITEM
=
0.5
THRESHOLD_PERSON
=
0.5
print
(
"Test 1 : Sharp Object Detection Start"
)
detector
=
ObjectDetection
()
detector2
=
ObjectDetection
()
# detector = ObjectDetection()
detector
=
VideoObjectDetection
()
detector2
=
VideoObjectDetection
()
detector
.
setModelTypeAsYOLOv3
()
detector
.
setModelPath
(
"model/yolo.h5"
)
detector
.
setModelPath
(
"
../
model/yolo.h5"
)
detector
.
loadModel
()
detection1
=
detector
.
detectObjectsFromImage
(
input_image
=
"input/sharp2.jpg"
,
output_image_path
=
"output/sharp2.jpg"
)
#
detection1 = detector.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
detector2
.
setModelTypeAsRetinaNet
()
detector2
.
setModelPath
(
"model/resnet50_coco_best_v2.1.0.h5"
)
detector2
.
loadModel
()
detection2
=
detector2
.
detectObjectsFromImage
(
input_image
=
"input/sharp2.jpg"
,
output_image_path
=
"output/sharp2.jpg"
)
scissors_count
=
0
scissors
=
[]
# detection2 = detector2.detectObjectsFromImage(input_image="input/sharp2.jpg", output_image_path="output/sharp2.jpg")
def
forFrame
(
frame_number
,
output_array
,
outpun_count
,
returned_frame
):
scissors_count
=
0
scissors
=
[]
knife_count
=
0
knife
=
[]
fork_count
=
0
fork
=
[]
person_count
=
0
person
=
[]
print
(
frame_number
)
# YOLOv3 Model (person and scissors)
for
detection
in
output_array
:
print
(
str
(
detection
[
'name'
])
+
" - "
+
str
(
detection
[
'percentage_probability'
])
+
" - "
+
str
(
detection
[
'box_point'
]))
# identify Scissors
if
detection
[
'name'
]
==
'scissors'
and
detection
[
'percentage_probability'
]
>=
THRESHOLD_ITEM
:
scissors_count
=
scissors_count
+
1
scissors
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
'box_point'
])
if
detection
[
'name'
]
==
'person'
and
detection
[
'percentage_probability'
]
>=
THRESHOLD_PERSON
:
person_count
=
person_count
+
1
person
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
'box_point'
])
# RetinaNet Model
if
detection
[
'name'
]
==
'knife'
and
detection
[
'percentage probability'
]
>=
THRESHOLD_ITEM
:
knife_count
=
knife_count
+
1
knife
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
"box_point"
])
print
(
detection1
)
if
detection
[
'name'
]
==
'fork'
and
detection
[
'percentage_probability'
]
>=
THRESHOLD_ITEM
:
fork_count
=
fork_count
+
1
fork
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"percentage_probability"
],
" : "
,
detection
[
"box_point"
])
# YOLOv3 Model
for
detection
in
detection1
:
print
(
str
(
detection
[
'name'
])
+
" - "
+
str
(
detection
[
'precentage_probability'
])
+
" - "
+
str
(
detection
[
'box_point'
]))
# Check the person is in room
if
len
(
person
)
==
0
:
print
(
"Person is not in room"
)
# identify Scissors
if
(
detection
[
'name'
]
==
'scissors'
and
detection
[
'precentage_probability'
]
>=
THRESHOLD_ITEM
):
scissors_count
=
scissors_count
+
1
scissors
.
append
(
detection
[
'box_point'
])
print
(
detection
[
"name"
],
" : "
,
detection
[
"precentage_probability"
],
" : "
,
detection
[
'box_point'
])
if
len
(
person
)
>
1
:
print
(
"Person in room"
)
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