Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 有没有办法提高opencv视频处理的速度?_Python_Opencv_Python Multithreading_Video Processing - Fatal编程技术网

Python 有没有办法提高opencv视频处理的速度?

Python 有没有办法提高opencv视频处理的速度?,python,opencv,python-multithreading,video-processing,Python,Opencv,Python Multithreading,Video Processing,有没有一种方法可以引入线程的概念来更快地处理视频 我试着用这个: 我尝试实例化\uuuuu init\uuuuuu>方法线程,但是,如何将其与读取while循环内帧的while循环连接起来。以下是有用的教程: out = cv2.VideoWriter(output_file, codec, fps, (width,height)) while video.isOpened(): has_frame, image = video.read() if has_frame:

有没有一种方法可以引入线程的概念来更快地处理视频

我试着用这个:
我尝试实例化
\uuuuu init\uuuuuu>方法线程,但是,如何将其与读取while循环内帧的while循环连接起来。

以下是有用的教程:

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