Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
osie
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
1
Merge Requests
1
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
nexedi
osie
Commits
a8a51c02
Commit
a8a51c02
authored
Jun 20, 2024
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better printout.
Update OPC UA node only if new shape is different than last one.
parent
99145da9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
15 deletions
+8
-15
oi-sensor/oi-sensor.py
oi-sensor/oi-sensor.py
+8
-15
No files found.
oi-sensor/oi-sensor.py
View file @
a8a51c02
...
@@ -70,6 +70,7 @@ async def main():
...
@@ -70,6 +70,7 @@ async def main():
# Initialize
# Initialize
result
=
0.0
result
=
0.0
shape_change_counter
=
0
result_stack
=
[]
result_stack
=
[]
current_shape
=
0.0
current_shape
=
0.0
...
@@ -157,22 +158,12 @@ async def main():
...
@@ -157,22 +158,12 @@ async def main():
result
=
3.0
result
=
3.0
# printout
# printout
print
(
"
\
t
Detected area (px)=%.2f, result=%d
"
%
(
area
,
result
))
print
(
"
\
t
Detected area (px)=%.2f, result=%d
, shape changes=%d"
%
(
area
,
result
,
shape_change_counter
))
# update list for last X results (FILO)
# update list for last X results (FILO)
default_occurence_number
=
5
result_stack
.
append
(
result
)
result_stack
.
append
(
result
)
if
len
(
result_stack
)
>
default_occurence_number
:
# leave only last X items
result_stack
=
result_stack
[
-
default_occurence_number
:]
# to avoid sometimes errors in detection algorithm we change OPC UA node
# variable only if at least we have 2 (40%) of last 5 (100%) items detected as this
# shape. Not complex but avoid false results.
count
=
result_stack
.
count
(
result
)
if
count
>=
2
:
# update OPC UA server's node attribute
current_shape
=
result
current_shape
=
result
shape_change_counter
+=
1
await
myvar
.
write_value
(
result
)
await
myvar
.
write_value
(
result
)
# break current countour detection loop as in this example we care
# break current countour detection loop as in this example we care
...
@@ -183,8 +174,10 @@ async def main():
...
@@ -183,8 +174,10 @@ async def main():
# no countours actually detected thus update OPC UA server's node attribute
# no countours actually detected thus update OPC UA server's node attribute
result
=
0.0
result
=
0.0
result_stack
.
append
(
result
)
result_stack
.
append
(
result
)
current_shape
=
result
shape_change_counter
+=
1
await
myvar
.
write_value
(
result
)
await
myvar
.
write_value
(
result
)
current_shape
=
result
print
(
"
\
t
No shape detected, result=%d, shape changes=%d"
%
(
result
,
shape_change_counter
))
# show current MASK and camera output windows
# show current MASK and camera output windows
if
not
headless
:
if
not
headless
:
...
...
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