Hello everyone.
I’m doing some smart camera development with mappVision, and I’d like to display the camera image in real time in my mappView interface, any recommendations on how to do this? If possible, it would be nice to provide a simple routine for reference. Thanks a lot!
Hi Wenjie!
From my point of view there are two solutions to this:
- First one, no official library, but easiest to implement
- Second one, official approach
First solution
From B&R Spain @javier.novella developed a library with two function blocks: ViEsGetCameraImage (uploads the camera image to a buffer) and ViEsStoreImage (saves the camera image in a File Device). Those function blocks are really easy to implement. The library has documentation included, to open press F1 above the library in AS, inside the help you will find also examples. Afterwards, once you have the image saved you can show it in mappView visualization. I attach it here:
ViEsTools_v1.0.0.zip (160.4 KB)
Second solution
From mappVision 5.20 function block ViBaseGetImage was released.
With function block ViBaseGetImage, the last acquired image can be retrieved from the camera and stored in a data buffer in DRAM memory on the PLC. This image can then be displayed in a mapp View HMI application or persisted using library FileIO.
There is an entire use case of this:
B&R Online Help - Use cases: Backing up, displaying or providing the camera image
Whatever solution you choose, please share it with us. Good luck
Another possibility (with a big caveat) is to use the Image widget in mapp View. While this is a pretty straight-forward way to show the image on the HMI, the caveat is that the HMI client will have to be configured with the correct routing to be able to reach the camera directly.
To get this to work, start by binding the attribute “image” to the url of the camera:
http://IP_ADDRESS_OF_CAMERA:8080/jpg?q=QQ&t=TS
- IP Address of the Camera: You’ve already specified a subnet for Ethernet traffic in your PLK network, e.g. 192.168.200.240 as shown below. In this example, for a camera that is configured for node number 1 on PLK, its IP address will be 192.168.200.1
-
QQ: Quality/compression factor for the JPG (try 50% to reduce the size of the image)
-
TS: this “timestamp” should be incremented once a new image is available to refresh the image on screen
On Windows, you can set the route by executing the following command on the CMD window:
route add 192.168.200.0 mask 255.255.255.0 PLC_IP_ADDRESS
(note that the subnet mask above is the same as configured for the PLK network)
In the near future, we’ll have a dedicated widget to make this whole process much easier.
@ghizonid you should create article to share info and ideas about it
One additional hint: You have written “real time”. Please be aware that you can not create a “video stream”. You can only load and show image after image.
We made in the past some tests similar to the mentioned method from Daniel. With a jpg-compression of about 30% and a 1.3MP camera you should get about 5 fps (images per second). Therefore we switched PLK to 800µs and MTU (Powerlink) to 1500. I think more image per second is not possible.
Thank you very much for your reply, I was originally using the second method you suggested to receive the image data, now that I’ve tried it with the first method, I think it’s a very simple and useful feature block.
However, the problem I’m currently experiencing is mainly with the mappView display, where there is a flickering image problem when displaying with the paper widget in the mappView, I’m not sure if you’ve encountered a similar problem.
You can see the attached picture, I set the timer to refresh the picture once every 1 second.
Thank you very much for your reply!
This is what I tried at first, I was using mappVision 5.23 in my project and tried to use the function block ViBaseAxisBasedAcquisition() to trigger the shot at a fixed position.
At first I put the ViBaseAxisBasedAcquisition() function block into a 0.4ms loop, and I would encounter the problem of the picture not refreshing out, then I started to put this function block into a 40ms loop, which was able to refresh out the picture. However, the problem of the image not refreshing still occurs intermittently. If I don’t use this function block to trigger a fixed position shot the display is fine.
I am using image weiget in mappView. the image is in jpg and compression is 50%.
Hello @cuiw I was wondering if you could help me to implement the function blocks from the Library ViEsTools. I have problems with the buffer, honestly i dont know how that input works or what should I write in the parameter pBufferName. Even following the examples from the Library Help I am still getting service mode when I restart the PLC.
Hi, are you trying to save the image as a file or staging it in RAM. If saving as a file, just refer to the contents of the help. If you want to save to RAM, I think you can check the parameters related to svgtag. As for pBufferName, I don’t know much about this parameter, you can ask the author of the library.
Hola Salvador @c571659
has intentado revisar el Logger de tu PLC, para ver que errores presenta?
No he revisado aún la librería de @javier.novella, pero he usado ViBaseGetImage de esta forma:
-
Para el pBufferName, hice uso de la Libreria AsMem (GUID: 7ccea62d-9c12-49ed-96f0-2aec124db8f6) para crear la partición con AsMemPartCreate:
-
Con AsMemPartAlloc, es para decirle donde voy almacenar la imagen de forma temporal :
-
Estos sean los parametros para ViBaseGetImage
Después puedes liberar o destruir la partición.
Puedes encontrar un ejemplo de como hacer uso de la libreria, y agregarlo dentro de tu proyecto, en LibrarySamples/ BRAutomation / AS/ Samples / Library / AsMem
Pero si solo quieres mostrar la imagen en tu Visu, después de activar el trigger, la forma más sencilla es como lo ha dicho @ghizonid
Espero que haya podido aclara tu duda. Saludos!
Vanessa
Hello
You can also use the same libraries that are used in the vision demo project, it also includes a widget that simplifies showing the image on HMI and also support drawing SVG on top of the image.
It also a vision MappView function block that take care of download the image and forward to HMI either over OPC UA or websocket internally. It should be quite straight forward.