一、mobaXterm
参考:https://blog.csdn.net/weixin_50973728/article/details/129882910
- 打开X11的主要参数
sudo vi /etc/ssh/sshd_config
修改这两个值,并且取消这两个参数的注释
python
AllowTcpForwarding yes
X11Forwarding yes
- 重启sshd服务
python
service sshd restart
- 关闭Windows防火墙,关闭mobaXterm
- 重启mobaXterm,可以看到X11-forwarding已经正常打开
- 在Ubuntu系统中修改.bashrc
sudo vi ~/.bashrc
在文件最下面增加一行,用于IP映射。将WindowsIP改为自己的ip地址,保存后运行source ~/.bashrc
python
export DISPLAY="WindowsIP:0.0"
二、VScode使用opencv
- cv2.imshow()时报错
cv2.error: OpenCV(4.10.0) /io/opencv/modules/highgui/src/window.cpp:1301: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'
- 更换无需GUI支持的opencv版本
python
pip uninstall opencv-python
pip install opencv-python-headless # 无需GUI支持的版本
pip install opencv-python # 带GUI支持的版本