Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

VDM 2012 SP1 Algorithms.MatchPattern2 disposes of the template image

Solved!
Go to solution

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?

0 Kudos
Message 1 of 8
(5,219 Views)

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. 

Rob B
FlexRIO Product Manager
Message 2 of 8
(5,191 Views)
Solution
Accepted by topic author Nemith

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.

 

 

 

 

 

0 Kudos
Message 3 of 8
(5,187 Views)

Rob,

 

Algorithms.MatchPattern3 fixes the issue. ie there is a bug in Algorithms.MatchPattern2 .

 

Thanks

 

 

0 Kudos
Message 4 of 8
(5,182 Views)

Good to hear it's working better with MatchPattern 3! 

Rob B
FlexRIO Product Manager
0 Kudos
Message 5 of 8
(5,168 Views)

@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?

0 Kudos
Message 6 of 8
(5,155 Views)

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.

0 Kudos
Message 7 of 8
(5,152 Views)

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. 

Rob B
FlexRIO Product Manager
0 Kudos
Message 8 of 8
(5,137 Views)