提问人:Hugo Van Der Wilt 提问时间:10/12/2023 最后编辑:Hugo Van Der Wilt 更新时间:10/12/2023 访问量:45
我可以在 python 中抑制 OpenCV / cv2 警告吗?
Can I supress OpenCV / cv2 warnings in python?
问:
每当我尝试该命令时,我都会收到以下警告cv2.VideoCapture(video_name)
[ WARN:[email protected]] global /private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_11nitadzeg/croot/opencv-suite_1691620374638/work/modules/videoio/src/cap_gstreamer.cpp (2386) handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin
还有 3 个,几乎完全相同。仅来自单行代码 VideoCapture(当然上面有一个导入)的整个警告是
[ WARN:[email protected]] global /private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_11nitadzeg/croot/opencv-suite_1691620374638/work/modules/videoio/src/cap_gstreamer.cpp (2386) handleMessage OpenCV | GStreamer warning: your GStreamer installation is missing a required plugin
[ WARN:[email protected]] global /private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_11nitadzeg/croot/opencv-suite_1691620374638/work/modules/videoio/src/cap_gstreamer.cpp (2402) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module uridecodebin1 reported: Your GStreamer installation is missing a plug-in.
[ WARN:[email protected]] global /private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_11nitadzeg/croot/opencv-suite_1691620374638/work/modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:[email protected]] global /private/var/folders/k1/30mswbxs7r1g6zwn8y4fyt500000gp/T/abs_11nitadzeg/croot/opencv-suite_1691620374638/work/modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
现在,这非常令人讨厌,因为我需要多次使用 VideoCapture 命令。在视频上尝试 tp.batch 命令(将 trackpy 导入为 tp)时,警告会变得更糟。
有什么方法可以阻止所有这些警告吗?
我尝试了以下方法:
os.environ["OPENCV_LOG_LEVEL"] = "SILENT"
、 和 None 都帮上了忙。tp.quiet()
os.environ["OPENCV_LOG_LEVEL"] = "FATAL"
warnings.filterwarnings('ignore').
答: 暂无答案
评论