09-23-2021 03:52 PM
Hi,
Hope yall are doing well. I am currently working with an XY and Z stage to raster scan and, next autofocus at each position. Currently, our problem is that the image acquisition speed is to slow. Theoretically with the ThorLabs Camera, I should be able to take pictures much quicker at each position. I was wondering if someone could help me tweak my vi so that the camera can image quicker at each position so the raster scan is faster. I am not sure what is slowing it down, does any know how to accelerate this?
Currently it takes about 5 minutes to raster scan a 100 images in 10mm X10mm. Need it to be faster.
I have attached an image and my .vi. Please let me know if yall need anything else. Thank you!!
09-23-2021 05:15 PM
Right now you have 3 things running in series, and it can't get a new frame until all 3 are done:
* Acquire image
* Process image into RGB color
* Save image to disk
You need to set those to run in parallel. I would recommend setting up 2 separate While loops that run in parallel with your event structure, one for image processing and one for saving the images to disk. When you get the raw image data (the 3D array) from the instrument drivers, just enqueue it as an element and have the first parallel loop dequeue it and process it into a TIFF, then enqueue that again into the 2nd while loop, where it dequeues to do the disk saving.
Also, I am pretty sure you could speed up your processing. Right now you run two nested FOR loops and each one is constantly building arrays with the auto-indexer output terminals. Resizing arrays can be a very time-intensive thing to do repeatedly, so what you probably want to do is create the final array at the start, then pass it into the FOR loops as a shift register, and then just use the "Replace" array function to insert each pixel, or use the "In place element structure" to be totally sure it's not doing unnecessary memory allocations.
09-26-2021 12:18 AM - edited 09-26-2021 12:18 AM
Hi Kyle,
Thank you so much for the outline on how to fix this. I will work on implementing this architecture this week and follow up. This is immensely helpful.
09-26-2021 08:19 AM
@Bobdog20 wrote:
Hi Kyle,
Thank you so much for the outline on how to fix this. I will work on implementing this architecture this week and follow up. This is immensely helpful.
And clean up the block diagram. True story:
A colleague of mine spent a few days trying to find a bug, and the bug was that he had wires running behind his subVI that he thought were connected, but they weren't. (The other glaring issue besides sloppy block diagram was that he didn't set the connector pane terminal to "required" so he had no idea that critical wire wasn't connected.)
09-28-2021 02:38 PM
Hi,
I am having a tough time getting started since I adopted this code from ThorLabs. Is there any way you could highlight what components of the image you would consider running in parallel?
Thanks.
09-28-2021 03:16 PM
I would move the red-circled area into one parallel loop and the green-circled part into another loop. I'm not totally sure you'll want to move the VI that makes the Z scan live view there, but definitely the rest.
You'll want to use a queue to do this (2 of them, actually). There's a few "how to use a queue in LabVIEW" videos and pages if you're unfamiliar with how to do that and need a starting point.
09-28-2021 03:44 PM
Thanks for the reply. My understanding is that there will be will 3 loops.
Loop 1.) Z-scan to acquire the image. (outside of green and red circle)
Loop 2.) Process the image to RGB (red circle)
Loop 3.) Save image to disk (green circle).
There will be 2 queues, one queue between loop 1 and 2, and another queue between loop 2 and 3?
09-28-2021 05:44 PM
Yes that's what I am recommending. Give it a shot and see what happens.
10-01-2021 09:59 AM
So far this works, not as fast as we'd like it but its significantly better (might be a computer issue). Might be following up with more questions. Thanks a lot for your help, I really appreciate it.
07-26-2022 10:21 PM
Hi Bobdog20,
Would you mind sharing your VI, as I'm having the same issue with the Kiralux cameras in LV, and I'm trying to put the get image and process image components into separate loops.
Much appreciated if you can,
Browntown