This cv2.imdecode is only giving warning instead of raising error.
# Decode the JPEG bytes into a numpy array
frame = np.frombuffer(bytes_jpeg, dtype=np.uint8)
# Decode the JPEG numpy array into a frame
frame = cv2.imdecode(frame, cv2.IMREAD_COLOR)
Even when I check is none by if frame is None: print('Corrupt'), it's always not printed. How do I catch is bytes_jpeg is corrupted jpeg?
Here is the warnings:
Corrupt JPEG data: premature end of data segment
Corrupt JPEG data: premature end of data segment
Corrupt JPEG data: 45342 extraneous bytes before marker 0xd8
Corrupt JPEG data: 17587 extraneous bytes before marker 0xd9