问题描述
out = cv2.VideoWriter(output_file,codec,fps,(width,height))
while video.isOpened():
has_frame,image = video.read()
if has_frame:
image_in = cv2.cvtColor(image,cv2.COLOR_BGR2RGB)
image_in = tf.expand_dims(image_in,0)
image_in = transform_images(image_in,FLAGS.size)
Boxes,scores,classes,nums = get_yolo_model()(image_in)
image = draw_outputs(image,(Boxes,nums),get_class_names())
image = cv2.putText(
image,"",(0,30),cv2.FONT_HERShey_COMPLEX_SMALL,1,255),2
)
out.write(image)
frame_count += 1
print('[In progress...] Writing frame:',frame_count)
else:
break
有没有一种方法可以引入线程化的概念来更快地处理视频?
我尝试使用此命令:How to increase performance of OpenCV cv2.VideoCapture(0).read()
我尝试实例化__init__
方法线程化,但是,如何将其与while循环连接以读取while循环中的帧。