有没有办法用opencv提高视频处理速度? [英] Is there a way to increase speed for video processing with opencv?
本文介绍了有没有办法用opencv提高视频处理速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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, scores, classes, nums), get_class_names())
image = cv2.putText(
image,
"",
(0, 30),
cv2.FONT_HERSHEY_COMPLEX_SMALL,
1,
(0, 0, 255),
2
)
out.write(image)
frame_count += 1
print('[In progress...] Writing frame:', frame_count)
else:
break
有什么方法可以引入线程的概念来更快地处理视频吗?
Is there a way I can introduce the concept of threading to process the video faster?
我尝试使用这个:如何提高性能OpenCV cv2.VideoCapture(0).read()我尝试实例化 __init__
方法线程,但是,如何将它与读取 while 循环内的帧的 while 循环连接起来.
I have tried to use this: How to increase performance of OpenCV cv2.VideoCapture(0).read()
I tried instantiating __init__
method Threading, however, how do I connect it with the while loop that reads the frames inside my while loop.
推荐答案
Here are useful tutorials: link1 link2
这篇关于有没有办法用opencv提高视频处理速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文