09-04-2018 10:20 AM
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
Solved! Go to Solution.
09-04-2018 10:36 AM
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.
09-04-2018 10:37 AM - edited 09-04-2018 10:42 AM
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)
09-04-2018 10:43 AM
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?
09-04-2018 10:45 AM
Thanks for your answer.
Ok i make a simply version of my code and upload it.
09-04-2018 10:59 AM
Hi altenbach
I upload a simply code that simulates the operation of my program.
Thanks in advance
Pablo
09-04-2018 11:12 AM
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.).
09-06-2018 02:10 AM
Hi altenbach
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.
Again, thank you very much
09-06-2018 01:47 PM
@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 😄
09-07-2018 01:28 AM
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