Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Try to use IMAQ UAB to track the braiding point.

Solved!
Go to solution

Hello, guys,

Right now, I am working on my project: I use DC servo motor to control braiding machine using USB camera as position sensor. Braiding machine will make a rope using 32 braids. Every braid goes to rope at fall point. These fall points compose braiding point, which is shown in figure 1. For unbalanced forces of every braid, braiding point will oscillate.

My job is fixing the point in horizontal direction. 32 braids are all moving too. So, I may not use  detecting motion method.

 

Muks already help me a lot in this problem under other thread. LV 8.0 in My university may not work any more. I attached a .JPG file, "brainding point tracking" as my code. Please help me take a look.

 

I saw Kristen H.'s post ( http://forums.ni.com/ni/board/message?board.id=170&thread.id=389052&view=by_date_ascending&page=2). He mentioned Ni example, Pattern Matching Example, which doesn't use IMAQ USB. My code follows this example.  I put IMAQ USB vis in this example and get my code (main program3_flat.vi) in LV8.6. It doesn't work well. It said Error-1074395247, Invalid template descriptor. 

 

Please feel free to help a little bit. I have been stuck by this since last Nov. Thank you in advance.  


0 Kudos
Message 1 of 27
(5,955 Views)

Hey guangli,

 

First, is there any more information about where the error you are seeing originated? Which VI caused that error? To help out with that, you could do a little more error handling in your code. However, as it is, LabVIEW does some automatic error handling, and it should inform you which VI cause this error. Second, an error like this could be cause by the fact that you didn't wire your Template Image reference through the LearnPattern2 VI. Instead branching off the image reference for you template, try wiring your image reference to be used for your template image through the LearnPattern2 VI.

 

Also, since it appears that you have the Vision Development Module, is there a reason why you are not using the Vision Acquisition Software and IMAQdx; as apposed to using IMAQ for USB? 

 

template.png

Message Edited by BCho on 01-15-2010 02:50 PM
Hope this helps.
-Ben

WaterlooLabs
Message 2 of 27
(5,922 Views)

Ben, Thank you very much!

I actually change the NI example: Pattern Matching example. I just change the beginning part, which getting image from opening image from a folder to snap a image from USB camera. 

for your question: 


First, is there any more information about where the error you are seeing originated? Which VI caused that error? To help out with that, you could do a little more error handling in your code. However, as it is, LabVIEW does some automatic error handling, and it should inform you which VI cause this error. 

 


 I originally get an error of image type when I modified the example code. I use IMAQ cast image to invert image type to grayscale U8. Then I got this error. BTW, how can I do error handling?

 


 Second, an error like this could be cause by the fact that you didn't wire your Template Image reference through the LearnPattern2 VI. Instead branching off the image reference for you template, try wiring your image reference to be used for your template image through the LearnPattern2 VI. 


 I don't know LV so much! I start change the example code first. Patter matching example work well for static image opened from a folder. 

check this example in attached file. 

 

 

0 Kudos
Message 3 of 27
(5,915 Views)
Solution
Accepted by guangli

Hey guangli,

 

I'd like to start by apologizing for my previous comment. While wiring the image reference through the VI as mentioned in my last post would help keep track of things, it is not absolutely required for the image template. This is because you are already wiring the reference to the image buffer to the set of VIs that create the template. Then, that buffer location becomes the template. This is useful to keep in mind during other image manipulation routines (that you actually change the information in the buffer that the image reference is points to). 

 

Thanks for pointing out the example that you started from. I took the liberty of modifying that same example (see attached) to make it more readable and valuable for your routine. In this example, I am using the IMAQdx VI's (Vision Acquisition 2009 now supports USB cameras that are DirectShow compliant) to acquire the image. I then use the same routine that you see in the example to create a template and then locate that template in subsequent images. I also took the liberty of cleaning up the block diagram and getting rid of the sequence structures and used error handling to force execution order. In your example, you were not far off, I believe it started to get a little confusing with the many different image buffers and numerous unnecessary sequence structures. So, hopefully this example will either work for you, or be a little easier to work with.

 

Each SubVI and property node have error in and error out terminals. By connecting these terminals from one SubVI to another, we can force execution order and keep track of any errors that arise during out code. So, if and error does occur, we can pin point much quicker where it came from and can then address it.

 

The example is in LabVIEW 8.6, let me know if you need a different version.

Message Edited by BCho on 01-18-2010 11:49 PM
Hope this helps.
-Ben

WaterlooLabs
Message 4 of 27
(5,865 Views)

Thank you very much!

I will try to do what you posted and give my response as soon as possible. 

0 Kudos
Message 5 of 27
(5,854 Views)
Dear BCHo,
Thank you for your detailed response. This code your modified is real good one. Like you said, it is more readable and valuable for my routine. That's a lot I can learn from this code since I am a new user. Anyway, I change IMAQdx VI's to USB VIs. It works real well for me. I can search my template now. I almost reslove the problem as I post. Many thanks.
Still I do need get the position after it is able search the template. Actually, I should put this part in my code before. Right now, I put this part after IMAQ Match Pattern 2 in your code. After modified your code, I try to run it. Sometimes, I can the video window. Sometime, no. I cannot read the position of centroid of template, either.   Could you help me a little more? Thousands of thanks! 

 Guangli

0 Kudos
Message 6 of 27
(5,846 Views)

Hi, BCHo,

One more question, how can you know use Search Property node at first? THKS! 

0 Kudos
Message 7 of 27
(5,845 Views)

Hi, ECHo, 

I put my previous code with measurement here as reference. Thank you! 

0 Kudos
Message 8 of 27
(5,836 Views)

Hey guangli,

 

I put the property node for the Search control at the beginning of the code to initialize it. This certainly isn't required; however, if you attempt to use the Match Pattern VI (hit 'Search' and the front panel) before you create a template you will see that an error similar to one that you reported early occurs because you haven't created a template yet. So, by using the property node to initialize the Search control to be false and invisible, I made sure that the user created a template before they attempted to match patterns. Just a little trick to add to the functionality of the example.

Hope this helps.
-Ben

WaterlooLabs
Message 9 of 27
(5,813 Views)

Thank you very much!

I put the position output and convert the pixel to realworld in the end of your code. It only output the pixel value rather than real millimeter. can you help me check that?

0 Kudos
Message 10 of 27
(5,810 Views)