1、python如何调用opencv中的saliency模块
如果你已经安装了opencv-python的库,但是调用cv2.saliency方法时出现了如下的报错:
module ‘cv2.saliency’ has no attribute ‘StaticSaliencySpectralResidual_create’
这时你只需要卸载opencv-python库,安装opencv-contrib-python库即可。
2、vscode中连接Linux服务器返回图形化界面报错
如果你的vscode项目代码中含有如下语句块:
# show the images
cv2.imshow("Image", image)
cv2.imshow("Output", saliencyMap)
cv2.imshow("Thresh", threshMap)
cv2.waitKey(0)
并出现如下的报错:
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “/home/###/anaconda3/envs/###/pytorch/lib/python3.10/site-packages/cv2/qt/plugins” even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
已放弃 (核心已转储)
这时你可以在你的本地安装Free版本的MobaXterm,同vscode一样,通过ssh连接上服务器,输入ip和服务器主机的用户名(log as),然后再在vscode的命令行输入:
export DISPLAY=localhost:10.0
这样就会正常生成图片,不会报错了。