python-3.x - Qt:opencv python中的会话管理错误
问题描述
我正在尝试运行以下脚本
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 个不需要的帧以及我的输出。
你们能帮助我如何摆脱这个错误和那些不需要的帧吗?
解决方案
伙计们,在找到许多博客和资源后,我终于得到了这个,它对我有用。
不要使用 pip 进行 opencv 安装,而是使用以下命令
sudo apt install libopencv-dev python3-opencv
https://linuxize.com/post/how-to-install-opencv-on-ubuntu-20-04/
注意 - 我认为这个问题与 Ubuntu 20.04 有关
推荐阅读
- angular - 如何验证在接口上设置属性
- android - 升级到 WorkManager 2.3.4 后 ObsoleteLintCustomCheck lint 警告
- android - 如何让我的 Firebase 数据库只读取给定引用的直接子级
- sql-server - 适用于 Oracle Instant Client 的 Microsoft ODBC 驱动程序
- python-3.x - 在运行贝叶斯层次模型时使用 pymc3 和 theano 编译错误
- postgresql - 在 postgres 中触发以使用列表锁定表
- windows - 如何批量打印黑色字符ascii
- graphql - 如何使用 Apollo/GraphQL 使派生状态保持最新?
- r - 有条件计数
- memory - PowerPoint VSTO 分配的内存越来越多