当前位置: 首页 > 知识库问答 >
问题:

opencv-python中的imshow不起作用

端木权
2023-03-14

执行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)
    null

那有什么不对?

共有1个答案

姬俊能
2023-03-14

请重新安装这些依赖项,如果问题仍然存在,请通知我

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
 类似资料:
  • 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

  • 我将OpenCV 3.0与python 2.7一起使用。6和玫瑰靛蓝。我通过安装它,并试图做一些天体物体检测。具有讽刺意味的是,所有实际的检测代码似乎都没有问题。不起作用的代码是imshow。它给出了以下错误: OpenCV错误:未指定的错误(函数未实现。使用Windows、GTK 2. x或Carbon支持重建库。如果你在Ubuntu或Debian上,安装libgtk2.0-dev和pkg-co

  • 我在mac os中使用pip安装opencv python。现在是cv2。imshow函数给出以下错误 OpenCV错误:未指定的错误(函数未实现。使用Windows、GTK 2. x或Carbon支持重建库。如果你在Ubuntu或Debian上,安装libgtk2.0-dev和pkg-config,然后在cvShowImage中重新运行cmake或配置脚本) 我如何解决这个问题?为什么pip不检

  • 本文向大家介绍OpenCV里的imshow()和Matplotlib.pyplot的imshow()的实现,包括了OpenCV里的imshow()和Matplotlib.pyplot的imshow()的实现的使用技巧和注意事项,需要的朋友参考一下 一、问题 在Python里使用OpenCV时,一般是通过cv2.imread读入图片,然后用plt.imshow显示图片,但最近学习OpenCV时这样做

  • 我试图使用官方openCV教程中的代码,在Ubuntu/Python 3.6中使用显示网络摄像头的视频: 对于: 功能未实现。使用Windows、GTK 2. x或Carbon支持重建库。如果你在Ubuntu或Debian上,安装libgtk2.0-dev和pkg-config,然后在cvShowImage函数中重新运行cmake或配置脚本 在搜索错误时,我偶然发现了这篇文章,作为类似问题的替代答