G_type_set_qdata: assertion 'quark != 0' failed roi = hailo.get_roi_from_buffer(frame) Segmentation fault

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

Hey @haldun,

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:

  1. Convert the frame format:

    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    
  2. Debug the frame input:

    print(frame.shape, type(frame))
    
  3. Ensure buffer compatibility with the Hailo API.

  4. Manage memory carefully, especially given the Raspberry Pi’s limitations.

  5. Verify correct Hailo device and pipeline initialization.

  6. 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!

hello

No module named ‘hailo’

  • I have executed the previous code, but I encountered the error that I sent you earlier.

cap = cv2.VideoCapture(“rtsp://admin:[email protected]:554/Streaming/Channels/1/”)

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)
print('hailo while ',detections)

Process detections…

except Exception as e:
print(f"Error occurred: {e}")
break

cap.release()