Skip to content

Dinamic change of background Image on HMI WebServer

Hello colleagues,

I made a small project of face recognition using Python on our PLCnext.

My script, enabled using C++ program that call the Shell, check on an input picture the presence of faces and make some elaboration on it.

Using REST API I can share variables between Python script and PLC program.

I'm using as input picture of my script the image used as background for WebHMI (/opt/plcnext/projects/PCWE/Services/Ehmi/ehmi/) so I can directly show on the webserver the result of my script...in this case using Translation of rectangle object around all the face found.

I'd like to can dinamically change this background picture, but anytime I try to do it PLC (AXC F3152) show error probably related to the ownership of this file; it looks like only plcnextfirmware can change it during download of a new project with a new background image.

Is there a way to can change it dinamically without having problem?

Comments

  • Hi Davide,

    Sorry for the long delay. We finally have an answer:

    =============================================

    We are assuming that you mean ‘Image source’ field of an HMI page.

    If that is the case, you should be able to change it dynamically via a script without having to re-download the whole project.

    1. Make sure root user is enabled
    2. Download project to controller that has an HMI page with an image background (image source)
    3. Add a line to the script to copy the new image to ehmi folder:
    4. Use WinSCP or pscp to copy the new picture
    5. pcsp C:/Users/testuser/Pictures/newpicture.jpg root@192.168.248.79:/opt/plcnext/projects/PCWE/Services/Ehmi/ehmi/
    6. If the name of the newly copied image (newpicture.jpg) is different than the name of the original image used as the page background, you will also have to edit the corresponding page .json to reference the new image name in order for it to show up as the page’s background.
    7. Refresh web page
    8. New image appears as background

     Please let us know how this works

     

  • Hello Martin.
    I read your answer and it was really very usefull because I could make a test so that I can use my IP camera to display its image in the eHMI page.
    But it was more simple than waht you described.
    For example, I just had to use the following command in the LinuxShell FB :

    curl -u admin:password http://192.168.10.33/tmpfs/auto.jpg --output /opt/plcnext/projects/PCWE/Services/Ehmi/ehmi/capture.png

    and of course, i use the capture.png file in the eHMI page. (192.168.10.33 is my IPCamera).

    But even if the file is updated in the AXC F 2152 directory, it is necessary to change to an other eHMI page so that the image is really update on the web browser.
    Is there any simple solution so that the eHMI page refreshes by itself its content? either via an internal command in the AXC F 2152, or something else.
    Thanks
  • Hi Michel,

    hey nicely done and thanks for the feedback.

    A auto refresh is for now unfurtonately not possible, but I will add this to the backlog.

    BR,
    Frank
Sign In or Register to comment.