hello
When I run the following code, I get this error. Can you help me solve this problem?
code is
import hailo
from PIL import Image
import cv2
if name == “main”:
print(‘start AI’)
cap = cv2.VideoCapture(“rtsp://admin:anas1155@192.168.1.168:554/Streaming/Channels/1/”)
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()
I get this error : rasai@raspberrypi:~/kh $ python test.py
It seems the error you’re encountering relates to library conflicts or configuration issues with GLib or OpenCV when accessing the RTSP stream. Here are some steps to help you resolve it:
1. Verify HailoRT Installation and Dependencies
Make sure the HailoRT drivers and libraries are installed correctly. Follow these steps based on the provided installation script:
Add Stream Reconnection Logic:
Handle possible connection drops:
while True:
success, frame = cap.read()
if not success:
print("Failed to retrieve frame. Retrying...")
cap.open("rtsp://admin:anas1155@192.168.1.168:554/Streaming/Channels/1/")
continue
Ensure Proper Use of Hailo Functions:
Confirm that the frame passed to hailo.get_roi_from_buffer() is formatted correctly. If necessary, initialize the HailoRT environment as described in the HailoRT User Guide.
These steps should help you resolve the error. Let me know if you encounter further issues!