Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

match pattern

I hope someone can help me out.  I am new to labview and i'm currently trying to make a continuous security system off an image through match point. 

I can't find that much information on it here are a couple of quesitons I have.

1.  How do I make a camera image go into my match function?

2.  Does my template have to be signified as an ROI?  Or can I take imagine(not in labview) and crop it and just use it as my template image.

 

As you can can I've started but i'm still confused on a lot of stuff.I've also included the VI I have just started as well.  The template is a image I have saved on my desktop, or home station, is this the correct way to start?

 

 

security.png

0 Kudos
Message 1 of 8
(7,294 Views)

Hello,

 

1. The image acqired from the camera is passed as a reference (purple line), so you can just directly wire it to the matching function. You need to wire both image and the template.

2. A template is basically your object/scene that you are trying to match in each new image. You can use outside editor to create a starting point for you template, but you still need to learn the significant features that are used for matching in Labview (train your pattern).

 

I have attached a really simple and straightforward example that should get you started. Just specify the image path, load the image, use rectangular roi tool to draw around the object of interest, learn the template and finaly search for it. Should be pretty easy to modify the example for live stream acquisition. (I suggest once you start building your application, that you follow the dataflow concept - you should not need the sequence structures).

 

 

There is also an example in Labview ("Help -> Find Examples")

 

For further reading check the NI Vision Concepts help and http://docs.opencv.org/doc/tutorials/imgproc/histograms/template_matching/template_matching.html

 

Hope this helps a bit.

 

Good luck.

 

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 2 of 8
(7,280 Views)

Ok so I'm experimenting with your Draw Pattern Matches block.  And I keep getting error code. 
I looked it up and it says it's a formatting error with the picture I'm trying to save, so I switched it as a PNG and still to no avail. 
I've included the VI and the image I'm trying to initially go through.  As well as pictures of the current running code and error:

current.pngcurrente.png

Download All
0 Kudos
Message 3 of 8
(7,253 Views)

Hello,

 

the draw pattern match.vi just overlays the matches found - it does not perform matching. You should use the color_matching.vi (if you check the code carefuly, you will see that the draw pattern match.vi is a function (subvi) inside). So in order to save the images, do it in the main program (color_matching.vi). Also, be careful with objects touching the border, since you need to have a sufficient padding to process this. I would avoid objects at the image borders.

 

test.png

 

Regarding your problem saving .png - check the "IMAQ Write PNG File" function (it does not accept hsl). If you want hsl, I think you will need to use "IMAQ Write Image And Vision Info File". You can only write the file as a .png.

 

Best regards,

K

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 4 of 8
(7,247 Views)

The draw pattern match.vi just overlays the matches found - it does not perform matching. You should use the color_matching.vi (if you check the code carefully, you will see that the draw pattern match.vi is a function (subvi) inside). So in order to save the images, do it in the main program (color_matching.vi). Also, be careful with objects touching the border, since you need to have a sufficient padding to process this. I would avoid objects at the image borders.

 

Yeah I clearly missed that subvi.  I see it now.  if you don't mind a couple of quick questions about the color match.vi
Mostly step's 1(0.2).  You have two image's going into IMAQ extract, that is getting the color palett of both image's and then your going to learn color pattern.  This function processes the color pattern of both image's, and makes a region of interest of similar color.  The global rectangle, extracts a rectangle like shape of the similar colors.

 

And then in 2 you just have both image's going into the match pattern looking similarities. 

(is that right), I guess my question is why is step 1(0.2) so important.  I think that's where issue lies, just key understanding, I've tried reading up this, but just ROI's just aren't "clicking" with me.

Sorry for slamming you with questions, I just want to learn this more.

 

Thank you

 

 

 

 

 

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

Hello,

 

no problem about the questions - that's what forums are for 🙂

 

So to take it step-by-step:

 

1. Create image reference to hold your original image (loaded image or acquired from the camera)

2. Create image reference to hold your template image (the template image is the subregion of the original image, usually the subregion, where your object of interest is located.

 

The pattern matching algorithm needs to know what the template image looks like (i.e. the intensities), so it can calculate the match using the criteria function (in Labview its normalized cross correlation, but other can be used, for example http://docs.opencv.org/doc/tutorials/imgproc/histograms/template_matching/template_matching.html). To understand pattern matching read:

 

http://zone.ni.com/reference/en-XX/help/372916P-01/nivisionconcepts/color_pattern_matching/

 

http://zone.ni.com/reference/en-XX/help/372916P-01/nivisionconcepts/pattern_matching_techniques/

 

http://zone.ni.com/reference/en-XX/help/372916P-01/nivisionconcepts/pattern_matching_indepth/

 

 

3. On the original image (loaded image or acquired from the camera) you specify the ROI (region of interest), which is subsequently the image template. You could extract this in an outside editor, for example "Paint".

 

4. Extract the subimage inside the ROI and "learn the pattern" - see the links above!. You need to learn this only once! The learning pattern part is necessary and can be performed in Labview only.

 

5. Search for the templated pattern on each new image.

 

P.S.: ROI is so called Region of Interest. It is basically an image mask, but with the property of being non-pixel destructable (it does not alter the values of the underlaying pixels).

 

Hope this helps!

 

If you need any more help, feel free to ask.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 6 of 8
(7,236 Views)

Ok so I decided to start small, with just basic camera acquistion.

 

I decided to use the grab function, in a while loop but it seems not to be working, i thought this would allow my camera to repeatedly take pictures, as i was able to take one picture without the while loop, but upon putting it in a while loop my camera just stays on and I don't acquire any pictures.   Any ideas?

 

 

0 Kudos
Message 7 of 8
(7,202 Views)

Hello,

 

patience and slow initial pace is the best way to go at learning new stuff. Always double check your actions...

 

Why does it not work along with some suggestions:

 

hmmmm-2_BD.png

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 8 of 8
(7,200 Views)