Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Instability in pattern matching

Quick suggestion to improve rotation invariance pyramid pattern matching performance. 

 

Increase the cache size in advanced options to reduce repeated computation of intermediate rotated images. Since your template size is quite large this can help boost the performance. Parameter to modify is Pyramid-Max Cache Size in MB. I reduced the timing to half by keeping it as 50 MB (default is 5MB). I am not sure if your system / application would allow to block sizeable cache for pattern matching. But, it is worth  trying. Also, please use brad's suggestions in addition to increasing the cache size. Cache size is not exposed in Vision Assitant, you need to modify it in your program. Let us know your findings.

 

Thanks,

Antony

Message 101 of 117
(1,609 Views)

Hello Antony,

As you wrote your suggestion helped with GPM (pyramid pattern matching). I have a small program that tests metods and measures processing times.

 

Results( All methods finds all 4 parts!)

 

PM (grayscale value pyramid) with Max cache size 5 MB (default) takes approximately 17 sec.

PM (grayscale value pyramid) with Max cache size 50 MB takes approximately 6-8 sec.

 

For me this is quite a significant imprevement.

 

But (a big but Smiley Happy)

GPM takes just 02.60 secs.

 

For our project, even with max cache size 50MB, PM speed not acceptable.

 

Thanks

 

Download All
0 Kudos
Message 102 of 117
(1,621 Views)

Hello Antony,

 

The value for "Pyramid - Match list reduction factor" in previous PM-tests was "0". As Brad suggested i changed this value and set "10".

 

Now the results for PM are much better and acceptable.

 

PM (grayscale value pyramid) with Max cache size 50 MB and "Pyramid - Match list reduction factor =10" takes now approximately 3.24 sec.

 

I thak you and Brad for all your helps.

Message 103 of 117
(1,610 Views)

Hi,

 

Glad to hear that you liked the results.

 

What is your target hardware configuration? Are you using any NI Hardware for this timings? I got less than a second for Pyramid matching in 2.7Ghz, i7 Dual core machine. 

 

My recommendations for few advanced options for your use case are:

1. Pyramid match list reduction factor - default 0 : preferred - 2 or 3 (unless you miss matches). You could also use 10 as Brad suggested but if you are missing matches in difficult cases this is the first parameter to modify.

2. Pyramid Process Border matches - default 1 : preferred - 0 ( unless you have parts on the border and occluded).

 

On the side note: While I was analysing your template (template002.png), I found that template curves had very sharp spikes due to binary form. This might affect GPM accuracy since it changes characteristics of curve. I got better results when I used grayscale template.

Message 104 of 117
(1,598 Views)

Hello Antony,

Target configuration:

Dell Inspiron 15R N5110

Intel Core i5 2450M (2.50GHz), 4MB RAM,Windows 8.1 Pro (64-bit)

 

I think your configuraton is better, this may be a reason why you got less than a second for pyramid matching. But less than a second?

 

We use NI vision .NET (C#). Our project (and test program that i previously mention) is in C#, too.

 

Vision Assistan generates code for LabVIEW with "IMAQ Match Pattern 4", and for C# with "MatchPattern3".

We have use "MatchPattern3", because we program in C#. I wonder if the different functions are an another reason for speed differences?

 

Can you post your script/code and template?

 

0 Kudos
Message 105 of 117
(1,586 Views)

Matchpatten3 is the right function.

 

c# code and template are attached. I relearned with grayscale template.

 

First iteration timing little high (still under second) to warm up rotation cache. Timing reduces from second iteration (it was giving under 500ms in my machine).

Download All
0 Kudos
Message 106 of 117
(1,573 Views)

Hello Antony,

 

Can you post Vision Assistant scrip file, too? I too use visison assistant generated code as basis, but for vs2008.

There is a huge speed difference between your code and my code. I can't understand why.

 

An another question: How did you generated your template "template005_PM.png"? It is saved with "Max Pyramid Level to store = 4". Did you changed it? I ask this because my templates are saved with value 2 (this makes template editor)

0 Kudos
Message 107 of 117
(1,565 Views)

Hello Antony,

After i studied your code again. I can see now a reason (there maybe more) why your code is faster than mine.

 

You loads all images (image and template) than starts to measure processing time at the point where matching takes place.

 

                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();
                patternMatchingResults = Algorithms.MatchPattern3(image, template, algorithm, matchesRequested, score, angleRange, roi, advancedMatchOptions);                
                stopWatch.Stop();
                timeTaken = stopWatch.ElapsedMilliseconds;                

On the other hand, i load image (not template image)  and start measure processing time. Loading template image was performed in this processing time.

 

 

0 Kudos
Message 108 of 117
(1,559 Views)

Hello Antony,

My new code and template:

 

Download All
0 Kudos
Message 109 of 117
(1,551 Views)

There is a option in Template editor to modify Max Pyramid Level to store. I incresed to 4 to reduce the disk size of template. Reducing this value will reduce the need to compute intermediate rotated images during matching. But, if there is enough cache this can be increases to save template size so that file read time can be reduced.

0 Kudos
Message 110 of 117
(1,543 Views)