When I run yolo_video.py, the following error occurs:
Traceback (most recent call last):
File "yolo_video.py", line 14, in <module>
detect_video(YOLO(), video_path, output_path)
File "/home/wyf/PycharmProjects/keras-yolo3/yolo.py", line 179, in detect_video
image = Image.fromarray(frame)
File "/home/wyf/anaconda2/envs/tf14py3/lib/python3.5/site-packages/PIL/Image.py", line 2421, in fromarray
arr = obj.__array_interface__
AttributeError: 'NoneType' object has no attribute '__array_interface__'
I think the problem occurs because the following code returns none. I wonder it's concerned about opencv. Here my environment is ubuntu16.04, tensorflow1.4 under Anaconda, python3.5, and opencv-python (3.4.1.15). I don't figure out how to solve it, can anyone help?
return_value, frame = vid.read()
first the problem could arise due to the codec: (in yolo.py)
change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')
another change can be made after reading the image in line 182: (in yolo.py)
return_value, frame = vid.read()
if not return_value:
break
this solves the issue with getting an empty frame and trying to save it.
change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')
*'xxxx' is decided by your video format, for me, I use *'FLV1' for .flv video
Most helpful comment
first the problem could arise due to the codec: (in yolo.py)
change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')
another change can be made after reading the image in line 182: (in yolo.py)
return_value, frame = vid.read()
if not return_value:
break
this solves the issue with getting an empty frame and trying to save it.