关于object detection运行视频检测代码出现报错:ValueError:assignment destination is read-only

我参考博主 withzheng的博客:https://blog.csdn.net/xiaoxiao123jun/article/details/76605928

在视频物体识别的部分中,我用的是Anaconda自带的spyder(python3.6)来运行他给的视频检测代码,出现了如下报错,图片说明

具体报错:
Moviepy - Building video video1_out.mp4.
Moviepy - Writing video video1_out.mp4

t: 7%|▋ | 7/96 [00:40<09:17, 6.26s/it, now=None]Traceback (most recent call last):

File "", line 1, in
runfile('C:/models-master1/research/object_detection/object_detection_tutorial (1).py', wdir='C:/models-master1/research/object_detection')

File "C:\Users\Administrator\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(),filename,'exec'), namespace)

File "C:/models-master1/research/object_detection/object_detection_tutorial (1).py", line 273, in
white_clip.write_videofile(white_output, audio=False)

File "", line 2, in write_videofile

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)

File "", line 2, in write_videofile

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
return f(clip, *new_a, **new_kw)

File "", line 2, in write_videofile

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
return f(clip, *a, **k)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\video\VideoClip.py", line 326, in write_videofile
logger=logger)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 216, in ffmpeg_write_video
fps=fps, dtype="uint8"):

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\Clip.py", line 475, in iter_frames
frame = self.get_frame(t)

File "", line 2, in get_frame

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
return f(*new_a, **new_kw)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
return self.make_frame(t)

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\Clip.py", line 138, in
newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))

File "C:\Users\Administrator\Anaconda3\lib\site-packages\moviepy\video\VideoClip.py", line 511, in
return self.fl(lambda gf, t: image_func(gf(t)), apply_to)

File "C:/models-master1/research/object_detection/object_detection_tutorial (1).py", line 267, in process_image
image_process=detect_objects(image,sess,detection_graph)

File "C:/models-master1/research/object_detection/object_detection_tutorial (1).py", line 258, in detect_objects
line_thickness=8)

File "C:\models-master1\research\object_detection\utils\visualization_utils.py", line 743, in visualize_boxes_and_labels_on_image_array
use_normalized_coordinates=use_normalized_coordinates)

File "C:\models-master1\research\object_detection\utils\visualization_utils.py", line 129, in draw_bounding_box_on_image_array
np.copyto(image, np.array(image_pil))

ValueError: assignment destination is read-only

想问问各位大神有遇到过类似的问题吗。。如何解决?

1个回答

原:image_process = detect_objects(image, sess, detection_graph)
image_process=detect_objects(np.array(image),sess,detection_graph) 改成这个就好了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问