Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

IMAQ Match Pattern 2 bug?

I think IMAQ Match Pattern 2  vi. is not made to run in parallel with itself. To be honest I do not  see a reason why not.

I use LV2009 SP1 on RT 9.01 with a Basler camera running at 60fps.  2.4GHz quad core


When I use one Match it is all fine but when I try to find two different patterns at the same time using two IMAQ Match Pattern 2  functions it goes haywire. How? It slows down about 15-20ms. My single match takes around 1-2ms, So when I run IMAQ Match Pattern in series it takes 2-4 ms, when I tried run it in parallel it takes 15-20 ms. It does not output any error though!

I made sure that it gets all the proper memory separate for each call etc.

IMAQ Match Pattern  has the execution properties set to reentrant execution and sharing clones. That does not sound right. Is it a default setting?

I would expect it to run faster not slower with the presence of 4 cores. If it was not intended to use in parallel it should be blocked or mentioned somewhere?

 

I guess I ill try to make my own copy of the function under different name but still it does not sound right.

0 Kudos
Message 1 of 7
(3,658 Views)

Hi Andy,

 

Do you have an example or screen shot of how you have it set up? It sounds like it should be able to run in parallel since the sharing clones will allow a default of two instances of the VI to be in memory.

 

How many image sessions do you have running in memory? If both VIs are trying to use the same image for matching, then that could also be your slowdown. They could be jumping back and forth between the image, rather than just focusing on one process at a time, and causing the delay on top of what your are seeing for serial. Give it a try but create a copy of the image and have each match work on its own image copy.

 

Best Regards,

 

Nathan B

Applications Engineer

National Instruments

0 Kudos
Message 2 of 7
(3,650 Views)

I will post the screenshot in a while.

The timings I got are from the performance profile and memory tool. Well, based on the numbers I see match2 takes 0.003ms ( yes ms) based on 13k runs. It used to be 1-2ms. Yet one extra match makes the acquisition to drop from 60fps to 30fps ( every 2nd frame 16ms to 33ms). My image copy takes now up to 5ms and used to take nothing  ( like 0.1 ms) It seems that the performance profiler puts random vis in the chart... Seen the same thing with a vi that was only unbundling two values out of a 6 elements bundle. That was taking more time ( according to the profiler) than image processing or any other Vi I had in my project. Are those symptoms sounding familair to anyone?

 

How reliable are numbers provided by the Performance profiles? For one test run ( best on a few k loops) l always have them consistent but I cannot say it makes perfect sense. 

 

Nathan,

As I mentioned I was afraid the two vis might be fighting for access to the memory so I made sure each gets its own copy ( using ImageCopy) and of course the memory was allocated outside the loop (if that is what LV really does during the "Create" image action).

0 Kudos
Message 3 of 7
(3,643 Views)

Here is a piece of the code. If I remove the second match it is all ok. Well, assuming those timings form perfomance profiler are any good.

0 Kudos
Message 4 of 7
(3,634 Views)

Here is the Profile and Performance Memory screenshot. Those numbers dont make much sense to me except the first one - something caused a delay and now it has to wait longer than usually for the next frame (but that is a fairly new thinng in my history of watching the timings in my project).

0 Kudos
Message 5 of 7
(3,628 Views)

Hi AndyN,

 

Where is this process being performed? On the host or target? It also seems really odd that it only takes 3 microseconds for the second pattern match.

 

Do you have a portion of code that I can try myself? I would like to see if I can replicate it here.

 

Best Regards,

 

Nathan B

Applications Engineer

National Instruments

0 Kudos
Message 6 of 7
(3,613 Views)

All the code happens on the target. I will try to come up with someting on Friday.

It seems to me that my conclusions based on the Profile and Mem thing are false . The timings dont make any sense and they change drastically between different configurations of the software.

Right now my Match takes about 3ms... Copy takes nothing and Get image takes about 5ms.  

0 Kudos
Message 7 of 7
(3,610 Views)