Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

NI vision project can't find pattern after migrating to labview.

Solved!
Go to solution
Unfortunately it's very difficult to help unless we don't see code.
- you told it doesn't exit properly - some loops are still running maybe!!
- make sure all loops have proper exit mechanism.
Thanks
uday
0 Kudos
Message 11 of 17
(2,106 Views)

Thank you, I'll look after it tomorrow and I'll send the whole project, and explain how it should be working. 🙂

0 Kudos
Message 12 of 17
(2,103 Views)
one of the thing that I think could cause such problem is your controls value maybe you adjust some of your control value like minimum contrast or other control
check all of your control value before start to run your code
0 Kudos
Message 13 of 17
(2,095 Views)

Sounds like a race condition.  Perhaps sometimes the program is trying to do the analysis before loading the template.  Easier to tell if we can see the code, though.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 14 of 17
(2,090 Views)

So the process looks like the pic, I attached. I think it's easier to explain how it works because that's in hungarian language. 🙂
Steps contains:
Clear: clears a specified folder (C:\REPORTS\ - moves the files from it to the - C:\ARCHIVED\ - folder.)  I made it with Labview and added a "Run LabVEW VI" step on it. In this step there is a user input, which asks if it's a new product or it's the same.(You will understand why are these needed,  when I tell everything) So, if that is a new product, so the user push YES on the popup the next step is the Barcode step. If the answer is NO, in that case the next step is the BarcodeCheck state.

Barcode: It asks a string which is saved in a Variable(Barcode var), and sets the Sameprod(int) variable to 0! From this state the next step is the Wait state

BarcodeCheck: increments Sameprod variable(It's needed to detect if there is more than 2 analyzed picture with the same barcode). If that would be the third, fourth etc.. analyze with the same barcode, it goes to the Warning state, otherwise to the Wait state.

Warning: It's just says that "You already have 2 analyzed picture with that barcode. Are you sure you want to use this barcode?" If the answer is Yes the next state is the Wait, if it's No, it goes to the Barcode state.

Wait: It has a "Run LabVIEW VI" step. The vi watches a folder (Filesystemwatcher .net) if the REPORTS folder gets the CScan.tif named file (just accepts this), it steps to the next state which is the Get-Match state.

Problematic part:

Get-match: I think there is the problem, 'cause until (and after) this step the program works correctly. So in this state, firstly opens the CScan.tif file with "Simulate Acquisition". After that I used the Vision assistant to "Extract RGB-Blue Plane 1" the image, then I used Proper close->Dilate->Erode to eliminate the defects (small black pixels, cuts on the product etc, because these aren't mean the product is wrong.). And here comes the 2 "Geometric Matching" function. I'm using 2 different geometry Matches First and Matches Second. If matches first is 1 the Firstmatch logical calc is Passed the other is Failed - in that case it goes to the First_Pic thread - if the matches second step is 1 then goes on the Second_Pic thread. AND if there is no matches, it goes to the NotMatch state (on the top).
Not Match: It tells the user, that it couldn't find any matches on the picture. And in the Labview migrated version I'm getting this message all the time.

-So I set the template as the following way: Open geometric matching, Template tab, New Template, select the whole picture, finish, set the minimum score to 4-500 at the settings tab and that's it. Did I do something wrong?

First_Pic - Second_Pic(these are doing the same thing): Set the Part variable to part1 or part2 depending on which thread are we at. Gets the Botton and the Right edge, sets a geometry from these, and makes a coordinate system about this. After that I put a sobel filter on it to filter out the intensity differences.
Threshold1-Threshold2: Thresholds the image to make it binary and to get the defects of the product.
Check_Voids1-Check_Voids2: In these states I used Measure Intensity, to filter out what's defect, what's not. After these measurements I selected the original picture, put some overlay on it to show the user(/operator) which is the problematic part of the picture. At the end of these states made a Logical calc to get the result and set it with set inspection status. If the result is OK these are going to the ResultOK if these're not ok, go to the Operator_Decision state.

ResultOK: It's a simple state which includes an Operator Input, that tells the user "The Analyze status is OK". The next step is the Move_Final state.
Operator_Decision: An Operator Input tells the user, the Analyze status is NOK. After that another Operator Input asks the user about his opinion, that the product is really wrong or it's not. After that comes the Move_Final state.
Move_Final: It moves the CScan.tif file from REPORTS folder to REPORTS2 folder, and in it makes a folder every hour, that's where the picture gets.

Log: In this state just Logs the Results in a csv file.

And that's the loop, that's what the program SHOULD do all the time. So any ideas what did i do wrong?

Thanks,
Bence

0 Kudos
Message 15 of 17
(2,084 Views)

I found out there is no problem with the template or the template matching. My next guess is that, I did something worng at my LabVIEW VIs, what I use at the Rub labview VI features. I attached these VIs, could someone look these, what could be wrong?! (rename the zip's format)
Thanks

0 Kudos
Message 16 of 17
(2,050 Views)
Solution
Accepted by topic author Sprake

I got the solution! There wasn't any problem with the template, the wrong part was the VI, I built and the setting up of the getimage step. I replaced the VI what was waiting for the CScan file to a VI what is waiting for any file and puts the filename to a string controll. With the vision builder I get this filename, Concatenate it with another string, which is C:\REPORTS\ and gave that PATH(variable) to the simulate acq. step. After these changes the inspection works perfectly.
Btw thanks for all your replies!
(I attached the VI which waits for the file and get its name, just delete the "rename" word from the extension)

0 Kudos
Message 17 of 17
(2,038 Views)