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
0c393c13
Commit
0c393c13
authored
Oct 11, 2021
by
Givindu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
V1.16.1
parent
5a2bf325
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
abnormal_behavior_detection/WeaponDetection/Knife_Detection.py
...mal_behavior_detection/WeaponDetection/Knife_Detection.py
+31
-3
abnormal_behavior_detection/WeaponDetection/Weapon_Detection.py
...al_behavior_detection/WeaponDetection/Weapon_Detection.py
+4
-2
No files found.
abnormal_behavior_detection/WeaponDetection/Knife_Detection.py
View file @
0c393c13
...
...
@@ -69,6 +69,33 @@ def weaponDetection():
i
=
i
[
0
]
box
=
bbox
[
i
]
x
,
y
,
w
,
h
=
box
[
0
],
box
[
1
],
box
[
2
],
box
[
3
]
# Detect handguns
if
classIds
[
i
]
==
0
:
# print(x,y,w,h)
text
=
"{:.4f}
%
"
.
format
((
confs
[
i
])
*
100
)
print
(
"Suspect Detected : "
,
"["
,
text
,
"]"
)
cv
.
rectangle
(
img
,
(
x
,
y
),
(
x
+
w
,
y
+
h
),
(
255
,
0
,
255
),
2
)
cv
.
putText
(
img
,
f
'{classNames[classIds[i]].upper()} {int(confs[i] * 100)}
%
'
,
(
x
,
y
-
10
),
cv
.
FONT_HERSHEY_SIMPLEX
,
0.6
,
(
255
,
0
,
255
),
2
)
# save detected frames
cv2
.
imwrite
(
'C:/Users/Givindu/Desktop/New folder/frames/Suspects with Weapons/frame
%
d.jpg'
%
count
,
img
)
count
+=
1
# Create and save in a CSV file
type
=
"Abnormal Activity"
weapon
=
"The Pistol was used as a weapon"
with
open
(
'C:/Users/Givindu/Desktop/New folder/frames/Abnormal Activity.csv'
,
'w'
,
newline
=
''
)
as
file
:
Num
+=
1
TimeD
=
start
-
time
.
time
()
arr
=
[
Num
,
type
,
weapon
,
TimeD
]
writer
=
csv
.
writer
(
file
)
writer
.
writerow
(
field
)
writer
.
writerow
(
arr
)
if
classIds
[
i
]
==
1
:
# print(x,y,w,h)
text
=
"{:.4f}
%
"
.
format
((
confs
[
i
])
*
100
)
...
...
@@ -77,12 +104,13 @@ def weaponDetection():
#cv.putText(img, f'{classNames[classIds[i]].upper()} {int(confs[i] * 100)}%',
# (x, y - 10), cv.FONT_HERSHEY_SIMPLEX, 0.6, (255, 0, 255), 2)
# save detected frames
cv2
.
imwrite
(
'E:/BACKBONE/abnormal_behavior_detection/frames/Suspects with Weapons/frame
%
d.jpg'
%
count
,
img
)
count
+=
1
# Create CSV File
type
=
"
Stabbing Attack
"
weapon
=
"
Knife used as the
weapon"
# Create
and save in a
CSV File
type
=
"
Abnormal Activity
"
weapon
=
"
The Knife was used as a
weapon"
with
open
(
'E:/BACKBONE/abnormal_behavior_detection/CSV/Abnormal Activity.csv'
,
'w'
,
newline
=
''
)
as
file
:
Num
+=
1
TimeD
=
time
.
time
()
-
start
...
...
abnormal_behavior_detection/WeaponDetection/Weapon_Detection.py
View file @
0c393c13
...
...
@@ -69,6 +69,8 @@ def weaponDetection():
i
=
i
[
0
]
box
=
bbox
[
i
]
x
,
y
,
w
,
h
=
box
[
0
],
box
[
1
],
box
[
2
],
box
[
3
]
# Detect handguns
if
classIds
[
i
]
==
0
:
# print(x,y,w,h)
text
=
"{:.4f}
%
"
.
format
((
confs
[
i
])
*
100
)
...
...
@@ -80,9 +82,9 @@ def weaponDetection():
cv2
.
imwrite
(
'E:/BACKBONE/abnormal_behavior_detection/frames/Suspects with Weapons/frame
%
d.jpg'
%
count
,
img
)
count
+=
1
# Create CSV File
# Create
and save in a
CSV File
type
=
"Abnormal Activity"
weapon
=
"
Pistol
"
weapon
=
"
The Knife was used as a weapon
"
with
open
(
'E:/BACKBONE/abnormal_behavior_detection/CSV/Abnormal Activity.csv'
,
'w'
,
newline
=
''
)
as
file
:
Num
+=
1
TimeD
=
time
.
time
()
-
start
...
...
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