From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D picture control performance

The 2D picture control performance does not appear to follow standard LabView conventions. What is the most efficient way to continuously add elements to a 2D picture control?
Attached is a sample vi, which has 3 scenarios, each with very different performance..... what is happening?

Philippe_RSA_0-1603266776544.png

 

0 Kudos
Message 1 of 23
(1,874 Views)

There's only one scenario, as far as I can tell.

 

You're continuously adding items to the picture. Drawing them will take longer and longer.

 

The picture control data is basically a string, and that string is used to render. The string gets longer and longer, and the rendering will take longer and longer.

 

That follows every LabVIEW convention I know of, and also all general programming conventions I know of...

 

If you don't want the rendering time to increase, you need to figure out a way to not increase the data. For instance, render, convert the picture to a pixmap. Next cycle, draw the pixmap, render over it. Etc. This takes longer for a few items, but the rendering will be stable, since the data won't grow.

0 Kudos
Message 2 of 23
(1,865 Views)

Hi Philippe,

 

you forgot to attach subVIs - and used too many local variables:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 23
(1,863 Views)

Another 'cheap' way to do this is by untagging the 'Erase first' option, and ditching the local in. This will render the new picture, but as it won't clear the previous lines, they will overlap. This might not work when hiding\opening the front panel, as that might clear the picture anyway. I don't really know.

 

This is in a way the same solution. Both solutions buffer the rendered image, not the raw data. The first method gives you full control over the rendered buffer, but if you can get away with letting LabVIEW do it, I don't see any objections. 

0 Kudos
Message 4 of 23
(1,861 Views)

Something in the lines of this.

 

Conceptually. This would be nice to put in a class.

 

I draw poly lines, since you didn't post the sub VI. But this would work no matter what you draw.

 

Draw to image endlessly.PNG

 

 

 

This won't work if you plan on using the zoom of the picture control. It will zoom, but you'll be zooming in on pixels, not vectors.

0 Kudos
Message 5 of 23
(1,856 Views)

The sub-vi is a standard picture vi, so LabView refuses to add it automatically to my llb.
Did a manual addition as attached.... not so cool.

Using a local variable vs using a shift register does not appear to improve performance.

0 Kudos
Message 6 of 23
(1,824 Views)

The "clear" button in my code appears to do the same, but under the hood....
Is it possible "clear" is making a bitmap?
By doing this infrequently (once a second instead of every loop) appears to give a performance boost also.

0 Kudos
Message 7 of 23
(1,819 Views)

@Philippe_RSA wrote:

Using a local variable vs using a shift register does not appear to improve performance.


Of course not. You still get the infinite data growth.

 

But you avoid a race condition. You're setting a local, while reading and writing a local. This means the first write can be undone by the read\write in the other loop.

 

0 Kudos
Message 8 of 23
(1,811 Views)

@Philippe_RSA wrote:

The "clear" button in my code appears to do the same, but under the hood....
Is it possible "clear" is making a bitmap?
By doing this infrequently (once a second instead of every loop) appears to give a performance boost also.


The clear will clear the data, so it will be fast for a while. But you've also lost all data.

 

I was assuming you want all previous data to appear, because that's what you programmed. And that's what the computer is doing.

 

If you don't want previous data to be drawn, why would you use locals or shift registers to get previous data? Why not simply draw the current lines and put them in the picture control?

0 Kudos
Message 9 of 23
(1,808 Views)

Hi Philippe,

 


@Philippe_RSA wrote:

The "clear" button in my code appears to do the same, but under the hood....
Is it possible "clear" is making a bitmap?


The clear button calls a case where you write an (apparently) empty image constant into a local of your 2DPictureIndicator…

You know there is an "Empty image" constant in the picture functions palette?

 

Your indicator is set to "antialiasing" the image: this may also have some influence on performance!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 23
(1,807 Views)