Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Color pattern matching is very slow

Hi

 

I tried this code creating one vi application.

pic1.png

After the testing with USB webcam I have realized that the color pattern matching is very slow. How to increase the speed and to work smoothly in real time.


Thank you

 

0 Kudos
Message 1 of 9
(5,623 Views)

Hi tiho,

 

Thank you for posting your question. Could you please describe what you would like to use your application for and post the VI if possible. Also, I would suggest to try some examples and if you are satisfied with the results start adding more functionality to it. Finally, what do you mean by Real Time? Do you use a Real Time platform or just want to see smooth results.

 

Good Luck With Your Project,

Tamas

0 Kudos
Message 2 of 9
(5,602 Views)

Hello tiho,

 

the color pattern matching is not as fast as 8-bit matching, but should still be fast.

 

For example, I am attaching a VI for color pattern matching where you load the image, create the template and search do the matching.

 

In my example I tried color pattern matching on color image of size 4288x2848 pixels and the matching is performed in ~140 ms (~7Hz). So, for a smaller image, I think the real-time processing is quite achievable (I consider real-time 20 Hz or more). The only problem is the template learning, which in my case takes around 10 seconds. But you should learn the template only once in the initialization stage.

 

 

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 3 of 9
(5,592 Views)

Hi

 

Thank you for your answer. I would like to make an application for selection of a desired object by the PC mouse and than finding this object. I am using an USB webcam. At the moment I don't use a real time platform. I would like to see smooth results only but till the moment  the webcam is working very slow when I am using the color pattern matching. I have fpga PCI card (NI PCI 7833R). I think that it will be suitable for a real time control but I would like to try at the beginning only with my home PC.

 

Best regards

0 Kudos
Message 4 of 9
(5,583 Views)

Hello,

 

I have tried your code and modified it a little:

 

You had no camera initialization and the template learning was not correct.


I achieve ~20 fps matching ( 50 ms per match) with 1280x720 web cam image size and 150x50 template size.

 

The computer specifications:

core i7

6 GB ram

 

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 5 of 9
(5,568 Views)

Hi tiho,

 

I found a forum page where they discuss a similiar problem, it includes an example as well . Please feel free to take a look at it:

 

http://forums.ni.com/t5/LabVIEW/How-to-use-Colour-pattern-matching-with-a-webcam/td-p/1855227

 

Besides this I have a few suggestions:

 

Use the wires directly if possible rather than the local variables.

If it is not necessary to change parameters after the application started change the controls to constants.

I would considere a State machine for this application with an Initialization, Run and Close state so only the necessary part of the code would run when processing the image. Here is a little help if you are not familiar with it: http://www.ni.com/white-paper/7595/en/

Finally, check different parts of your code to see which one takes (too) long to execute. 

 

Good luck with Your project

0 Kudos
Message 6 of 9
(5,567 Views)

Hi tiho,

 

I just wanted to check if you managed to have your application working with the desired results.

 

Good luck with Your future projects.

 

Tamas

0 Kudos
Message 7 of 9
(5,536 Views)

Hi Tapas

 

I have checked the corrected application. It is working very well. Thank you very much. I would like to know why sometimes it is not possible to find the object. The red rectangle appears in wrong places. My second question is: is it necessary to use FPGA PCI board for real time applications in domain of image processing?

 

Best regards

 

Tihomir

0 Kudos
Message 8 of 9
(5,521 Views)

Hi tiho,

 

I am glad to hear that Your application is working.

 

It is possible that you cannot find the object because the lighting changes or the object is seen from a different angle. I would suggest you test it in a controlled environment (for example in the dark with only one light on) and try to change small things like the angle or the light source to see what causes the mismatch.

 

In order to do real-time measurements you can use a smart camera for image processing. It is fast and has a real time operation system so you can create stand alone applications if you want to. Here is a link to see what cameras NI offeres:

 

https://www.ni.com/en-us/shop/category/machine-vision.html

 

Good luck with Your application and have a nice day.

 

Tamas

0 Kudos
Message 9 of 9
(5,515 Views)