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
rahul
aart_ppe_detection
Commits
8592705b
Commit
8592705b
authored
Jan 06, 2023
by
Sikhin VC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a
parent
a1848085
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
55 deletions
+22
-55
edge_engine/streamio/__pycache__/frameProcessor.cpython-39.pyc
...engine/streamio/__pycache__/frameProcessor.cpython-39.pyc
+0
-0
edge_engine/streamio/frameProcessor.py
edge_engine/streamio/frameProcessor.py
+6
-34
edge_engine/streamio/videostream/__pycache__/filevideostream.cpython-39.pyc
...io/videostream/__pycache__/filevideostream.cpython-39.pyc
+0
-0
edge_engine/streamio/videostream/filevideostream.py
edge_engine/streamio/videostream/filevideostream.py
+1
-17
logs/ilens-edge_engine.log
logs/ilens-edge_engine.log
+11
-0
scripts/ppe.py
scripts/ppe.py
+4
-4
No files found.
edge_engine/streamio/__pycache__/frameProcessor.cpython-39.pyc
View file @
8592705b
No preview for this file type
edge_engine/streamio/frameProcessor.py
View file @
8592705b
...
@@ -6,45 +6,17 @@ class FrameProcessor:
...
@@ -6,45 +6,17 @@ class FrameProcessor:
def
__init__
(
self
,
stream
,
model
):
def
__init__
(
self
,
stream
,
model
):
self
.
model
=
model
self
.
model
=
model
self
.
stream
=
stream
self
.
stream
=
stream
self
.
old_video_capture_count
=
0
logger
.
info
(
"Setting up frame processor !!"
)
logger
.
info
(
"Setting up frame processor !!"
)
self
.
count
=
0
self
.
skip_frame_every
=
30
# 1 does not skip any frame (n-1 frames get skipped)
def
run_model
(
self
):
def
run_model
(
self
):
count
=
0
while
self
.
stream
.
stream
.
isOpened
():
while
self
.
stream
.
running
():
try
:
try
:
# video_capture_count = self.stream.get_frame_count()
# if(video_capture_count != self.old_video_capture_count):
#
# self.old_video_capture_count = video_capture_count
# count = 0
# if(video_capture_count == 1):
# count = 0
count
+=
1
logger
.
debug
(
"Getting frame mask_model"
)
logger
.
debug
(
"Getting frame mask_model"
)
frame
=
self
.
stream
.
read
()
frame
=
self
.
stream
.
read
()
logger
.
debug
(
"Running mask_model"
)
if
frame
is
not
None
and
self
.
count
%
self
.
skip_frame_every
==
0
:
data
=
{
"frame"
:
frame
,
"frameId"
:
"{}"
.
format
(
uuid4
()),
"deviceId"
:
"{}"
.
format
(
DEVICE_ID
)}
fid
=
uuid4
()
data
=
{
"frame"
:
frame
,
"frameId"
:
self
.
count
,
"deviceId"
:
"{}"
.
format
(
DEVICE_ID
),
}
self
.
model
.
predict
(
data
)
self
.
model
.
predict
(
data
)
self
.
count
+=
1
logger
.
debug
(
"publishing mask_model output"
)
# logger.debug("Running mask_model")
# data = {"frame": frame, "frameId": "{}".format(uuid4()), "deviceId": "{}".format(DEVICE_ID), "frame_id": count}
# self.model.predict(data)
# logger.debug("publishing mask_model output")
if
(
self
.
count
==
3227
):
self
.
count
=
0
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
e
)
logger
.
error
(
e
)
logger
.
error
(
traceback
.
format_exc
())
logger
.
error
(
traceback
.
format_exc
())
edge_engine/streamio/videostream/__pycache__/filevideostream.cpython-39.pyc
View file @
8592705b
No preview for this file type
edge_engine/streamio/videostream/filevideostream.py
View file @
8592705b
...
@@ -14,7 +14,6 @@ else:
...
@@ -14,7 +14,6 @@ else:
class
FileVideoStream
:
class
FileVideoStream
:
def
__init__
(
self
,
stream_config
,
transform
=
None
):
def
__init__
(
self
,
stream_config
,
transform
=
None
):
self
.
count
=
0
# initialize the file video stream along with the boolean
# initialize the file video stream along with the boolean
# used to indicate if the thread should be stopped or not
# used to indicate if the thread should be stopped or not
self
.
transform
=
transform
self
.
transform
=
transform
...
@@ -22,8 +21,6 @@ class FileVideoStream:
...
@@ -22,8 +21,6 @@ class FileVideoStream:
# initialize the queue used to store frames read from
# initialize the queue used to store frames read from
# the video file
# the video file
self
.
build_pipeline
()
self
.
build_pipeline
()
# self.count_dict = {"count": 0}
def
start
(
self
):
def
start
(
self
):
...
@@ -32,7 +29,6 @@ class FileVideoStream:
...
@@ -32,7 +29,6 @@ class FileVideoStream:
return
self
return
self
def
build_cv_obj
(
self
):
def
build_cv_obj
(
self
):
# self.count += 1
self
.
stream
=
cv2
.
VideoCapture
(
self
.
stream_config
[
"uri"
])
self
.
stream
=
cv2
.
VideoCapture
(
self
.
stream_config
[
"uri"
])
self
.
stopped
=
False
self
.
stopped
=
False
...
@@ -47,8 +43,6 @@ class FileVideoStream:
...
@@ -47,8 +43,6 @@ class FileVideoStream:
self
.
thread
.
daemon
=
True
self
.
thread
.
daemon
=
True
def
is_opened
(
self
):
def
is_opened
(
self
):
return
self
.
stream
.
isOpened
()
return
self
.
stream
.
isOpened
()
...
@@ -64,17 +58,12 @@ class FileVideoStream:
...
@@ -64,17 +58,12 @@ class FileVideoStream:
if
not
self
.
Q
.
full
():
if
not
self
.
Q
.
full
():
# read the next frame from the file
# read the next frame from the file
(
grabbed
,
frame
)
=
self
.
stream
.
read
()
(
grabbed
,
frame
)
=
self
.
stream
.
read
()
# self.count += 1
# self.count_dict["count"] = self.count
# if the `grabbed` boolean is `False`, then we have
# if the `grabbed` boolean is `False`, then we have
# reached the end of the video file
# reached the end of the video file
if
grabbed
is
False
or
frame
is
None
:
if
grabbed
is
False
or
frame
is
None
:
#self.stopped = True
#self.stopped = True
# self.count = 0
# self.count_dict["count"] = self.count
self
.
build_cv_obj
()
self
.
build_cv_obj
()
continue
continue
# if there are transforms to be done, might as well
# if there are transforms to be done, might as well
...
@@ -99,14 +88,9 @@ class FileVideoStream:
...
@@ -99,14 +88,9 @@ class FileVideoStream:
self
.
stream
.
release
()
self
.
stream
.
release
()
def
read
(
self
):
def
read
(
self
):
# return next frame in the queue
# return next frame in the queue
return
self
.
Q
.
get
()
return
self
.
Q
.
get
()
def
get_frame_count
(
self
):
# return next frame in the queue
return
self
.
count
# Insufficient to have consumer use while(more()) which does
# Insufficient to have consumer use while(more()) which does
# not take into account if the producer has reached end of
# not take into account if the producer has reached end of
...
...
logs/ilens-edge_engine.log
View file @
8592705b
...
@@ -36545,3 +36545,14 @@ DETAIL: Failing row contains (4, 0, 2023-01-05 15:52:35.882488, null).
...
@@ -36545,3 +36545,14 @@ DETAIL: Failing row contains (4, 0, 2023-01-05 15:52:35.882488, null).
2023-01-06 15:59:05,026 INFO ilens-edge_engine Setting up frame processor !!
2023-01-06 15:59:05,026 INFO ilens-edge_engine Setting up frame processor !!
2023-01-06 15:59:05,545 INFO ilens-edge_engine []
2023-01-06 15:59:05,545 INFO ilens-edge_engine []
2023-01-06 15:59:06,591 INFO ilens-edge_engine []
2023-01-06 15:59:06,591 INFO ilens-edge_engine []
2023-01-06 16:31:43,198 INFO ilens-edge_engine building publishers
2023-01-06 16:31:43,859 INFO ilens-edge_engine Setting up frame processor !!
2023-01-06 16:32:31,830 INFO ilens-edge_engine building publishers
2023-01-06 16:32:32,123 INFO ilens-edge_engine Setting up frame processor !!
2023-01-06 16:32:32,613 INFO ilens-edge_engine []
2023-01-06 16:32:33,390 INFO ilens-edge_engine []
2023-01-06 16:32:39,091 INFO ilens-edge_engine []
2023-01-06 16:32:40,244 INFO ilens-edge_engine []
2023-01-06 16:32:41,158 INFO ilens-edge_engine []
2023-01-06 16:32:42,103 INFO ilens-edge_engine []
2023-01-06 16:32:43,282 INFO ilens-edge_engine []
scripts/ppe.py
View file @
8592705b
...
@@ -653,8 +653,8 @@ class Ppe(ModelWrapper):
...
@@ -653,8 +653,8 @@ class Ppe(ModelWrapper):
self
.
violation_count
=
{
"Air Breathing Mask"
:
[],
"Safety helmet"
:
[],
"Hand gloves"
:
[],
"coverall suit"
:
[]}
self
.
violation_count
=
{
"Air Breathing Mask"
:
[],
"Safety helmet"
:
[],
"Hand gloves"
:
[],
"coverall suit"
:
[]}
# 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(0)
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
)):
...
@@ -789,8 +789,8 @@ class Ppe(ModelWrapper):
...
@@ -789,8 +789,8 @@ class Ppe(ModelWrapper):
1
,
cv2
.
LINE_AA
)
1
,
cv2
.
LINE_AA
)
cv2
.
imshow
(
"output is "
,
cv2
.
resize
(
frame
,
(
1000
,
800
)))
#
cv2.imshow("output is ", cv2.resize(frame, (1000, 800)))
cv2
.
waitKey
(
1
)
#
cv2.waitKey(1)
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
exception
(
f
"Error: {e}"
,
exc_info
=
True
)
logger
.
exception
(
f
"Error: {e}"
,
exc_info
=
True
)
obj
[
'frame'
]
=
cv2
.
resize
(
obj
[
'frame'
],
(
self
.
config
.
get
(
'FRAME_WIDTH'
),
self
.
config
.
get
(
'FRAME_HEIGHT'
)))
obj
[
'frame'
]
=
cv2
.
resize
(
obj
[
'frame'
],
(
self
.
config
.
get
(
'FRAME_WIDTH'
),
self
.
config
.
get
(
'FRAME_HEIGHT'
)))
...
...
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