11-02-2022 02:55 AM
First of all, hello everyone.
I am currently dealing with an issue that I understand the reason for but do not know exactly what to do. I think I just need an opinion on this issue.
With NI-Vision I read the image from a camera and do some overlays on it and then send that video over TCP to a different computer (client).
I'm adding some more overlays to the video received on the client.
But the overlays I added to the video on the server side are not visible on the client side, only the overlays I added on the client are visible.
If the video name I use on the client side and the video name I use on the server side are the same, the video starts to flicker.But it is showing added overlays on both sides.
If the IMAQ CREATE names on the client and server are used differently, the video does not flicker, but the added overlays on the client are not visible, only the added overlays on the server are visible.
Note: I don't want to use Merge overlay on client side. Because I'm using image proccesing.
Does anyone know a solution to this problem?
Solved! Go to Solution.
11-02-2022 03:43 AM - edited 11-02-2022 03:51 AM
Your description doesn't say so but it is pretty clear that your server and client do run in the same computer and LabVIEW instance. IMAQ Vision images are identified by their name. If you use the same name in the IMAQ Create function, the second and subsequent calls will not create a new image but create only an alias to the original image with that name. Access from two or more locations to that image need to be synchronized, so that is the flicker you are seeing. Two functions reading and writing to the same memory location of the image will randomly interfere with each other, causing that flicker.
Overlay information is stored as a special attribute list in an IMAQ Vision image. It is not part of the actual bitmap memory. If you use the standard Flatten to String function, only the bitmap data is flattened but if you use the special IMAQ Flatten Image to String function, to turn your IMAQ Vision image into a byte stream, it will add the overlay information into the data stream. The Unflatten from String can then convert it back into an IMAQ Vision image with the overlay information preserved.
If you have the client and server run on the same computer, you should also observe the Flatten with Process-Unique Name Boolean. If this is false (default), the resulting image after unflattening will have the same name and cause the flickering you already observed in your current implementation. If client and server run on different computers this is not important as they can not share memory and the Unflatten function will have to create the image anyways.
11-02-2022 05:37 AM
Thanks for your answer rolfk
@rolfk wrote:
Your description doesn't say so but it is pretty clear that your server and client do run in the same computer and LabVIEW instance. IMAQ Vision images are identified by their name. If you use the same name in the IMAQ Create function, the second and subsequent calls will not create a new image but create only an alias to the original image with that name. Access from two or more locations to that image need to be synchronized, so that is the flicker you are seeing. Two functions reading and writing to the same memory location of the image will randomly interfere with each other, causing that flicker.
From what you've said here, interestingly, it's acting like it's working on the same computer.
But Both are on different computers.
PC-1 server.vi
Here I am reading and opening the video over TCP
PC-2 client.vi
Here I am capture the video from the camera.
I think I've already done something exactly like you said, so where exactly does the problem start?
11-02-2022 08:45 AM - edited 11-02-2022 08:55 AM
I think I found part of the source of the problem. It was flickering due to the resizing I added on the server side and causing the overlay to disappear.
By the way, I don't know why the overlays don't appear when I resize the image.
11-02-2022 09:19 AM
@constructionworker wrote:
By the way, I don't know why the overlays don't appear
If you would like to flatten image together with overlay you should use Image and Vision Info here:
Then it should work
11-02-2022 01:39 PM
@Andrey_Dmitriev wrote:
@constructionworker wrote:
By the way, I don't know why the overlays don't appear
If you would like to flatten image together with overlay you should use Image and Vision Info here:
Then it should work
Thanks for your suggestion.
I tested it but it didn't fix the problem
Once set this way if I try to resize the video with ''IMAQ resample'' or ''IMAQ Set size'' the generated overlay in the client still does not appear.
I add another overlay on the server side to the received video as below. Everything works fine when I create the following. It shows all the created overlays, even the video doesn't flicker.
PC-1 server.vi
PC-1 server.vi
But when I add something like below, the overlay added in the client suddenly disappears.
Only now there is a problem with resizing, if I solve it my problem will be completely solved.
Why does the old overlay disappear when I add a new overlay after copying and resizing the image?
11-02-2022 03:21 PM
@constructionworker wrote:Only now there is a problem with resizing, if I solve it my problem will be completely solved.
Why does the old overlay disappear when I add a new overlay after copying and resizing the image?
Probably because resizing is considered an operation that would potentially make old overlay information invalid (for instance, what to do with overlay data that is outside of the new image dimensions?). So the Resize operation and likely several others simply invalidate overlay and calibration data.
It definitely makes sense to me and I probably would have implemented it similarly. Of course they could try and start parsing all that data to see if it might be outside of the new constraints and only reset it then, but that gets nasty very quickly. Simply defining that this operation potentially makes this extra information invalid and therefore needs to be invalidated is much simpler and always works reliably.
11-02-2022 03:42 PM
@rolfk wrote:
@constructionworker wrote:Only now there is a problem with resizing, if I solve it my problem will be completely solved.
Why does the old overlay disappear when I add a new overlay after copying and resizing the image?Probably because resizing is considered an operation that would potentially make old overlay information invalid (for instance, what to do with overlay data that is outside of the new image dimensions?). So the Resize operation and likely several others simply invalidate overlay and calibration data.
It definitely makes sense to me and I probably would have implemented it similarly. Of course they could try and start parsing all that data to see if it might be outside of the new constraints and only reset it then, but that gets nasty very quickly. Simply defining that this operation potentially makes this extra information invalid and therefore needs to be invalidated is much simpler and always works reliably.
Accordingly, it is quite normal for the overlays to disappear. so is there a way to resize the image?
11-03-2022 06:37 AM
@constructionworker wrote:
Accordingly, it is quite normal for the overlays to disappear. so is there a way to resize the image?
If you would like to keep overlay on resize (which is by default removed after IMAQ Resample), then you should use IMAQ Set Overlay Preperties with Scale and Transform, something like that:
11-03-2022 02:38 PM
@Andrey_Dmitriev wrote:
@constructionworker wrote:
Accordingly, it is quite normal for the overlays to disappear. so is there a way to resize the image?
If you would like to keep overlay on resize (which is by default removed after IMAQ Resample), then you should use IMAQ Set Overlay Preperties with Scale and Transform, something like that:
Thank you for your answer, it partially works, the overlays remain visible, but I get an image that changes by itself (like non-fast flickering) between the portion scaled with the ''resample'' and the default video size.