05-02-2017 03:40 AM
Hello all
I have started a project for image processing and would like to have some inputs to improve the processing time,speed and overall efficiency. I am using a Basler ace 1300-30um camera and a DAQ USB module ( not NI DAQ). A display card has to be tested for each display and depending on the image processing result, a button is pressed on the display.
The current situation is like this:
STEP1:I start camera and grab an image. close camera. Do the Vision processing for parameter 1 with acquired image and if the result is TRUE, then go to STEP2.
STEP2:I start camera and grab an image. close camera. Do the Vision processing for parameter 2 with acquired image and if the result is TRUE, then go to STEP3
STEP3:I start camera and grab an image. close camera. Do the Vision processing for parameter 3 with acquired image and if the result is TRUE, then go to STEP4
.
.
Like this i have around 10 - 15 test steps. For some teststeps, the camera have to wait a few seconds to grab image as the display have different timings. Some steps also include text recognition.
I have a MAIN VI using queue sturcture( producer- consumer) and all test steps are subVIs. For each subVI, camera is started, image is grabbed, camera is closed and image is processed.
Is there any better option to decrease the processing time? at the moment the camera is triggered manually based on the Image processing result( TRUE or FALSE).i.e each time starting , grabbing and closing camera.
Is it possible to initialize and open the camera in the beginning and then just trigger it dependng on the Image processing result( TRUE or FALSE)? Will that be beneficial or will it just lag the whole process.?
Thanks
05-02-2017 03:51 AM
05-02-2017 07:15 AM
A few questions and comments.
Bob Schor
05-02-2017 10:34 AM
Hi Bob
05-02-2017 11:14 PM
@Nghtcrwlr wrote:
Hi Bob
- Yes. a small portion of my processing time is spend in opening, configuring and closing camera each time. So, do you mean i open the camera and configure it initially just once ( in initialize state) and then do the IMAQ snap each time the processing is finished? Exactly. With my camera, I turn it on, take a picture, look at the picture, take another picture, look, take, look, take, then turn it off. I could turn on and off around each single picture, but that just wastes time ...
- I programmed my test steps as State Machines. Each State Machine is running like this: Initialize controls , Get & process Image 1 , Check result, End. Depending on the result of one Test step, it goes to the next. Modify slightly. First State is "Turn on", middle states are "Snap", "Process", "Crackle", "Pop", after which you go back to "Snap" or, if you are all done, to the last state, "Turn off and Exit".
Bob Schor
05-03-2017 01:27 AM
Hi!
have I overlooked that, or can you post (the interesting section of) your code?
As Bob wrote I would strongly recommend to open and close the IMAQdx sesssion only once. Depending on your priority (latency, throughput) it could be helpful to transfer your image processing to another loop (if the processing takes a considerable amount of time), so you do not have [once: open camera] [loop: -> wait for trigger -> snap -> process ->] [once: close camera]
Best regards,
Christoph
05-03-2017 01:40 AM
A note about the open/close each loop, it tends to leave a ref in memory so the memory grows, which can cause out of memory if running for too long. That won't happen if opening once, ofc. 🙂
If the processing take too long, you can send the image off to a queue and have one or several consumers that'll process in parallell.
/Y
05-03-2017 10:49 AM
The code is a bit large. But here is what i do. The below snippet is a state machine with 3 states. After one time the state TEST is executed, it remains again in the TEST state until all teststeps ( test1,test2,test3)are completed.
I tried taking the open camera and close camera sessions in Initialise and End states respectively. ( oipening and closing just once). But then I have always an error( Camera already in Use)
05-04-2017 12:00 AM
Before getting why it's giving error
-Where is the stop button to stop the loop?
-Are you using Abort button?
-Post your code as you mentioned with following setup:
@Nghtcrwlr wrote:
I tried taking the open camera and close camera sessions in Initialise and End states respectively. ( oipening and closing just once). But then I have always an error( Camera already in Use)
-You get the Camera already in Use either because you didn't close camera properly or aborted in between.
-As suggested by others it is always nice to have Camera Open in Init case, and snap in test case and Close the camera in End case.
05-04-2017 12:47 AM