I have a opencv program as a server to send image stream from camera. Now I have to make a c# program to open the opencv program remotely.
everything is good by using ssh via cmd. like:
ssh myname@ip
export DISPLAY=":0"
~/home/MyName/MyOpencvProgram
and I can see a imshow windows pop-up in my server computer.
Now I want to make this in c# WPF program so I use SSH.NET package:
public void TrySomeSSh()
{
ConnectionInfo conInfo = new ConnectionInfo(ip, _port, _username, new AuthenticationMethod[]{
new PasswordAuthenticationMethod(_username,_password)});
SshClient sshClient = new SshClient(conInfo);
sshClient.Connect();
if (sshClient.IsConnected)
{
SshCommand output1;
string line1 = "export DISPLAY=\":0\"";
output1 = sshClient.RunCommand(line1);
Console.WriteLine(output1.Execute());
Console.WriteLine(line1);
string line = "/home/MyName/MyOpencvProgram";
Console.WriteLine(line);
var output2 = sshClient.RunCommand(line);
Console.WriteLine(output2.Execute());
}
else
{
Console.WriteLine("not connected");
}
sshClient.Disconnect();
sshClient.Dispose();
}
from the output.Execute() I can see the program is running. However it would always stop when meet some GUI function like namedwindow() , imshow() , or waitKey() .All of these work fine when use ssh via cmd, and I think the export DISPLAY=":0" command is enough to solve this. But It still stopped.
What should I do now?