Commit 0c393c13 authored by Givindu's avatar Givindu

V1.16.1

parent 5a2bf325
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment