Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-208
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-208
2021-208
Commits
7239a3e0
Commit
7239a3e0
authored
Nov 20, 2021
by
IT18052152_Perera H.G.G.M
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT18052152_Givindu' into 'master'
V1.22 See merge request
!102
parents
0cc20836
6ff0b856
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
81 additions
and
6 deletions
+81
-6
UI/AbnormalBehaviourDetection.html
UI/AbnormalBehaviourDetection.html
+1
-1
abnormal_behavior_detection/HumanDetection/Human_Detection_Video.py
...ehavior_detection/HumanDetection/Human_Detection_Video.py
+1
-1
abnormal_behavior_detection/ScriptsOrder/Scripts_Order.py
abnormal_behavior_detection/ScriptsOrder/Scripts_Order.py
+2
-1
abnormal_behavior_detection/WeaponDetection/Knife_Detection_Images.py
...avior_detection/WeaponDetection/Knife_Detection_Images.py
+74
-0
abnormal_behavior_detection/WeaponDetection/Weapon_Detection.py
...al_behavior_detection/WeaponDetection/Weapon_Detection.py
+3
-3
No files found.
UI/AbnormalBehaviourDetection.html
View file @
7239a3e0
...
...
@@ -26,7 +26,7 @@
<h1
class=
"mx-auto my-0 text-uppercase"
>
Abnormal Behavior Detection
</h1>
<h2
class=
"text-white-50 mx-auto mt-2 mb-5"
>
Detect suspects
&
abnormal behaviors accompanied by
Threatening Weapons (Hand Guns, Knives, Grenade)
</h2>
<img
src=
"assets/gun.png"
alt=
"Girl in a jacket"
width=
"200"
height=
"200"
<img
src=
"assets/gun
_new
.png"
alt=
"Girl in a jacket"
width=
"200"
height=
"200"
style=
"position: relative; top: 15px; opacity:90%;"
>
<div
class=
"row justify-content-md-center"
style=
"padding: 36px;"
>
<div
class=
"col col-lg-2"
>
...
...
abnormal_behavior_detection/HumanDetection/Human_Detection_Video.py
View file @
7239a3e0
...
...
@@ -48,7 +48,7 @@ def capture_humans(path):
while
True
:
ret
,
frame
=
cap
.
read
()
if
ret
!=
False
:
frame
=
imutils
.
resize
(
frame
,
width
=
8
00
)
frame
=
imutils
.
resize
(
frame
,
width
=
6
00
)
total_frames
=
total_frames
+
1
(
H
,
W
)
=
frame
.
shape
[:
2
]
...
...
abnormal_behavior_detection/ScriptsOrder/Scripts_Order.py
View file @
7239a3e0
...
...
@@ -13,7 +13,8 @@ def data(path):
path
=
path
elif
file
==
"Input.avi"
:
path
=
"E:
\\
BACKBONE
\\
videos
\\
"
+
file
elif
file
==
"Input.mp4"
:
path
=
"E:
\\
BACKBONE
\\
videos
\\
"
+
file
print
(
"path ->"
+
path
)
...
...
abnormal_behavior_detection/WeaponDetection/Knife_Detection_Images.py
0 → 100644
View file @
7239a3e0
import
glob
import
cv2
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
pandas
as
pd
count
=
1
path
=
glob
.
glob
(
"C:/Users/Givindu/Desktop/New folder/frames/New/*.jpg"
)
for
file
in
path
:
image
=
plt
.
imread
(
file
)
classes
=
None
with
open
(
'coco.names'
,
'r'
)
as
f
:
classes
=
[
line
.
strip
()
for
line
in
f
.
readlines
()]
Width
=
image
.
shape
[
1
]
Height
=
image
.
shape
[
0
]
# read pre-trained model and config file
net
=
cv2
.
dnn
.
readNet
(
'yolov3.weights'
,
'yolov3.cfg'
)
# create input blob
# set input blob for the network
net
.
setInput
(
cv2
.
dnn
.
blobFromImage
(
image
,
0.00392
,
(
416
,
416
),
(
0
,
0
,
0
),
True
,
crop
=
False
))
# run inference through the network
# and gather predictions from output layers
layer_names
=
net
.
getLayerNames
()
output_layers
=
[
layer_names
[
i
[
0
]
-
1
]
for
i
in
net
.
getUnconnectedOutLayers
()]
outs
=
net
.
forward
(
output_layers
)
class_ids
=
[]
confidences
=
[]
boxes
=
[]
#create bounding box
for
out
in
outs
:
for
detection
in
out
:
scores
=
detection
[
5
:]
class_id
=
np
.
argmax
(
scores
)
confidence
=
scores
[
class_id
]
if
confidence
>
0.1
:
center_x
=
int
(
detection
[
0
]
*
Width
)
center_y
=
int
(
detection
[
1
]
*
Height
)
w
=
int
(
detection
[
2
]
*
Width
)
h
=
int
(
detection
[
3
]
*
Height
)
x
=
center_x
-
w
/
2
y
=
center_y
-
h
/
2
class_ids
.
append
(
class_id
)
confidences
.
append
(
float
(
confidence
))
boxes
.
append
([
x
,
y
,
w
,
h
])
indices
=
cv2
.
dnn
.
NMSBoxes
(
boxes
,
confidences
,
0.1
,
0.1
)
#check if is people detection
for
i
in
indices
:
i
=
i
[
0
]
box
=
boxes
[
i
]
if
class_ids
[
i
]
==
0
:
label
=
str
(
classes
[
class_id
])
cv2
.
rectangle
(
image
,
(
round
(
box
[
0
]),
round
(
box
[
1
])),
(
round
(
box
[
0
]
+
box
[
2
]),
round
(
box
[
1
]
+
box
[
3
])),
(
0
,
0
,
0
),
2
)
cv2
.
putText
(
image
,
label
,
(
round
(
box
[
0
])
-
10
,
round
(
box
[
1
])
-
10
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
0
,
0
),
2
)
cv2
.
imwrite
(
'C:/Users/Givindu/Desktop/frames/frame'
+
str
(
count
)
+
'.jpg'
,
image
)
count
+=
1
#plt.imshow(image)
\ No newline at end of file
abnormal_behavior_detection/WeaponDetection/Weapon_Detection.py
View file @
7239a3e0
...
...
@@ -15,7 +15,7 @@ count = 1
start
=
time
.
time
()
def
weaponDetection
():
cap
=
cv
.
VideoCapture
(
'E:
\\
BACKBONE
\\
abnormal_behavior_detection
\\
frames
\\
Generated Video Output
\\
Output Video.avi'
)
cap
=
cv
.
VideoCapture
(
'E:
\\
BACKBONE
`
\\
abnormal_behavior_detection
\\
frames
\\
Generated Video Output
\\
Output Video.avi'
)
whT
=
320
confThreshold
=
0.1
nmsThreshold
=
0.1
...
...
@@ -72,7 +72,7 @@ def weaponDetection():
# Detect handguns
if
classIds
[
i
]
==
'0'
:
if
classIds
[
i
]
==
0
:
# print(x,y,w,h)
text
=
"{:.4f}
%
"
.
format
((
confs
[
i
])
*
100
)
print
(
"Suspect Detected : "
,
"["
,
text
,
"]"
)
...
...
@@ -97,7 +97,7 @@ def weaponDetection():
# Detect knives
if
classIds
[
i
]
==
1
:
if
classIds
[
i
]
==
'1'
:
# print(x,y,w,h)
text
=
"{:.4f}
%
"
.
format
((
confs
[
i
])
*
100
)
print
(
"Suspect Detected : "
,
"["
,
text
,
"]"
)
...
...
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