vscode远程调试opencv2图形显示

Posted on 2023-02-09  10 Views


假设我的本地Windows ip:192.168.1.235;Linux ip:192.168.1.213.

Windows安装x-ming服务端

除了安装路径其余保持默认
安装完成后启动XLaunch.exe,保持默认一直下一步。
进入安装路径修改X0.hosts如下:

localhost
192.168.1.213

在Windows端VScode

应该编辑远程中的SSH配置文件\.ssh\config如下:

Host homeServer
    HostName 192.168.1.213 #远程linux
    ForwardX11 yes
    ForwardX11Trusted yes
    ForwardAgent yes
    Port 22
    User root

编辑Linux服务器

vi ~/.bashrc #加入下面的语句
export DISPLAY="192.168.1.235:0.0"
source ~/.bashrc

测试

ssh终端测试代码

echo $DISPLAY

xclock

Windows端python测试代码

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
ax = plt.axes(projection='3d')
ax.scatter(np.random.rand(10),np.random.rand(10),np.random.rand(10))
plt.show()

小问题

1.This application failed to start because no Qt platform plugin could be initialized
解决

pip install PyQt6==6.3.1
pip install opencv-python==4.6.0.66

本当の声を響かせてよ