Commit 613205dc authored by Ivan Tyagov's avatar Ivan Tyagov

Add a new mode of operation which will disable camera integration

(for testing purposes).
parent 78f6249b
...@@ -40,6 +40,7 @@ a('--ipv4', help='The IPv4 address on which the OPC UA server runs', default="0. ...@@ -40,6 +40,7 @@ a('--ipv4', help='The IPv4 address on which the OPC UA server runs', default="0.
a('--port', help='The port on which the OPC UA server runs', default="4840") a('--port', help='The port on which the OPC UA server runs', default="4840")
a('--camera', help='The index of the camera (i.e. indxed in /dev/videoX)', default=0) a('--camera', help='The index of the camera (i.e. indxed in /dev/videoX)', default=0)
a('--headless', help='Run without screen in a headless mode (boolean, default=0)', default=False) a('--headless', help='Run without screen in a headless mode (boolean, default=0)', default=False)
a('--mode', help='Mode of operation. The default is to read data from camera device. If set to 1 do NOT read data from camera device. (default=0)', default=0)
# XXX: allow to specify from CLI DEFAULT_LH & friends # XXX: allow to specify from CLI DEFAULT_LH & friends
args = parser.parse_args() args = parser.parse_args()
...@@ -47,6 +48,7 @@ ipv4 = args.ipv4 ...@@ -47,6 +48,7 @@ ipv4 = args.ipv4
port = args.port port = args.port
camera = int(args.camera) camera = int(args.camera)
headless = bool(int(args.headless)) headless = bool(int(args.headless))
mode = bool(int(args.mode))
def nothing(x): def nothing(x):
# any operation # any operation
...@@ -74,6 +76,7 @@ async def main(): ...@@ -74,6 +76,7 @@ async def main():
result_stack = [] result_stack = []
current_shape = 0.0 current_shape = 0.0
if not mode:
# init camera # init camera
cap = cv2.VideoCapture(camera) cap = cv2.VideoCapture(camera)
font = cv2.FONT_HERSHEY_COMPLEX font = cv2.FONT_HERSHEY_COMPLEX
...@@ -97,6 +100,7 @@ async def main(): ...@@ -97,6 +100,7 @@ async def main():
# recognition. Thus give (roughly) some CPU time so both can work together. # recognition. Thus give (roughly) some CPU time so both can work together.
await asyncio.sleep(SLEEP_DURATION) await asyncio.sleep(SLEEP_DURATION)
if not mode:
before = time.time() * 1000 before = time.time() * 1000
# read and process camera # read and process camera
_, frame = cap.read() _, frame = cap.read()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment