为什么 cv2 在命令行中运行 Python 脚本时有效,而在 IDLE 中运行时无效?

时间:2021-02-01 19:29:49

标签: python opencv cv2

我已经开始使用 PySceneDetect,它使用 OpenCV,特别是 cv2。在命令行中运行我的脚本时,它工作得非常好(参见截图 1):帧速率稳定,处理视频几乎不需要时间。 使用 Python IDLE 时,相同的脚本会遇到内存泄漏(参见截图 2)。 IDLE 的偏好设置中是否有我需要更改的设置,或者还有其他我没有考虑的设置? Script running in the command line

enter image description here

import moviepy
from scenedetect import VideoManager
from scenedetect import SceneManager
from scenedetect.detectors import ContentDetector

video_title = "video.mp4"

def find_scenes(video_path, threshold=5.0):
    # Create our video & scene managers, then add the detector.
    video_manager = VideoManager([video_path])
    scene_manager = SceneManager()
    scene_manager.add_detector(
    ContentDetector(threshold=threshold))

    # Improve processing speed by downscaling before processing.
    video_manager.set_downscale_factor()

    # Start the video manager and perform the scene detection.
    video_manager.start()
    scene_manager.detect_scenes(frame_source=video_manager)

    # Each returned scene is a tuple of the (start, end) timecode.
    return scene_manager.get_scene_list()

print(find_scenes(video_title))

0 个答案:

没有答案
相关问题