LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Draw life digitizer data into Picture control

Hi,

 

We built a digitizer with 0.01mm XY resolution, pressure sensitive head (0..1500g) and data refresh rate up to 30K/s. The arm of the digitizer is lightweight and the idea is to use it for generating very precise handwriting patterns which in turn could be reproduced on some robot for testing touchscreens. The hardware works fine and we built a LabView application to capture, display and log XY, time & force data. Everything works fine except when it comes to display the life data as lines with thickness proportional to the pressure. We use picture control and DrawLine.vi and we change the line width according to the pressure.

  

Now about the strange effects - with 50Samples/s  initially the drawing of the lines is going smooth  but after some moment the application begins to slow down and can't draw in real time the lines.  If we use faster sampling rate (1K/s) the effect of slowing down appears immediately. We use a separate queue to send data for drawing and it's visible how it begins to fill (some elements were not polled). Somewhere in the forums (unfortuntaley I can't find the exact link) I read a post about Picture control and Altenbach said that it's actually not drawing onto canvas but gathering commands what to be drawn. In order to prove if this is the case I made simple experiment VI (see attached TestPictureDrawPoint). 

 

Before you run the VI scroll the front panel picture up/down or left/right to witness that everything is OK (later you'll find out strnage effects with this because of image redrawing). Smooth updates are Off, Synchronous Dipslay is On.

 

When you run it for first time you'll notice that the drawinglines  process is quite fast (by looking at CurrentIndex indicator)  but when it comes the picture changes to be applied to the Picture it slows down. Something interesting, after you ran the application and after it stopped the VI control begins to behave strange - you'll find that if you scroll the Picture on the pane the computer freezes until it refreshes again the image (couple of seconds). You may think at this point that your computer crashed or hanged, actually it's just updating the picture.

 

I have experince in C# and Embarcadero where drawing on TImage is simple &  fast. Once the new data is placed into the Canvas the image is resolved, seems that LabView is accumlating the changes into the picture and as more data you add than slower it works. For simple images it may bring some advantage but for complex drawings it's killing the performance.

 

My question is - how I can draw quickly lines with different width on some control in LabView. The idea is to get life data from digitizer with pressure sensor and display it on screen as drawing pad in real time. How I can modify the Bitmap Canvas directly?

 

Thank you

Luben

 

 

0 Kudos
Message 1 of 4
(3,367 Views)

I solved the problem - now I can draw my digitizer data with dynamic lines on screen just like I did this in C#. In case anybody else came to the same problem here is the solution:

 

-  Use .NET PictureBox which can do a lot of things beyond LabView 2D Picture.

 

- When you draw a point, line or any other shape you draw it straigth to the canvas so adding more drawings is not slowing down the process like this is happening with 2D Picture.

 

- It has alpfa transparency (you can control precisely the percent of transparency) for lines and shapes so you can achieve amazing graphics

 

See attached the VI which shows the basic operations.

Download All
Message 2 of 4
(3,285 Views)

I forgot to add the link from where I got the idea:

 

https://webcache.googleusercontent.com/search?q=cache:A4RlPAnm10cJ:https://lavag.org/topic/18252-cre...

 

You can see there how to save the PictureBox image to file

0 Kudos
Message 3 of 4
(3,276 Views)

Using the example I posted (PictureBox/CreateGraphics + [FillEllipse or DrawLine])  has two major drawbacks:

- you can't save the image to file (at least I was not able to find any way to do this)

- once the window is hidden and then shown again the image disappears

 

So, seems the right approach is to draw on Bitmap which is attached to the Picturebox and has the same size (as shown in the links in previous post).

 

One more trick when drawing on Bitmap -  if trying to draw on Bitmap from time to time an error 1172 can occur, especially if changiung the focus of the panel and the VI is not topmost:

 

Error 1172 occurred at Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
Inner Exception: System.InvalidOperationException: Object is currently in use elsewhere.

 

The solution I found which works is to check always before drawing is the VI top most - see the latest version.

0 Kudos
Message 4 of 4
(3,195 Views)