-1

I got a task and have absolutely no clue on how to do it at the moment.

I watched a couple of tutorials on REST API, but none of them are applicable for my application. I don't intend to use a localhost, but if it's required then sure.

What is this task?

So there are two parts.

  1. PC (client)
  2. Raspberry Pi 4 (server)

Here’s the sequence:

The PC is the client and sends a request to the server, which is the Raspberry Pi 4, to display an image, let's say image1.jpg. The rpi4 is connected to an external monitor via HDMI.

The server/Raspberry Pi 4 receives the request and opens up image1.jpg which will then be displayed on the screen in full screen to be shown on the screen through HDMI.

Perhaps there is a better solution than to use RESTful API to solve this. If there is please give me recommendations.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
sajid
  • 1

1 Answers1

0

There are 3 parts to this:

  • capturing an image
  • displaying an image
  • telling RasPi to do both the above

In order to capture an image you can use raspistill or libcamera utils in newer versions of Raspberry Pi OS.

If you aren't capturing pictures with the camera, you must presumably be supplying them from the PC. So you can either use scp to copy one across from the PC:

scp SOMEIMAGE.JPG raspberrypi:image.jpg

Or you can use a Windows SHARE to share a directory between the PC and the RasPi. In Windows you'd use the "Share Folder" option and on the RasPi you can use smbclient or cifs-utils to mount it. Example here.


In order to display an image, either use raspistill built-in options, or use fbi or fim or feh depending on how things are connected and whether you are running an X11 server or not.


In order to tell RasPi to do the above, just use ssh (or Putty on Windows) like this:

ssh user@raspberrypi 'raspistill ... -o /tmp/image.jpg; fim /tmp/image.jpg'

Note that RasPi implements avahi, so if your Raspberry Pi's hostname is set to simon, you should be able to talk to it under the name simon.local on your network, so the command above would become:

ssh user@simon.local '...'

where user is your username that you login to your RasPi with.

You can set your RasPi hostname with:

sudo raspi-config
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432