Python-OpenCV GStreamer警告,长时间运行

Python-OpenCV GStreamer warning, and long time running

提问人:Thanabodi Worakitthamrong 提问时间:9/17/2023 最后编辑:Thanabodi Worakitthamrong 更新时间:9/18/2023 访问量:119

问:

我使用 Python(版本 3.11.5)和 Anaconda 发行版。我通过 Anaconda 安装了 OpenCV(4.6.0 版)和 GStreamer(1.18.5 版)包。我有读取一帧视频的代码:

Import cv2
Import matplotlib.pyplot as plt
video = cv2.VideoCapture(r"file_name.mov")
number_of_frames = int(video.get(cv2.CAP_PROP_FRAME_COUNT))
print("Number of frames: ", str(number_of_frames))
video.set(cv2.CAP_PROP_POS_FRAMES, frame_id)
ret, frame = video.read()
img = np.asarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
fig, axs = plt.subplots()
axs.imshow(img, origin='lower')
plt.show()

代码可以正常运行(在另一台计算机上),但它在我的计算机上无法正常工作。我在 Windows 11 上使用 Visual Studio Code 运行。通常,代码可以在 10 秒内运行,但对于我的计算机,我收到警告并使用了 7 分钟以上的时间来运行它(正常结果)。警告是:

[ WARN:[email protected]] global C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\videoio\src\cap_gstreamer.cpp (2386) cv::handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin
[ WARN:[email protected]] global C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\videoio\src\cap_gstreamer.cpp (2386) cv::handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin
[ WARN:[email protected]] global C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\videoio\src\cap_gstreamer.cpp (2402) cv::handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module uridecodebin0 reported: Your GStreamer installation is missing a plug-in.
[ WARN:[email protected]] global C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\videoio\src\cap_gstreamer.cpp (1356) cv::GStreamerCapture::open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:[email protected]] global C:\b\abs_f8n1j3l9l0\croot\opencv-suite_1691622637237\work\modules\videoio\src\cap_gstreamer.cpp (862) cv::GStreamerCapture::isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created

(python.exe:7476): GLib-GIO-WARNING **: 23:01:55.543: Unexpectedly, UWP app `Microsoft.ScreenSketch_11.2307.45.0_x64__8wekyb3d8bbwe' (AUMId `Microsoft.ScreenSketch_8wekyb3d8bbwe!App') supports 29 extensions but has no verbs

我试图寻找这样的问题的解决方案,但我仍然找不到它。我真的需要大家的帮助来解决这个问题。非常感谢。

python-3.x opencv anaconda 警告 gstreamer

评论


答:

0赞 Thanabodi Worakitthamrong 9/18/2023 #1

我通过卸载 Anaconda 和 Python 解决了这个问题。然后从 https://www.python.org/ 再次安装 python。并使用 Windows 的命令程序安装 NumPy、Matplotlib、pandas、SciPy、OpenCV 等库,一切正常。pip install [libraries-name]