05-12-2014 01:24 AM
My application requires fairly quick repetitive image acquisition and processing (<100ms per cycle). Kind of "realtime" processing, I'd prefer not doing post image processing.
Currently the image processing takes ~200ms per cycle (mostly grey image pattern matching).
~150ms of this time is taken by loading the template images from disk or cloning the template images (using the visionimage flatten/unflatten).
The reason for reloading or cloning is that the Algorithms.MatchPattern2 disposes of the template image during execution i.e. I must reload or clone template images every acquisition/processing cycle.
Ideally, at configuration I would like to provide 1x set of template images to the processing application which is reused (without cloning) every processing cycle allowing for a ~50ms process time.
Any fixes or workaounds?
Solved! Go to Solution.
05-13-2014 08:44 AM
In terms of disconnecting acquisition rate from processing rate, I would recommend moving to a producer consumer architecture. This way, your producer loop can acquire images as quickly as needed and your consumer loop can then process them at a lower rate. More information on the producer consumer architecture can be found here: http://www.ni.com/white-paper/3023/en/
Additionally, you might consider creating image masks based on a specific ROI to reduce image size and decrease processing time.
How are you referencing the template? If you open a reference it shouldn't be disposing of that reference each time.
Finally, have you tried MatchPattern 3 or MatchPattern 4? Simply switching to those newer functions may drastically speed up your processing.
05-13-2014 10:44 AM
Thanks for the response Rob.
Note: I am using the VDM .net libraries and coding in C#.
My acquisition is decoupled from my processing. The main reason for mentioning the acquisition was to provide a bit of context to my issue.
I initially thought my big ROI sizes was causing the increased processing time (initial process time = ~230ms). I then reduced all my ROIs sizes and improved the process time = ~190ms.
I'm currently creating an array of template images and passing it into the image processing function (basically performing 9x pattern matches and 1x OCR).
When I remove the template image cloning code(visionimage flatten/unflatten), the image processing function executes in 50-60ms but only executes once. On the second excution cycle it throws an exception....
"Cannot access a disposed object."
"Object name: 'NationalInstruments.Vision.VisionImage'."
I'll try MatchPattern 3... My current version does not have MatchPattern 4.
05-13-2014 11:47 AM
Rob,
Algorithms.MatchPattern3 fixes the issue. ie there is a bug in Algorithms.MatchPattern2 .
Thanks
05-14-2014 08:18 AM
Good to hear it's working better with MatchPattern 3!
05-14-2014 09:25 AM
@BauerPower wrote:
Good to hear it's working better with MatchPattern 3!
is there a bug in the match pattern2? Is there a car already?
05-14-2014 09:34 AM
Definitely a bug in the .net API's Algorithms.MatchPattern2.
I am new to the forum and don't know what a "car" is... I am assuming a bug/issue list. If correct, then no is "car" logged.
05-15-2014 04:34 PM
There were a number of bug fixes and optimizations that were made when moving from MatchPattern2 to MatchPattern3, that's why the function was incremented. I haven't found a CAR in our system for the template reference being disposed of but it looks like it was fixed in MatchPattern3.