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
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
nexedi
osie
Commits
c0d01905
Commit
c0d01905
authored
Jun 20, 2024
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Plain Diff
Oi sensor
See merge request
!57
parents
99145da9
a8a51c02
Changes
1
Hide 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 @
c0d01905
...
...
@@ -70,6 +70,7 @@ async def main():
# Initialize
result
=
0.0
shape_change_counter
=
0
result_stack
=
[]
current_shape
=
0.0
...
...
@@ -157,23 +158,13 @@ async def main():
result
=
3.0
# 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)
default_occurence_number
=
5
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
await
myvar
.
write_value
(
result
)
current_shape
=
result
shape_change_counter
+=
1
await
myvar
.
write_value
(
result
)
# break current countour detection loop as in this example we care
# for first detected SHAPE, we do not expect more shapes
...
...
@@ -183,8 +174,10 @@ async def main():
# no countours actually detected thus update OPC UA server's node attribute
result
=
0.0
result_stack
.
append
(
result
)
current_shape
=
result
shape_change_counter
+=
1
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
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