Skip to content

Commit

Permalink
Refactor SymbolDetector to fit into threaded process
Browse files Browse the repository at this point in the history
  • Loading branch information
MDP G14 RPI committed Oct 1, 2019
1 parent 69c5ea6 commit 004dc7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/communicator/MultiThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(self):
# self.android.connect()
# self.arduino.connect()
# self.pc.connect()
self.detector.start()

self.android_queue = queue.Queue(maxsize= 0)
self.arduino_queue = queue.Queue(maxsize=0)
Expand Down Expand Up @@ -110,6 +111,10 @@ def write_pc(self, pc_queue):
log.info('Write PC: ' + str(msg))

def detect_symbols(self):
self.detector.start()
self.detector.detect()
while True:
frame = self.detector.get_frame()
symbol_match = self.detector.detect(frame)
if symbol_match is not None:
# Push to queue
print('Symbol Match ID: ' + str(symbol_match))

4 changes: 2 additions & 2 deletions src/detector/SymbolDetector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def get_frame(self):
return self.video_stream.read()

def detect(self, image):
image = self.video_stream.read()
pre_proc_frame = preprocess_frame(image)

# Uncomment if debugging threshold value
Expand Down Expand Up @@ -109,7 +108,8 @@ def detect(self, image):
self.match_count = self.match_count + 1
if (self.match_count == MATCH_CONFIDENCE_COUNT):
# TO-DO: Ping to PC/N7 about the detected Symbol's ID
log.info('Found: ' + str(closest_match['symbol']) + '; ID: ' + str(closest_match['id']))
# log.info('Found: ' + str(closest_match['symbol']) + '; ID: ' + str(closest_match['id']))
return(closest_match['id'])
else:
self.match_symbol_id = closest_match['id']
self.match_count = 1
Expand Down

0 comments on commit 004dc7a

Please sign in to comment.