gpt4 book ai didi

python - opencv-python 中的 imshow 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 21:11:59 24 4
gpt4 key购买 nike

执行cv2.imshow时出现错误,程序崩溃

我的代码只是

import cv2
sscv = cv2.imread('/home/myuser/Pictures/Workspace 1_007.png',0)
cv2.imshow("screenshot image", sscv)
cv2.waitKey(0)

显示的错误是

    /home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: cannot register existing type 'GdkDisplayManager'
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: g_once_init_leave: assertion 'result != 0' failed
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: invalid (NULL) pointer instance
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: cannot register existing type 'GdkDisplay'
cv2.imshow("screenshot image", sscv)
/home/mallory/workspace/python-autoaction/test/test_xutils.py:11: Warning: g_type_register_static: assertion 'parent_type > 0' failed
cv2.imshow("screenshot image", sscv)
Segmentation fault (core dumped)

使用

  • Ubuntu 14.0.4
  • python 2.7.6
  • cv2 2.4.8

这有什么问题吗?

最佳答案

尝试再次安装这些依赖项,如果问题仍然存在请告诉我

sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils ffmpeg cmake qt5-default checkinstall

之后就可以了

cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..
make -j2
sudo checkinstall
sudo sh -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

关于python - opencv-python 中的 imshow 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27647689/

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