detection ok

This commit is contained in:
neo-dl 2022-07-29 18:54:27 +02:00
parent 8635c7fd37
commit 6e8a6ab806
4 changed files with 12 additions and 5 deletions

View File

@ -2,4 +2,5 @@
this: this this: this
mino: mino mino: mino
DESKTOP-VOCOB38: vm DESKTOP-VOCOB38: vm
neodl-MS-7A62: neo-dl
ST-RES-1: stres1 ST-RES-1: stres1

View File

@ -0,0 +1,7 @@
[tecna_t3]
port: /dev/ttyUSB0
[neo_pixels]
port: /dev/ttyACM0
baudrate: 9600

View File

@ -344,7 +344,9 @@ class Vision(Component):
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:
tensor = np.expand_dims(frame, axis=0) frame_resized=cv2.resize(frame, (256,256), interpolation=cv2.INTER_LINEAR)
tensor = tf.convert_to_tensor(np.asarray(frame_resized))
tensor = tensor[tf.newaxis, ...]
# Run inference # Run inference
if lock: if lock:
self.lock.lock() self.lock.lock()
@ -391,10 +393,7 @@ class Vision(Component):
"detection_classes": [map(lambda class_id: class_id + 1, class_ids)][0:1], "detection_classes": [map(lambda class_id: class_id + 1, class_ids)][0:1],
} }
else: else:
input_tensor = tf.convert_to_tensor(np.asarray(tensor)) detections = self.model(tensor)
#input_tensor = input_tensor[tf.newaxis, ...]
detections = self.model(input_tensor)
if lock: if lock:
self.lock.unlock() self.lock.unlock()
# WARNING: results other than the ones related to tensor[-1] will be discarded # WARNING: results other than the ones related to tensor[-1] will be discarded

0
src/test/detection.py Normal file
View File