Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
aart_ppe_detection
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
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
aart_ppe_detection
Commits
28552503
Commit
28552503
authored
Jan 17, 2023
by
Sikhin VC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added api recording feature
parent
494a31c4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4853 additions
and
137 deletions
+4853
-137
logs/ilens-edge_engine.log
logs/ilens-edge_engine.log
+4678
-0
output/recorded_video_list.txt
output/recorded_video_list.txt
+25
-0
scripts/__pycache__/ppe.cpython-39.pyc
scripts/__pycache__/ppe.cpython-39.pyc
+0
-0
scripts/ppe.py
scripts/ppe.py
+150
-137
No files found.
logs/ilens-edge_engine.log
View file @
28552503
This source diff could not be displayed because it is too large. You can
view the blob
instead.
output/recorded_video_list.txt
View file @
28552503
...
@@ -15,3 +15,28 @@ a1055d17-dbe0-42fe-9a5a-7cc877e863f01673919140.8465016.avi
...
@@ -15,3 +15,28 @@ a1055d17-dbe0-42fe-9a5a-7cc877e863f01673919140.8465016.avi
42f7b82a-ee30-49df-86fe-f8acfdb41d5f1673919201.623807.avi
42f7b82a-ee30-49df-86fe-f8acfdb41d5f1673919201.623807.avi
926d531b-f9a3-4545-8f10-72232c1a19581673919232.0070171.avi
926d531b-f9a3-4545-8f10-72232c1a19581673919232.0070171.avi
5a8bc7ec-0840-45e2-b823-9251df6ed4521673919262.2924252.avi
5a8bc7ec-0840-45e2-b823-9251df6ed4521673919262.2924252.avi
ef149507-10b0-49a5-8dd2-4d35ae3f540b1673937257.0850854.webm
1e12fad8-e319-4c4a-8a59-e3b60fc839641673937501.7711918.webm
f3b958af-f280-43aa-96c5-b1aa40f8a32a1673937635.0289881.webm
62054c4f-8d28-4153-ab01-f91c3b5d7c0b1673937672.4400358.webm
a74a3eb0-a2cb-4a1e-acea-588308006ace1673937870.293142.webm
b6271369-49b9-4834-bfe9-f256fb0437da1673938017.9071586.webm
80850154-1686-4b9a-a078-53c828bfd5911673938137.0431178.webm
920e0bd3-ff9c-4651-8c29-73f55da676bf1673938688.2525978.webm
3682bdcc-7345-4a8b-bbc5-cbdc90e27b961673938795.913603.webm
8d1daf45-b7a3-4f76-be72-791a9049be591673938826.3939579.webm
fb179339-7261-49cf-91f6-fcfca68c126a1673938856.883514.webm
e334b338-ac05-4e8f-abef-85c06861cc941673938887.3769703.webm
289d80a9-7a7a-4248-bc3e-ad12f94d3b401673939458.6783032.webm
81818b70-df7d-4a54-8fc0-919bf2d186e91673939548.079672.webm
0163846d-1c7a-4e47-8a21-f4343064b6341673944845.2525587.webm
23c579f3-7527-49a1-b3f1-4f2a112a3cc11673944875.549665.webm
53ba7ebb-d82b-41fd-a7e7-3102d197b0611673944905.8529074.webm
2c6ef734-7a71-4e5d-a82a-4d1298b1becb1673944936.2374694.webm
1c577a66-416d-451b-b017-1a2ebbb5f5321673944966.7960153.webm
20a7f8b3-da8d-446b-b9d6-09d1f01df0561673944997.252341.webm
cba5d9e8-2138-4a53-b845-600ffd9ac6c41673945027.7105763.webm
9d5f41b2-ddf6-4f21-9d0d-e0891e84d4921673945058.0353796.webm
3291b3cf-0b04-48f8-993a-c754176c6ca81673945088.4803202.webm
20a8f4c9-c315-4f3b-b4c7-5028856290ce1673945118.7755.webm
13159e47-a9e3-46c2-a611-24eda50329171673945149.1806812.webm
scripts/__pycache__/ppe.cpython-39.pyc
View file @
28552503
No preview for this file type
scripts/ppe.py
View file @
28552503
...
@@ -440,26 +440,28 @@ class Ppe(ModelWrapper):
...
@@ -440,26 +440,28 @@ class Ppe(ModelWrapper):
# print("SAFE--------------------------------------------")
# print("SAFE--------------------------------------------")
person_with_safety_kit
+=
1
person_with_safety_kit
+=
1
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
if
(
object_id
in
self
.
active_rec
):
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
for
v
in
temp_v_list
:
try
:
#
try:
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
#
sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# for violated_items in violations:
#
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
#
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur
=
self
.
conn
.
cursor
()
#
cur = self.conn.cursor()
frame_count
=
self
.
frame_id
#
frame_count = self.frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
#
file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
# cur.execute(sql, [frame_count, 10
, str(unique_id), datetime.datetime.now(), file_path, v])
self
.
conn
.
commit
()
#
self.conn.commit()
cur
.
close
()
#
cur.close()
except
:
#
except:
self
.
conn
.
rollback
()
#
self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
...
@@ -499,7 +501,7 @@ class Ppe(ModelWrapper):
...
@@ -499,7 +501,7 @@ class Ppe(ModelWrapper):
# result = self.video_write(frame, unique_id)
# result = self.video_write(frame, unique_id)
requests
.
post
(
'http://
localhost
:2328/items/'
,
json
=
{
requests
.
post
(
'http://
192.168.3.181
:2328/items/'
,
json
=
{
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"name"
:
str
(
unique_id
)
"name"
:
str
(
unique_id
)
})
})
...
@@ -524,31 +526,6 @@ class Ppe(ModelWrapper):
...
@@ -524,31 +526,6 @@ class Ppe(ModelWrapper):
self
.
conn
.
commit
()
self
.
conn
.
commit
()
cur
.
close
()
cur
.
close
()
# try:
#
# sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# # for violated_items in violations:
# # present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# cur = self.conn.cursor()
# frame_count = self.frame_id
# file_path = "/home/administrator/historical_videos/" + str(unique_id) + ".avi"
# cur.execute(sql, [frame_count, 4, str(unique_id), datetime.datetime.now(), file_path, v])
# self.conn.commit()
# cur.close()
# except:
# self.conn.rollback()
else
:
time_diff
=
time
.
time
()
-
self
.
reported_violation_ids
[
object_id
]
if
(
time_diff
>
30
):
del
self
.
reported_violation_ids
[
object_id
]
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
for
v
in
temp_v_list
:
try
:
try
:
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
...
@@ -557,13 +534,40 @@ class Ppe(ModelWrapper):
...
@@ -557,13 +534,40 @@ class Ppe(ModelWrapper):
cur
=
self
.
conn
.
cursor
()
cur
=
self
.
conn
.
cursor
()
frame_count
=
self
.
frame_id
frame_count
=
self
.
frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
cur
.
execute
(
sql
,
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
self
.
conn
.
commit
()
self
.
conn
.
commit
()
cur
.
close
()
cur
.
close
()
except
:
except
:
self
.
conn
.
rollback
()
self
.
conn
.
rollback
()
else
:
time_diff
=
time
.
time
()
-
self
.
reported_violation_ids
[
object_id
]
if
(
time_diff
>
30
):
del
self
.
reported_violation_ids
[
object_id
]
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
# # try:
#
# sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# # for violated_items in violations:
# # present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# cur = self.conn.cursor()
# frame_count = self.frame_id
# file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
# cur.execute(sql,
# [frame_count, 10, str(unique_id), datetime.datetime.now(), file_path,
# v])
# self.conn.commit()
# cur.close()
# except:
# self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
...
@@ -583,26 +587,28 @@ class Ppe(ModelWrapper):
...
@@ -583,26 +587,28 @@ class Ppe(ModelWrapper):
# print("SAFE--------------------------------------------")
# print("SAFE--------------------------------------------")
person_with_safety_kit
+=
1
person_with_safety_kit
+=
1
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
if
(
object_id
in
self
.
active_rec
):
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
for
v
in
temp_v_list
:
try
:
# #
try:
#
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
#
sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# for violated_items in violations:
#
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
#
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur
=
self
.
conn
.
cursor
()
#
cur = self.conn.cursor()
# cur.execute("ROLLBACK")
#
# cur.execute("ROLLBACK")
frame_count
=
self
.
frame_id
#
frame_count = self.frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
#
file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
# cur.execute(sql, [frame_count, 10
, str(unique_id), datetime.datetime.now(), file_path, v])
self
.
conn
.
commit
()
#
self.conn.commit()
cur
.
close
()
#
cur.close()
except
:
# #
except:
self
.
conn
.
rollback
()
#
self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
...
@@ -647,7 +653,7 @@ class Ppe(ModelWrapper):
...
@@ -647,7 +653,7 @@ class Ppe(ModelWrapper):
# f.write(unique_id + ".webm")
# f.write(unique_id + ".webm")
# f.write("\n")
# f.write("\n")
# result = self.video_write(frame, unique_id)
# result = self.video_write(frame, unique_id)
requests
.
post
(
'http://
localhost
:2328/items/'
,
json
=
{
requests
.
post
(
'http://
192.168.3.181
:2328/items/'
,
json
=
{
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"name"
:
str
(
unique_id
)
"name"
:
str
(
unique_id
)
})
})
...
@@ -667,31 +673,6 @@ class Ppe(ModelWrapper):
...
@@ -667,31 +673,6 @@ class Ppe(ModelWrapper):
cur
.
execute
(
sql
,
[
4
,
frame_count
,
datetime
.
datetime
.
now
(),
v
])
cur
.
execute
(
sql
,
[
4
,
frame_count
,
datetime
.
datetime
.
now
(),
v
])
self
.
conn
.
commit
()
self
.
conn
.
commit
()
cur
.
close
()
cur
.
close
()
# try:
#
# sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# # for violated_items in violations:
# # present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# cur = self.conn.cursor()
# # cur.execute("ROLLBACK")
# frame_count = self.frame_id
# file_path = "/home/administrator/historical_videos/" + str(unique_id) + ".webm"
# cur.execute(sql, [frame_count, 4, str(unique_id), datetime.datetime.now(), file_path, v])
# self.conn.commit()
# cur.close()
# except:
# self.conn.rollback()
else
:
time_diff
=
time
.
time
()
-
self
.
reported_violation_ids
[
object_id
]
if
(
time_diff
>
30
):
del
self
.
reported_violation_ids
[
object_id
]
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
for
v
in
temp_v_list
:
try
:
try
:
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
...
@@ -701,13 +682,40 @@ class Ppe(ModelWrapper):
...
@@ -701,13 +682,40 @@ class Ppe(ModelWrapper):
# cur.execute("ROLLBACK")
# cur.execute("ROLLBACK")
frame_count
=
self
.
frame_id
frame_count
=
self
.
frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
cur
.
execute
(
sql
,
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
self
.
conn
.
commit
()
self
.
conn
.
commit
()
cur
.
close
()
cur
.
close
()
except
:
except
:
self
.
conn
.
rollback
()
self
.
conn
.
rollback
()
else
:
time_diff
=
time
.
time
()
-
self
.
reported_violation_ids
[
object_id
]
if
(
time_diff
>
30
):
del
self
.
reported_violation_ids
[
object_id
]
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
# try:
# sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# # for violated_items in violations:
# # present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# cur = self.conn.cursor()
# # cur.execute("ROLLBACK")
# frame_count = self.frame_id
# file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
# cur.execute(sql,
# [frame_count, 10, str(unique_id), datetime.datetime.now(), file_path,
# v])
# self.conn.commit()
# cur.close()
# except:
# self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
with
open
(
"output/recorded_video_list.txt"
,
"a"
)
as
f
:
...
@@ -717,7 +725,7 @@ class Ppe(ModelWrapper):
...
@@ -717,7 +725,7 @@ class Ppe(ModelWrapper):
person_without_safety_kit
+=
1
person_without_safety_kit
+=
1
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
0
,
255
),
2
)
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
0
,
255
),
2
)
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
else
:
else
:
print
(
"without air breathing mask if"
)
print
(
"without air breathing mask if"
)
...
@@ -725,26 +733,28 @@ class Ppe(ModelWrapper):
...
@@ -725,26 +733,28 @@ class Ppe(ModelWrapper):
# print("SAFE--------------------------------------------")
# print("SAFE--------------------------------------------")
person_with_safety_kit
+=
1
person_with_safety_kit
+=
1
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
255
,
0
),
2
)
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
if
(
object_id
in
self
.
active_rec
):
if
(
object_id
in
self
.
active_rec
):
rec_inf
=
self
.
active_rec
[
object_id
]
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
for
v
in
temp_v_list
:
try
:
# #
try:
#
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
#
sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# for violated_items in violations:
#
# for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
#
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur
=
self
.
conn
.
cursor
()
#
cur = self.conn.cursor()
# cur.execute("ROLLBACK")
#
# cur.execute("ROLLBACK")
frame_count
=
self
.
frame_id
#
frame_count = self.frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
#
file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
# cur.execute(sql, [frame_count, 10
, str(unique_id), datetime.datetime.now(), file_path, v])
self
.
conn
.
commit
()
#
self.conn.commit()
cur
.
close
()
#
cur.close()
except
:
#
except:
self
.
conn
.
rollback
()
#
self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
...
@@ -787,7 +797,7 @@ class Ppe(ModelWrapper):
...
@@ -787,7 +797,7 @@ class Ppe(ModelWrapper):
# f.write(unique_id + ".webm")
# f.write(unique_id + ".webm")
# f.write("\n")
# f.write("\n")
# result = self.video_write(frame, unique_id)
# result = self.video_write(frame, unique_id)
requests
.
post
(
'http://
localhost
:2328/items/'
,
json
=
{
requests
.
post
(
'http://
192.168.3.181
:2328/items/'
,
json
=
{
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"rtsp"
:
"rtsp://192.168.3.181:8554/stream"
,
"name"
:
str
(
unique_id
)
"name"
:
str
(
unique_id
)
})
})
...
@@ -807,20 +817,20 @@ class Ppe(ModelWrapper):
...
@@ -807,20 +817,20 @@ class Ppe(ModelWrapper):
cur
.
execute
(
sql
,
[
4
,
frame_count
,
datetime
.
datetime
.
now
(),
v
])
cur
.
execute
(
sql
,
[
4
,
frame_count
,
datetime
.
datetime
.
now
(),
v
])
self
.
conn
.
commit
()
self
.
conn
.
commit
()
cur
.
close
()
cur
.
close
()
#
try:
try
:
#
#
sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
#
# for violated_items in violations:
# for violated_items in violations:
#
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
#
cur = self.conn.cursor()
cur
=
self
.
conn
.
cursor
()
#
# cur.execute("ROLLBACK")
# cur.execute("ROLLBACK")
#
frame_count = self.frame_id
frame_count
=
self
.
frame_id
# file_path = "/home/administrator/historical
_videos/" + str(unique_id) + ".webm"
file_path
=
"/home/administrator/aarti_violation
_videos/"
+
str
(
unique_id
)
+
".webm"
#
cur.execute(sql, [frame_count, 4, str(unique_id), datetime.datetime.now(), file_path, v])
cur
.
execute
(
sql
,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
v
])
#
self.conn.commit()
self
.
conn
.
commit
()
#
cur.close()
cur
.
close
()
#
except:
except
:
#
self.conn.rollback()
self
.
conn
.
rollback
()
...
@@ -835,23 +845,26 @@ class Ppe(ModelWrapper):
...
@@ -835,23 +845,26 @@ class Ppe(ModelWrapper):
rec_inf
=
self
.
active_rec
[
object_id
]
rec_inf
=
self
.
active_rec
[
object_id
]
# rec_inf[1].release()
# rec_inf[1].release()
temp_v_list
=
rec_inf
[
3
]
temp_v_list
=
rec_inf
[
3
]
print
(
temp_v_list
)
cv2
.
waitKey
(
1
)
for
v
in
temp_v_list
:
for
v
in
temp_v_list
:
try
:
#
try:
sql
=
'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (
%
s,
%
s,
%
s,
%
s,
%
s,
%
s);'
# sql = 'INSERT INTO "historical_video_2" ("event_id", "camera_id", "frame_id", "timestamp", "video_url", "violation_type") VALUES (%s, %s, %s, %s, %s, %s);'
# for violated_items in violations:
# # for violated_items in violations:
# present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
# # present_event_id = 'SELECT "event_id" FROM aarti_violation_event_table'
cur
=
self
.
conn
.
cursor
()
# cur = self.conn.cursor()
# cur.execute("ROLLBACK")
# # cur.execute("ROLLBACK")
frame_count
=
self
.
frame_id
# frame_count = self.frame_id
file_path
=
"/home/administrator/aarti_violation_videos/"
+
str
(
unique_id
)
+
".webm"
# file_path = "/home/administrator/aarti_violation_videos/" + str(unique_id) + ".webm"
cur
.
execute
(
sql
,
# cur.execute(sql,
[
frame_count
,
4
,
str
(
unique_id
),
datetime
.
datetime
.
now
(),
file_path
,
# [frame_count, 10, str(unique_id), datetime.datetime.now(), file_path,
v
])
# v])
self
.
conn
.
commit
()
# self.conn.commit()
cur
.
close
()
# cur.close()
except
:
# except:
self
.
conn
.
rollback
()
#
# self.conn.rollback()
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
self
.
send_payload
(
frame
=
resize_to_64_64
(
frame
),
message
=
temp_v_list
,
event
=
v
,
frame_id
=
rec_inf
[
2
])
event
=
v
,
frame_id
=
rec_inf
[
2
])
...
@@ -862,7 +875,7 @@ class Ppe(ModelWrapper):
...
@@ -862,7 +875,7 @@ class Ppe(ModelWrapper):
person_without_safety_kit
+=
1
person_without_safety_kit
+=
1
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
0
,
255
),
2
)
cv2
.
rectangle
(
frame
,
(
person_bb
[
0
],
person_bb
[
1
]),
(
person_bb
[
2
],
person_bb
[
3
]),
(
0
,
0
,
255
),
2
)
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
# for (object_id, det) in zip(other_class_name, other_centroid):
# for (object_id, det) in zip(other_class_name, other_centroid):
#
#
# centroid = object_id[1]
# centroid = object_id[1]
...
@@ -962,7 +975,7 @@ class Ppe(ModelWrapper):
...
@@ -962,7 +975,7 @@ class Ppe(ModelWrapper):
# print("expiring dict")
# print("expiring dict")
# print(self.safety_equip)
# print(self.safety_equip)
# if(len(self.safety_equip) == 0):
# if(len(self.safety_equip) == 0):
# cv2.waitKey(
0
)
# cv2.waitKey(
1
)
return
frame
return
frame
def
draw_line_over_image
(
self
,
frame
,
color
=
(
255
,
255
,
255
)):
def
draw_line_over_image
(
self
,
frame
,
color
=
(
255
,
255
,
255
)):
...
...
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