python-3.x - Qt : Session management error in opencv python

标签 python-3.x opencv ubuntu

我正在尝试运行以下脚本

import numpy as np
import cv2

#Capture Video from Camera
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()
当我尝试在 Ubuntu 终端中运行它时,它给了我这个 Qt: Session management error和 2 个不需要的帧以及我的输出。
enter image description here

can you guys help me how can i get rid of this error and those unwanted frames?

最佳答案

伙计们,在找到许多博客和资源后,我终于得到了这个,它对我有用。
不要使用 pip 进行 opencv 安装,而是使用以下命令

sudo apt install libopencv-dev python3-opencv
https://linuxize.com/post/how-to-install-opencv-on-ubuntu-20-04/
注意 - 我认为这个问题与 Ubuntu 20.04 有关

关于python-3.x - Qt : Session management error in opencv python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63147397/

相关文章:

为 python 3.0 编译 CMPI 代码

c++ - Opencv特征描述给定坐标

python - 在 Amazon ec2 ubuntu 实例上使用 enthought Python 安装 lxml

c++ - 测量cpp中的函数内存使用情况

linux - Ubuntu本地IP地址无法解析

python - Python 中 Unicode 字符的显示问题(组合字符、假名字符等)

python - 如何从 Python 3 中的整数列表创建字节对象

python - 将混合数据转换为字符串 numpy

opencv - 为什么我不能使用opencv仿射变换来翻转图像?

c++ - 哪种图像处理技术?