我正在尝试运行以下脚本
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 个不需要的帧以及我的输出。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/