LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Efficient 2D array Append

Solved!
Go to solution

Hello everyone

 

I have a problem with the efficient handling of 2d arrys.  I try to simulate a continuos image of lineal camera. All the image have this dimensions (U16) 3200 pixels of height for 6900 pixels of width. 

 

First of all i create a array with this dimensions (all of the elements with value 0 (U16)) and initialize a shift register of a while structrue.

 

In each iteration i have to concatenate, the data that the camara gives me (one array of dimensions 3200 pixels of height for 100 pixels of width (U16)) at the beginning of the full array (3200x6900) and to mantain the dimensions i have to delete an array of dimensiones  3200 pixels of height for 100 pixels of width (U16).

 

I have measured this two operations in each iterations:

Concatenate array = 200 ms (aprox.)

Delete array = 10 ms (aprox)

 

My problem is that each packet of data that the camera returns to me is in approximate time of 100 ms, if i have a time for concatenate arrays of 200, i lose packets of datas.

 

i want to know if there is a more efficient way to do this to lower my times to 100ms or less

 

Thanks is advance

 

Pablo

0 Kudos
Message 1 of 10
(4,299 Views)

So for a full image, you are getting 69 smaller images.  I am left to assume this acquisition is in a FOR loop.  Therefore, you could just use Replace Array Subset to put your latest sample in the array.  When the FOR loop is complete (69 iterations), you will have your full image.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 10
(4,295 Views)

If the size does not change, you would use "replace array subset". No need to change size ever.

 

(Next time, please attach a simplified version of your code. It is easier for us to tell what you are doing. Long descriptions are ambiguous. It is also not clear how you measure the speed. These numbers don't look right)

Message 3 of 10
(4,294 Views)

Thanks for your answer

 

The image is obtained as a while loop, like a ring buffer with this dimensions 6900 x 3200 for genarate like "live image". How could I solve my problem then?

0 Kudos
Message 4 of 10
(4,290 Views)

Thanks for your answer. 

 

Ok i make a simply version of my code and upload it. 

 

 

0 Kudos
Message 5 of 10
(4,288 Views)

Hi altenbach

 

I upload a simply code that simulates the operation of my program.

 

Thanks in advance 

 

Pablo

0 Kudos
Message 6 of 10
(4,279 Views)
Solution
Accepted by topic author Pablo_Novadep

Sorry, I don't have the IMAQ toolkit, but there is absolutely no need to ever change the size of the array. You do a bewidering amount of data manipulations (Transposition, appending at the front, etc. etc) where none are needed.

 

Here's a quick example that builds the array from 100pixel wide slices and displays it whenever a full frame has been acquired. (Displaying the image is probably the most expensive operation, so don't do it with every new slice.).

 

 

Message 7 of 10
(4,269 Views)
 
Message 8 of 10
(4,206 Views)

@Pablo_Novadep wrote:
Your tip is amazing, only 2ms in each loop!! Thank you very vey much. I modified your example to what my application has to do, my image works like a fifo stack, that's why I have to rotate the image. I attached my example to see if you think it is efficient or not. I have measured the time in each iteration and it is 70 ms.

 Why do you think you need three time primitives to control and measure the loop rate. One wait is sufficient, it will give you the tick count for free 😄

 

ticker.png

 

 

Message 9 of 10
(4,186 Views)

Hi altenbach!!

 

You have to teach me, master!!! jejeje

Thanks very very very much for your tips!!. Now i have to investigate how to make a histogram as fast as possible, since before I used the IMAQ tools.

 

Best Regards

 

Pablo

0 Kudos
Message 10 of 10
(4,169 Views)