gpt4 book ai didi

python - cv2.imshow 失败 : Fontconfig error: failed reading config file

转载 作者:行者123 更新时间:2023-12-04 16:39:59 25 4
gpt4 key购买 nike

在运行代码时

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
# Capture frame-by-frame
ret, frame = cap.read()

# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

我有一个错误:

字体配置错误:读取配置文件失败

(python:5882): Gtk-CRITICAL **: IA__gtk_widget_style_get: 断言 'GTK_IS_WIDGET (widget)' 失败

最佳答案

TL;DR:现在,这不是一个很好的解决方案,但我已经通过降级我的版本解决了这个问题,所以只需运行:

pip 卸载 opencv-python

pip install -Iv opencv-python==4.2.0.34

自从我转移到 OpenCV 4.3.0.36 后,我也遇到了同样的问题。我使用 Ubuntu 16.04,可以将问题缩小到 opencv_python.libs 目录下的 libfontconfig-42c558d2.so.1.11.1 库。

顺便提一下,我使用的是虚拟环境。在我看来,这个问题是由于操作系统的libfontconfig和OpenCV自己的版本之间的冲突,因为在许可文件中有如下声明。

libfontconfig is redistributed within all opencv-python Linux and macOS packages.

...我在以前的版本中没有遇到过这样的问题。

您可以看到完整的简历版本列表 here如果这对你有用。希望这个旁路对您有所帮助,尤其是当您有最后期限或其他事情时。

关于python - cv2.imshow 失败 : Fontconfig error: failed reading config file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62888765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com