01-18-2013 02:21 PM - edited 01-18-2013 02:22 PM
Hello,
I am using XY Graph to display GPS data, XY graph also displays a map that is being preprocessed using vision functions to display correct part of image data, fit the scale etc.
Everything works fine, but the standard conversion way
takes long (25 ms). It becomes user unfriendly, when every scale / move of the XY graph introduces a delay.
The IMAQ vision preprocessing takes about 25ms too, together with some other calculations, the user response is about 60ms and it is just so - so to use.
I am hoping, to cut some processing time over here, becouse it it just flattening of an array.
I started making my own IMAQImage2LVPic function, but little success, since I do not understand the Image format of the LVPicture, I keep getting deformed images, memory violations and it becomes frustrating.
The memory structure of the LVPicture would be great to know. Please help.
Solved! Go to Solution.
01-18-2013 03:25 PM
The most likely reason that it is taking so long is that memory resources are redundant several times for this operation. The image data type defies the usual LabVIEW paradigm, as it is essentially a pointer to an array of pixel data rather than the actual data itself. This makes sense because images are fairly large memory chunks, and if you can operate on them and then stick them back in the same place you found them, you really won't cost yourself much RAM. That is how image manipulation generally works.
However, this changes when you want to bring the actual array data into LabVIEW. When you convert the image to an array, you are reallocating the image. It now exists in the location pointed to by the image wire, and it exists in LabVIEW RAM "on the wire." It is reallocated again when put into the cluster, then reallocated a few more times when calling the Draw Flattened Pixmap VI. At the end, it is flattened to string, which is another allocation, and then concatenated with header data and so forth, which is yet another memory allocation. (By the way, the picture data type is essentially a string full of flattened data). By the end of the whole deal, you have half a dozen or more copies of your image in RAM. That is costly and time consuming, however, when dealing with arrays directly, which is what this method is doing, it is difficult to avoid this because any time you change the size or change the datatype, you are reallocating all of that data again.
I would suggest going the other way, and trying to use the image data type and use IMAQ and Vision functions. The benefit is that these are designed specifically to handle large arrays of deep data and perform multiple operations on them with minimal memory reallocation. That is why the data type itself is a pointer rather than actual data.
01-19-2013 03:03 AM
@Wes_P wrote:
However, this changes when you want to bring the actual array data into LabVIEW.
This takes little time, 1 ms for 700x700 image.
The brake is the flattening operation using labview for loops.
How can I move to vision ?! I want to display the picture in XY graph, did you read the post ?
01-20-2013 03:10 PM
Rather than drawing into the PlotImage of the XY Graph, have you tried making the XY Graph transparent (which includes both the graph background, and also the enclosing control), and placing it in front of a Vision Display? Then you won't need any conversion. I haven't tried it, so I don't know whether there may be issues with the speed of drawing, or flicker, or aliasing, but it might be worth a try.
01-20-2013 03:31 PM - edited 01-20-2013 03:32 PM
Bublina wrote:
How can I move to vision ?! I want to display the picture in XY graph, did you read the post ?
Well, if you want to keep using graphs, that means that you are going to have to keep taking up excessive memory and processing, and you will keep having these problems. I read your post and was trying to help you. No need to get snarky about it.
01-21-2013 12:09 PM
Wes_P wrote:
Bublina wrote:
How can I move to vision ?! I want to display the picture in XY graph, did you read the post ?
Well, if you want to keep using graphs, that means that you are going to have to keep taking up excessive memory and processing, and you will keep having these problems. I read your post and was trying to help you. No need to get snarky about it.
No offense
01-21-2013 12:11 PM
@GregSands wrote:
Rather than drawing into the PlotImage of the XY Graph, have you tried making the XY Graph transparent (which includes both the graph background, and also the enclosing control), and placing it in front of a Vision Display? Then you won't need any conversion. I haven't tried it, so I don't know whether there may be issues with the speed of drawing, or flicker, or aliasing, but it might be worth a try.
Never thought about that !
01-21-2013 02:02 PM
Just thought of a second option, if there are not too many points in your XY data. You could use the IMAQ Overlay functions to overlay your lines directly onto the image, without the graph - this also allows for an easy handling of zooming, if you need to do that. Vision 2012 has the option (in Overlay Multiple Lines) to "Maintain Width" which means the lines remain the same size independent of the zoom.
01-21-2013 02:42 PM
Unfortunately, there is usually tens to hundreds of thousands of data points...