i have error ‘NoneType’ has no attribute ‘shape’, i assume its because camera connection.
BUT, when i check on default live preview IP Camera everything is ok. the error is only between python and camera.
here my example code
while True:
try:
ret, frame = capture.read()
frame = camera.get_frame(frame, id_cam, 0)
if frame is not None:
if hasattr(frame, 'shape') and frame.shape is not None:
update_status_camera(id_cam, 1, 1)
# Convert frame to bytes
frame_bytes = cv2.imencode('.jpg', frame)[1].tobytes()
# Include ratio in the response as bytes
yield (b'--framern'
b'Content-Type: image/jpegrnrn' + frame_bytes + b'rn')
else:
pass
else:
pass
except Exception as e:
update_status_camera(id_cam, 1, 0)
print(f"{device_code} Terjadi kesalahan saat mengambil frame:", e)
yield None
when connection is lost, it will running to exception.
how to solve this problem?