Skip to content
Advertisement

How to get the value of a python script I run through ssh

I am using 2 raspberry pi and each of them has a camera connected. I am trying to run, from the first pi, a script to get the video feed of the second one.
And for that, I would need the value my function returns through ssh.

With a simple example :
slaveScript.py

JavaScript

masterScript.py

JavaScript

I would like, for this example to get “hello there”. How can I get it? Is there a pexpect method I can use?

In context with the cameras :
SlaveScript.py

JavaScript

MasterScript.py

JavaScript

I know that it works if I put the lines from while True to cv2.imshow in the slave script. I have a window opening and a video feed of around 1 image every 3 seconds (I don’t care about performance).
However, the video feed will have to be implemented inside a kivy GUI, so I need to get the frame in my master script so that I can put it in a texture in kivy.

Is there any way to do it?

Advertisement

Answer

I think you are on the wrong track with pexpect. You should be using password-less login by copying your public RSA key to the slave device – then you can get rid of all the awkwardness of pexpect.

Also, I would consider using Redis. It is very fast, and lightweight and it serves integers, strings, lists, sets, hashes from memory (RAM) across a network.

Simply stuff the frames of video in Redis on the slave, either as JPEGs, or PNGs or Numpy arrays and call it latestFrame. That looks like:

JavaScript

On the other machine, just grab latestFrame from Redis and display it. That looks like:

JavaScript

Example here.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement