but i have another question :
I want to perform separate detection using my business , as I have some specific code I want to implement. Is this possible as in the following example?"
cap = cv2.VideoCapture("speed3.mp4")
while True:
success, frame = cap.read()
roi = hailo.get_roi_from_buffer(frame)
detections = roi.get_objects_typed(hailo.HAILO_DETECTION)
can I do that I try but I get this error:
(venv_hailo_rpi5_examples) rasai@raspberrypi:~/kh/hailo-rpi5-examples $ python basic_pipelines/detection.py
/home/rasai/kh/hailo-rpi5-examples/basic_pipelines/detection.py:99: Warning: g_type_set_qdata: assertion ‘quark != 0’ failed
roi = hailo.get_roi_from_buffer(frame)
Segmentation fault
The error you’re seeing (g_type_set_qdata: assertion 'quark != 0' failed followed by a segmentation fault) likely stems from how the Hailo API is handling the video stream buffer. This could be due to memory mismanagement or a data type mismatch between OpenCV and the Hailo API.
To resolve this, try the following:
Convert the frame format:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
Debug the frame input:
print(frame.shape, type(frame))
Ensure buffer compatibility with the Hailo API.
Manage memory carefully, especially given the Raspberry Pi’s limitations.
Verify correct Hailo device and pipeline initialization.
Update to the latest Hailo SDK version.
Here’s a modified code snippet addressing these points:
import cv2
import hailo
cap = cv2.VideoCapture("speed3.mp4")
device = hailo.Device()
pipeline = hailo.create_pipeline(device)
while True:
success, frame = cap.read()
if not success:
break
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
try:
roi = hailo.get_roi_from_buffer(frame)
detections = roi.get_objects_typed(hailo.HAILO_DETECTION)
# Process detections...
except Exception as e:
print(f"Error occurred: {e}")
break
cap.release()
cv2.destroyAllWindows()
Let me know if you need any further clarification or assistance!