LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Real Time PlotXY

Hi, I'm trying to plot a real time line profile of a 640x512 image at 30 Hz (the line profile is only 640 pixels) and it seems that the plot just can't keep up.  Am I pushing the PlotXY function beyond is limits or am I just doing something stupid?  Sample code below:

 

startPoint = imaqMakePoint(1, rowToPlot -1);

entPoint = imaqMakePoint(640, rowToPlot-1);

spotImProfile = imaqLineProfile(camImage, startPoint, endPoint);

 

dataSize = spotImProfile->dataCount;

 

for(i = 0; i < dataSize; i++)

    spotProfileData[i] = (short)(*(spotImProfile->prfileData + i));

 

spotPlotHandle = PlotXY(panelHandle, PANEL, xProfileData, spotProfileData, 640, VAL_SHORT_INTEGER, VAL_SHORT_INTEGER, VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1, VAL_GREEN);

 

DeleteGraphPlot(panelHandle, PANEL_SPOTIMGRAPH, spotPlotHandle, VAL_DELAYED_DRAW);

 

 

I don't have internet access on my programming machine so if I missd a tpyo its safe to assume the actual code is correct.

 

Graph settings are:

Control mode: Hot

Data mode: Retain

Smooth update: Yes

 

 

Has anyone else tried Real Time PlotXY with ~640 data points and updating at 30Hz?  My program runs fine without the plot.  Intermittantly the plot updates at ~30 Hz but for the most part it is 1 Hz at best.  Thanks!

 

FeralPhysicist

 

 

 

 

 

0 Kudos
Message 1 of 8
(5,044 Views)

Slow graph updates may be a performance issue. 640 data points should not be pushing the limits of XYPlot function. Are you calling this function repeatedly? If yes, how often? Are you seeing any other performance delays besides plotting to the graph?

 

The LabWindows/CVI Help Manual page Programming with Graph Controls discusses ways to increase performance of a Graph Control. Disabling X-Autoscaling, enabling Anti-aliasing, and enabling smooth updating are three suggestions. There is also a section under performance in regards to optimizing memory usage. Improved memory usage can improve performance. Hope this helps!

 

Taylor B.
National Instruments
0 Kudos
Message 2 of 8
(5,008 Views)

My program runs through the above code at 30 Hz. 

 

I'll take a look at the link and reply if any of the hints in the link work.  Thanks!

0 Kudos
Message 3 of 8
(5,005 Views)

I have tried all the hints (a actually was already using all the hints) and the program will still only run at about 1 Hz while plotting.  It runs great at 30 Hz if the only change I make is commenting out PlotXY and DelteGraphPlot.  I should mention that I'm using imaqGrab and imgPlot before the plotting each iteration.  Thanks!

0 Kudos
Message 4 of 8
(4,968 Views)

If you comment out the PlotXY function, do you still see delays? I'm wondering if this is a problem with the IMAQ driver or LabWindows/CVI.

 

I'm not too familiar with the IMAQ driver functions. I do have the driver installed, but the Machine Vision forum may be a better place for IMAQ questions.

Taylor B.
National Instruments
0 Kudos
Message 5 of 8
(4,952 Views)

If I comment out the PlotXY i do not see the delays.  In fact I can do an image subtraction, image cast, image treshold, get a line profile (but not plot them) of all 4 images, and plot 4 images to a canvas all at 30 Hz with absolutely no problem.  But when I comment out all the imaq functions except the imaqGrab and get a line profile (for only one image not all 4) and try to plot the single profile to a graph my program runs at about 1 Hz.

0 Kudos
Message 6 of 8
(4,950 Views)

You could try using a StripChart instead of a Graph. The StripChart's scrolling mode could have an effect on the speed:

LabWindows/CVI: Programming with Strip Chart Controls

 

Perhaps a Producer/Consumer architecture would be best, where the data points (I'm assuming a 640x512 image means 327,680 data points) are stored in a queue and the plotting is handled in a separate thread. Here's some information about multithreading in LabWindows/CVI:

http://www.ni.com/white-paper/3663/en/

Taylor B.
National Instruments
0 Kudos
Message 7 of 8
(4,946 Views)

You can speed up plotting somewhat by disabling the graph's smooth update and the copy original data settings. You should probably also disable auto-scaling of both axes, if you haven't yet. Plotting at those speeds is a blur anyway, and constantly updating the axis range would only serve to add more noise.

 

Also, make sure that no other control is overlapping the graph in any way.

 

Even if you do all that, you still might not be able to achieve 30 Hz plotting. But it doesn't make much sense to me why you have to plot at such fast rates. I understand that you have to run through your loop fairly quickly, but is there a reason why you have to plot every single frame? Why not plot only every 5th iteration, or something like that? I doubt that the human eye can keep up with a new plot every 33 milliseconds anyway (unless the data of each iteration is only slightly different from that of the previous iteration).

 

Luis

 

0 Kudos
Message 8 of 8
(4,915 Views)