Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I load pattern matching images into memory?

I discovered this problem by accident when our network went down. I could not run my VI because the .png file used for pattern matching was on a network drive. My concern it the amount of time that is required to read a network file. Is there a way to load the file into memory when the VI is opened?
0 Kudos
Message 1 of 5
(2,923 Views)
Brian,

Thank you for contacting National Instruments. For most pattern matching programs, the pattern file should only be read from file once and is then copy to a buffer on the local machine. If you examine your code, or an example program for pattern matching, you should see at least two IMAQ Create VI called somewhere near the front of your code. This VI basically creates a memory location and most likely will be called once for your pattern image and once for the image you are searching.

Unless you are specifically calling a File Dialog VI where you are given a dialog box to open a file or have hard coded the file path so that it is read each iteration of your code, then your pattern file should only need to be called at the beginning of your application, th
us causing only one file read over the network for that image. Therefore your program most likely already loads the image in memory once it is read and should not be accessing the network constantly.

Again, I would recommend taking a look at your code to make sure you are not causing a file access every time and then you should be ready to go. Just in case you do have the network go down, I would recommend keeping a copy of the image locally and, if you are feeling ambitious, you can programmatically have your program read the file locally if the network file returns an error.

Good luck with your application and let us know if we can be of any further assistance.

Regards,
Michael
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(2,923 Views)
Michael-

I am using the pattern matching functions as they were created by Vision Builder. There is a Create, Read Image and Vision Info, and Destroy for the pattern matching portion. This would be called on every iteration of the program.

Are you saying that I should use a Create and Read Image and Vision info only once at the beginning of my code and pass the image into the VI that uses it, and never destroy it?

Thanks,

Brian
0 Kudos
Message 3 of 5
(2,923 Views)
That is what you should do. Unless you are modifying the pattern, it won't change during the execution of the program. It doesn't make sense to continuously recreate it for each iteration. This can be a time consuming process that really slows down your program.

You could destroy it as you exit the program if you want. That is a little cleaner, but not absolutely necessary.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 5
(2,923 Views)
By making this change, I was able to shave 300 ms off of my processing routine!

Brian
0 Kudos
Message 5 of 5
(2,923 Views)