Efficiently draw a 3d Plot from realtime data


#1

Hi,

I’m currently implementing an RF direction of arrival estimation algorithm, which is fed by a stream of realtime RF samples that get accumulated in a special way until there is enough data to compute a so called MUSIC spectrum (MUSIC is just the name of the algorithm and has nothing to do with music :smile:) based on some linear algebra, performed with the help of the Eigen linear algebra C++ library.
The resulting spectrum is output as a 90x360 Eigen::Matrix and should be displayed like this MATLAB-Plot:

MUSIC_Spec

The matrix will be updated between one to four times per second, depending of the number of samples to accumulate, which should be a user settable value. As I’m no expert in GUI and even less in 3D graphics, I’d like to get some input on how to generate a plot like this in general and how to do it efficiently with respect to the given update rates and the fact, that the algorithm and realtime computation of the samples coming in at 200 kHz shouldn’t be interrupted by to heavy graphic-rendering.

Will openGL help me here?


How would you do this kind of 3d scatter plot with mouse picking in JUCE?
#2

Hi Jucers,

After not getting any response to this thread I focused on other tasks, but as our application develops successfully I‘m now comming back to this topic.

The context of this application is a scientific student project where me and my colleague both are students of elecrical engineering with decent knowledge in math and DSP but not in things like GUI - we‘re just doing our best trying to learn what‘s needed to develop our application. That said, learning how to program a juce-compatible open GL 3D Plot Component would surely be interesting but also very very hard and time consuming for us as we start with zero knowledge for a little side-task in that project.

So I looked for plot libs out there but most things I found, like GNUPlot are outputting the plots to files or separate windows. As the plot should be shown into a Juce Component this doesn‘t really seem like what I‘m looking for. I thought of using GNUPlot to plot the content to an uncompressed image file and load that file in my application afterwards, but I guess this won’t be verry efficient - even at a low update rate like 2 Hz.

So I‘d love to get some input on how to get this working with a reasonable amount of work for a guy with my knowledge while getting a reasonable performance. Maybe there are good libraries for thatc task I haven’t come across until now.
And even if it‘s beyond my current knowledge I‘d also like to hear suggestions on how to do this if performance was the highest goal.


#3

I guess the lack of response is because not many people here do much graph plotting stuff!

I’ve never done anything like that myself, but if I was tackling it, I guess I’d just write it using plain old 2D rendering to start with, and see how well it performs. openGL would be the fastest possible way to render it, but writing a shader for it could be a bit fiddly, so if you only need a few FPS then it might be easiest not to bother.


#4

Yes I think so too. I also don’t have any music/dsp application or plugin in mind that would need this kind of GUI element :smiley:

To be honest, even doing this with plain old 2D rendering seems quite challenging to me. It should be quite straightforward to calculate a (float) pixel position and a resulting colour for each given datapoint from the source matrix, however I have no idea on how to interpolate everything between those given pixels with a given colour. Just take those sharp peaks in the picture from the original post, let’s say this is the value [35][100] from the source matrix and then take the value [35][99] which has nearly 5dB lower value. The MATLAB plot generates a nice fade from dark red to orange between those data points over several pixels. I wouldn’t have an idea on how to do this properly and efficiently over the whole area.


#5

I actually do, I always wanted to do a nice realtime waterfall display like this… But I never implemented it (yet)


#6

If it should animate in real time, I’d do it with OpenGL.


#7

Oh yes, that’s a use-case indeed. Too sad you haven’t done it until now :wink: Nevertheless, did you already have any specific thoughts on how to get it working?

If I knew how to do it, I’d do it with OpenGL too :smiley:
I’m just lacking some experience in this field and sadly with that also the time to learn all skills needed for this just to complete a side-task of my project… Would be real fun to learn OpenGL to get this working I think!


#8

If you havent already found it, there is a section on OpenGL wikibook about rendering graphs/plots/surfaces.

The sceintific arc


#9

Thank you for that link - seems like a really good ressource to learn everything needed to do this right!