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
Nikola Balog
osie
Commits
7be11596
Commit
7be11596
authored
Oct 09, 2020
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start and stop conveyor.
parent
d254265e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
6 deletions
+26
-6
eggs/osie_plc/osie_ocr.py
eggs/osie_plc/osie_ocr.py
+26
-6
No files found.
eggs/osie_plc/osie_ocr.py
View file @
7be11596
...
...
@@ -18,18 +18,33 @@ def nothing(x):
# any operation
pass
def
se
ndModbusCommand
(
):
def
se
tConveyorState
(
state
):
"""
XXX: Pure example.
Send to modbus server command to start (state 1)
or stop (state 0) conveyor.
"""
client
=
ModbusClient
(
OSIE_PLC_ADDRESS
,
port
=
OSIE_PLC_PORT
)
client
.
connect
()
client
.
write_coils
(
0
,
[
state
],
unit
=
UNIT
)
client
.
close
()
def
openAndCloseAirValve
(
seconds
=
0.05
):
"""
Send to modbus server command to open and close the air valve for
a specified amount of time in seconds.
"""
client
=
ModbusClient
(
OSIE_PLC_ADDRESS
,
port
=
OSIE_PLC_PORT
)
client
.
connect
()
#rr = client.read_coils(1, 1, unit=UNIT)
client
.
write_coils
(
1
,
[
True
],
unit
=
UNIT
)
sleep
(
0.05
)
sleep
(
seconds
)
client
.
write_coils
(
1
,
[
False
],
unit
=
UNIT
)
client
.
close
()
# start conveyor
setConveyorState
(
1
)
cap
=
cv2
.
VideoCapture
(
1
)
cv2
.
namedWindow
(
"Trackbars"
)
cv2
.
createTrackbar
(
"L-H"
,
"Trackbars"
,
0
,
180
,
nothing
)
...
...
@@ -78,15 +93,15 @@ while True:
if
len
(
approx
)
==
3
:
cv2
.
putText
(
frame
,
"Triangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
sendModbusCommand
()
openAndCloseAirValve
()
elif
len
(
approx
)
==
4
:
cv2
.
putText
(
frame
,
"Rectangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
sendModbusCommand
()
openAndCloseAirValve
()
elif
10
<
len
(
approx
)
<
20
:
cv2
.
putText
(
frame
,
"Circle-fire!"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
sendModbusCommand
()
openAndCloseAirValve
()
cv2
.
imshow
(
"Frame"
,
frame
)
cv2
.
imshow
(
"Mask"
,
mask
)
...
...
@@ -97,3 +112,8 @@ while True:
cap
.
release
()
cv2
.
destroyAllWindows
()
# stop conveyor
setConveyorState
(
0
)
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