ADEEPT AWR Wheeled Robot Manual page 103

4wd smart robot kit compatible with raspberry pi 4 3 model b+ b, opencv target tracking
Table of Contents

Advertisement

94
from
thread
import
except
ImportError:
from
_thread
class
CameraEvent(object):
"""An Event-like class that signals all active clients when a new frame is
available.
"""
def
__init__(self):
self.events = {}
def
wait(self):
"""Invoked from each client's thread to wait for the next frame."""
ident = get_ident()
if
ident
not in
# this is a new client
# add an entry for it in the self.events dict
# each entry has two elements, a threading.Event() and a timestamp
self.events[ident] = [threading.Event(), time.time()]
return
self.events[ident][0].wait()
def
set(self):
"""Invoked by the camera thread when a new frame is available."""
now = time.time()
remove =
None
for
ident, event
if not event[0].isSet():
# if this client's event is not set, then set it
# also update the last set timestamp to now
event[0].set()
event[1] = now
else:
# if the client's event is already set, it means the client
# did not process a previous frame
# if the event stays set for more than 5 seconds, then assume
# the client is gone and remove it
if
now - event[1] > 5:
if
remove:
del
self.events[remove]
def
clear(self):
get_ident
import
get_ident
self.events:
in
self.events.items():
remove = ident

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?

This manual is also suitable for:

Picar-b

Table of Contents

Save PDF