Hi All,
I have an application where a bunch of images are analyzed on a server then the results plus the annotated image are transmitted via MQTT. I'm having trouble figuring out how to render the image from the byte stream in the (either MQTT msg or OPC Tag). I can do it in python using the following code:
But i'm not sure how to get this to render in a perspective view.
The data looks like this:
Thanks in advance
You can you publish the image base64 encoded instead, you could use a data URI to display it. See Perspective: Base64 Image into Table - #7 by SR_Solar or some other related topics by searching.
Otherwise you'll probably have to do some scripting to handle the incoming data. The "encoding" in your screenshot looks more like the string representation of some binary data rather than binary data.
Also, if these images are large or there's a lot of them, you really shouldn't store the data in tags at all. It would be better to stick them in a database or host them on a simple HTTP server on the server doing the processing.
So this is the part of the function that encodes the image:
It is definitely not a string at that point, MQTTExplorer struggles to display it:
But by the time it ends up in the OPC server (and in the ignition OPCTag) it may be a string. I was trying to figure out how to convert it into something I can use in ignition (I found a bunch of topics on getting Blobs out of a database but nothing in them seemed to work):
Okay, so update.
It turns out it was the string representation - there was an error in the MQTT to OPC application which is now fixed, so the actual tag data in ignition is now a decoded bytestring:
However - i'm still not sure how to deal with it.
@Kevin.Herron - I did the simple webserver approach and put the image path into the OPC tag and that worked wonderfully. But my worry is that if the client browser has to load the image then i'll need to talk to my firewall friends to get that route unblocked and that is something i'd rather not do if I can avoid it as the network setup has become . . . . complex . . . due to unnecessary and idiotic corporate restrictions. I will look at the database option too
Try the base64 approach I linked to.
Ok - success.
I missed the bit in your first reply that meant publish the image with base64 encoding first so did that and got it to work,
Updated function:
Tag value:
Property Binding:
Tada!
Thanks @Kevin.Herron
1 Like