This commit is contained in:
matteo porta 2022-07-27 16:05:38 +02:00
parent 70c9fb1dbd
commit d9b09debb2

View File

@ -336,8 +336,6 @@ class Vision(Component):
self.loading_model_signal.emit({"status": "done"}) self.loading_model_signal.emit({"status": "done"})
def check_features(self, frame, lock=True): def check_features(self, frame, lock=True):
if frame is None:
return []
if self.interpreter is not None and frame.shape != self.interpreter.get_input_details()[0]["shape"][1:3]: if self.interpreter is not None and frame.shape != self.interpreter.get_input_details()[0]["shape"][1:3]:
tensor = np.expand_dims(cv2.resize(frame, self.interpreter.get_input_details()[0]["shape"][1:3], interpolation=cv2.INTER_LINEAR), axis=0) tensor = np.expand_dims(cv2.resize(frame, self.interpreter.get_input_details()[0]["shape"][1:3], interpolation=cv2.INTER_LINEAR), axis=0)
else: else:
@ -687,13 +685,15 @@ class Vision(Component):
# print("VISION", str(int(QThread.currentThreadId())), flush=True) # print("VISION", str(int(QThread.currentThreadId())), flush=True)
if data is None: if data is None:
return return
frame = data[-1][list(self.sources)[0]]
if frame is not None:
# ADD FRAMETO VISION_CONSUMER QUEUE # ADD FRAMETO VISION_CONSUMER QUEUE
self.vision_consumer.add_consumable({"frame": data[-1][list(self.sources)[0]]}) self.vision_consumer.add_consumable({"frame": frame})
super()._get(emit=False) super()._get(emit=False)
def vision_consumer_work(self, consumable=None): def vision_consumer_work(self, consumable=None):
# VISION_CONSUMER TASK # VISION_CONSUMER TASK
if consumable is None or consumable["frame"] is None: if consumable is None:
return return
detections = self.check_features(consumable["frame"]) detections = self.check_features(consumable["frame"])
results = self.process_detections(detections) results = self.process_detections(detections)