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
Martin Manchev
osie
Commits
ebf0b15b
Commit
ebf0b15b
authored
Oct 16, 2020
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save frames locally.
parent
7aa390b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
1 deletion
+23
-1
eggs/osie_plc/osie_ocr.py
eggs/osie_plc/osie_ocr.py
+23
-1
No files found.
eggs/osie_plc/osie_ocr.py
View file @
ebf0b15b
...
@@ -8,11 +8,14 @@ import numpy as np
...
@@ -8,11 +8,14 @@ import numpy as np
import
pymodbus
import
pymodbus
from
pymodbus.client.sync
import
ModbusTcpClient
as
ModbusClient
from
pymodbus.client.sync
import
ModbusTcpClient
as
ModbusClient
from
time
import
sleep
from
time
import
sleep
from
datetime
import
datetime
import
os
import
time
UNIT
=
0x1
UNIT
=
0x1
OSIE_PLC_ADDRESS
=
"localhost"
# "192.168.0.48" for real machine
OSIE_PLC_ADDRESS
=
"localhost"
# "192.168.0.48" for real machine
#OSIE_PLC_ADDRESS = "192.168.0.48"
OSIE_PLC_PORT
=
502
OSIE_PLC_PORT
=
502
ROOT_FOLDER_PATH
=
"/mnt/flash"
def
nothing
(
x
):
def
nothing
(
x
):
# any operation
# any operation
...
@@ -42,6 +45,22 @@ def openAndCloseAirValve(seconds=0.05):
...
@@ -42,6 +45,22 @@ def openAndCloseAirValve(seconds=0.05):
client
.
write_coils
(
1
,
[
False
],
unit
=
UNIT
)
client
.
write_coils
(
1
,
[
False
],
unit
=
UNIT
)
client
.
close
()
client
.
close
()
def
storeFrame
(
frame
):
"""
Store a video frame in locally.
"""
folder_path
=
"%s/%s"
%
(
ROOT_FOLDER_PATH
,
datetime
.
today
().
strftime
(
'%Y-%m-%d'
))
if
not
os
.
path
.
isdir
(
folder_path
):
os
.
mkdir
(
folder_path
)
millis
=
int
(
round
(
time
.
time
()
*
1000
))
file_path
=
"%s/%s.jpg"
%
(
folder_path
,
millis
)
cv2
.
imwrite
(
file_path
,
frame
)
#f = open(file_path, "w")
#f.write(file_content)
#f.close()
# start conveyor
# start conveyor
setConveyorState
(
1
)
setConveyorState
(
1
)
...
@@ -93,14 +112,17 @@ while True:
...
@@ -93,14 +112,17 @@ while True:
if
len
(
approx
)
==
3
:
if
len
(
approx
)
==
3
:
cv2
.
putText
(
frame
,
"Triangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
cv2
.
putText
(
frame
,
"Triangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
storeFrame
(
frame
)
openAndCloseAirValve
()
openAndCloseAirValve
()
elif
len
(
approx
)
==
4
:
elif
len
(
approx
)
==
4
:
cv2
.
putText
(
frame
,
"Rectangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
cv2
.
putText
(
frame
,
"Rectangle"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
storeFrame
(
frame
)
openAndCloseAirValve
()
openAndCloseAirValve
()
elif
10
<
len
(
approx
)
<
20
:
elif
10
<
len
(
approx
)
<
20
:
cv2
.
putText
(
frame
,
"Circle-fire!"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
cv2
.
putText
(
frame
,
"Circle-fire!"
,
(
x
,
y
),
font
,
1
,
(
0
,
0
,
0
))
storeFrame
(
frame
)
openAndCloseAirValve
()
openAndCloseAirValve
()
cv2
.
imshow
(
"Frame"
,
frame
)
cv2
.
imshow
(
"Frame"
,
frame
)
...
...
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