hailort for rpi 5 isn’t exist?
I did compile yolov5s.hef(for hailo8l)
And I put my code
“libcamera-vid -t 0 --width 640 --height 480 --inline --listen --vflip --hflip -o tcp://0.0.0.0:8888”
“python infer_yolo_hailo_stream.py”
(hailo_env38) pinky@pinky:~/yolov5$ python infer_yolo_hailo_stream.py
Traceback (most recent call last):
File “infer_yolo_hailo_stream.py”, line 3, in
import hailort
ModuleNotFoundError: No module named ‘hailort’
This is mystery error…
I installed ‘hailort-4.21.0-cp38-cp38-linux_aarch64.whl’, ‘hailort_4.21.0_arm64.deb’, ‘hailo_model_zoo-2.15.0-py3-none-any.whl’.
The program need ‘pyhailo’. But I can’t find it.
How can I do?
#infer_yolo_hailo_stream.py
from flask import Flask, Response
import cv2
import hailo
from hailo.platform import HailoRT
from hailo.model_zoo.core.postprocessing.detection_postprocessing import yolo_postprocessing
from hailo.model_zoo.utils import path_resolver
app = Flask(name)
모델 설정
hef_path = “yolov5s.hef”
yolo_anchors = [[10, 13], [16, 30], [33, 23], [30, 61], [62, 45], [59, 119], [116, 90], [156, 198], [373, 326]]
Hailo 장치 초기화
hef = HailoRT.Hef(hef_path)
device = HailoRT.Device()
network_group = device.configure(hef, HailoRT.ConfigureParams()).wait()
input_vstream = network_group.create_input_vstream()
output_vstreams = network_group.create_output_vstreams()
영상 입력 (libcamera 스트림 수신)
cap = cv2.VideoCapture(“tcp://127.0.0.1:8888”, cv2.CAP_FFMPEG)
def infer_stream():
while True:
ret, frame = cap.read()
if not ret:
continue
# 전처리
resized = cv2.resize(frame, (640, 640))
rgb = cv2.cvtColor(resized, cv2.COLOR_BGR2RGB)
# 추론
input_vstream.send(rgb)
outputs = [out.receive() for out in output_vstreams]
# 후처리
bboxes, scores, class_ids = yolo_postprocessing(outputs, anchors=yolo_anchors)
# Bounding box 표시
for box, score, cls_id in zip(bboxes, scores, class_ids):
x1, y1, x2, y2 = map(int, box)
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.putText(frame, f'{cls_id}:{score:.2f}', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,0), 1)
# 스트리밍
_, buffer = cv2.imencode('.jpg', frame)
frame = buffer.tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route(‘/’)
def index():
return “
YOLOv5 + Hailo 추론 웹 스트리밍
@app.route(‘/video’)
def video():
return Response(infer_stream(), mimetype=‘multipart/x-mixed-replace; boundary=frame’)
if name == ‘main’:
app.run(host=‘0.0.0.0’, port=5000)