|
5 | 5 | import argparse |
6 | 6 |
|
7 | 7 | import cv2 |
8 | | - |
9 | 8 | from picamera2 import MappedArray, Picamera2, Preview |
10 | | -from picamera2.devices import Hailo |
| 9 | +from picamera2.devices import Hailo, hailo_architecture |
11 | 10 |
|
12 | 11 |
|
13 | 12 | def extract_detections(hailo_output, w, h, class_names, threshold=0.5): |
@@ -38,14 +37,22 @@ def draw_objects(request): |
38 | 37 | if __name__ == "__main__": |
39 | 38 | # Parse command-line arguments. |
40 | 39 | parser = argparse.ArgumentParser(description="Detection Example") |
41 | | - parser.add_argument("-m", "--model", help="Path for the HEF model.", |
42 | | - default="/usr/share/hailo-models/yolov8s_h8l.hef") |
| 40 | + parser.add_argument("-m", "--model", help="Path for the HEF model. " |
| 41 | + "Defaults to /usr/share/hailo-models/yolov8s_h8l.hef for H8 devices, " |
| 42 | + "and /usr/share/hailo-models/yolov8m_h10.hef for H10 devices.", |
| 43 | + default=None) |
43 | 44 | parser.add_argument("-l", "--labels", default="coco.txt", |
44 | 45 | help="Path to a text file containing labels.") |
45 | 46 | parser.add_argument("-s", "--score_thresh", type=float, default=0.5, |
46 | 47 | help="Score threshold, must be a float between 0 and 1.") |
47 | 48 | args = parser.parse_args() |
48 | 49 |
|
| 50 | + if args.model is None: |
| 51 | + if hailo_architecture() == 'HAILO10H': |
| 52 | + args.model = '/usr/share/hailo-models/yolov8m_h10.hef' |
| 53 | + else: |
| 54 | + args.model = '/usr/share/hailo-models/yolov8s_h8l.hef' |
| 55 | + |
49 | 56 | # Get the Hailo model, the input size it wants, and the size of our preview stream. |
50 | 57 | with Hailo(args.model) as hailo: |
51 | 58 | model_h, model_w, _ = hailo.get_input_shape() |
|
0 commit comments