SLOW pattern matching in VB, FAST in VisionBuil​der?????
I've built several vision aquisition and analysis apps with VB and CWIMAQ. Now, I'd like to do a pattern matching application, however, I can't seem to get the same functionality and speed with the VB component as I can using VisionBuilder! Attached is a grayscale image of a microtiterplate, and a "pattern" of a well or "hole". Using pattern matching in visionbuilder there are about 96 matches, which is perfect, dang near a match for every well. However, if I try to reverse engineer the VB "FeatureFind" example and use the attached picture and pattern, the "Correlation" takes a VERY long time (14 seconds for VB featurefind app, instant for VisionBuilder), and it doesn't even match!
Even though I can't use
visionbuilder in my final application, it works almost perfectly when I use the attached image and pattern while setting the minimum score to 50. I wish I could implement the same thing in VB, that is, if NatInst could tell me the CWIMAQ components function calls used to implement it :-0)
Any Ideas? Thanks
Attachments:
bw.tif 301 KB
test_patt.png 57 KB
I am not familiar with the VB commands you want to use since I use LabVIEW. However, I think you might be using the wrong function. It sounds like the example you tried to modify uses correlation, which is different from pattern matching. As you have seen, pattern matching is much faster and gives better results.
I would assume that the manual for CWIMAQ would give you the information you need.
Bruce
Bruce Ammons
Ammons Engineering
Similar Messages
-
Color pattern matching is very slow
Hi
I tried this code creating one vi application.
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 youHello 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."
Attachments:
color matching.zip 49 KB -
Slowness of color pattern matching vi
Hi,
We're trying to implement a SLAM (simultaneous localization and mapping) algorithm in Labview based on kinect. In order to do so, the mapping robot should spot landmarks in real-time from the kinect image. We found the color pattern matching VI which does exactly what we need but the problem is that it's very slow (about 1.5 seconds for each image and total of 3 images each iteration). Is this the normal time for detecting landmarks in a kinect image? The robot can't map accurately when the iteration is so slow.
Thanks,
Rap Master
Attachments:
detect landmarks.vi 61 KBGiven that the pattern matching VI is an IMAQ (Image Acquisition) VI, this question will be best served by posting in our Machine Vision forums.
Blake C.
Applications Engineer
National Instruments
www.ni.com/support -
Regular expression and pattern matching/replacing
I have a list of key words. It has around 1000 key word now but can grow to 5000 keywords.
My web application displays lot of texts which are stored in the database. My requirement is to scan each text for the occurance of any of the above keywords. If any keyword is present I have to replace that with some custom values, before showing it to the user.
I was thinking of using using regular expression for replacing the keyword in the text using matcher.replaceAll method as follows:
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
String output = matcher.replaceAll(replacementStr);
But My pattern string will have around 5000 keywords with the 'OR' Logical Operator like- keyword1| keyword2 I keyword3 | ..........
Will such a big pattern string adversly affect the performance? What can I do to speed up the performance? (Since my keyword list is not static i would prefer to do the replacement just before showing the text to the user)
Any suggestions are most welcome.I don't think a pure regex approach would be that slow, but it would be a maintenance nightmare. I think a combined regex/table-lookup approach would be best: use a regex to identify potential keywords, then look them up in the table to confirm. For instance, to find all Java keywords you could use the regex "\\b[a-z]{2,12}+\\b" to filter out anything that can't possibility be a keyword.
What are you going to replace the keywords with? Will it vary depending on which keyword is found? If so, you'll have to use a table--and you won't be able to use the replaceAll method, because it can't handle dynamically generated replacement values. You would have to use the lower-level appendReplacement and appendTail method instead. -
Help for image pattern matching
Hello Everyone
I am working for my last year project. In my project I will work on the image processing to find a moving object. I will work by JMF. I have finished to grab a frame from the webcam video clips. Now I need a algorithm to find a Image pattern from the grabed image. But I donot know which algorithm is fine for image pattern matching as well as how can I implement in java. Is anyone know please help me very urgently.
Thank you
Md. Mainul HasanIf you would like to take a look at http://www.exactfutures.com/index01.htm and http://www.exactfutures.com/index02.htm and http://www.codeproject.com/useritems/activity.asp then these pages and links may well be useful to you. It may not be exactly what you are looking for, but it does point to some examples with source for video analytics, and at the very least they illustrate how to capture & handle the data including a fast movement detection algorithm. If you want to find a specific shape then search the internet for information on chamfer distance transforms - one can use JMF or extend these simple examples to apply those techniques.
-
Pattern matching using Regular expression
Hi,
I am working on pattern matching using regular expression. I the table, I have 2 columns A and B
A has value 'A499BPAU4A32A386KBCZ4C13C41D20E'
B has value like '*CZ4*M11*7NQ+RDR+RSM-R9A-R9B'
the requirement is that I have to match the columns of B in A. If there is a value with * sign, this must be present in A like 'CZ4' should exit in string A.
The issue I am facing is that there are 2 values with * sign. The code works fine for first match (CZ4) but it does not look further as M11 does not exist in A.
I used the condition
AND instr(A,substr(REGEXP_SUBSTR(B, '*[^*]{3}'),2) ,1)=0
First of all, is this possible to match multiple patterns in one condition?
If yes, please suggest.
Thanksuser2544469 wrote:
Thanks a lot Frank. This query worked wonderful for the test data I have provided however I have some concerns:
- query doesnot include the column BOOK which is a mandatory check.Sorry, that was my mistake. It was a very easy mistake to make, since you posted sample data where it didn't matter. Instead of doing a cross-join between vn and got_must_have_cnt, do an inner join, using book. That means book will have to be in got_must_have_cnt, and all the sub-queries from which it descends. Look for comments that say "March 22".
If you want to treat '+' in test_cat.codes as '*', then the simplest thing is probably just to use REPLACE, so that when the table has '+', you use '*' instead.
WITH got_token_cnt AS
SELECT cat
, book -- Added March 22
, REPLACE (codes, '+', '*') AS codes -- If desired. Changed March 22
, LENGTH (codes) - LENGTH ( TRANSLATE ( codes
, 'x*+-'
, 'x'
) AS token_cnt
FROM test_cat
, cntr AS
SELECT LEVEL AS n
FROM ( SELECT MAX (token_cnt) AS max_token_cnt
FROM got_token_cnt
CONNECT BY LEVEL <= max_token_cnt
, got_tokens AS
SELECT t.cat
, t.book -- Added March 22
, REGEXP_SUBSTR ( t.codes
, '[*+-]'
, 1
, c.n
) AS token_type
, SUBSTR ( REGEXP_SUBSTR ( t.codes
, '[*+-][^*+-]*'
, 1
, c.n
, 2
) AS token
FROM got_token_cnt t
JOIN cntr c ON c.n <= t.token_cnt
, got_must_have_cnt AS
SELECT cat, book -- Changed March 22
, COUNT (CASE WHEN token_type = '*' THEN 1 END) AS must_have_cnt
FROM got_tokens
GROUP BY cat, book -- Changed March 22
SELECT mh.cat
, vn.vn_no
FROM got_must_have_cnt mh
JOIN vn ON mh.book = vn.book -- Changed March 22
LEFT OUTER JOIN got_tokens gt ON mh.cat = gt.cat
AND INSTR (vn.codes, gt.token) > 1
GROUP BY mh.cat
, mh.must_have_cnt
, vn.vn_no
HAVING COUNT (CASE WHEN gt.token_type = '*' THEN 1 END) = mh.must_have_cnt
AND COUNT (CASE WHEN gt.token_type = '-' THEN 1 END) = 0
ORDER BY mh.cat
- query is very slow with 60000 records in vn table. Cost is somewhere around 36000.See these threads:
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
Relational databases were designed to have (at most) one piece of information in each column. If you decide to have multiple items in the same column (as you have a variable number of tokens in the codes column), don't be surprised if that makes things slower and more complicated. Most of the query I posted, and perhaps most of the time needed, is jsut to normalize the data. If you stored the data in a narmalized form, perhaps something like got_tokens, then you wouldn't need the first 3 sub-queries that I posted.
Edited by: Frank Kulash on Mar 22, 2011 12:04 PM -
I have to check for a pattern match from port 2 and based on this trigger I have to write onto port 3(buffered) as fast as possible. So there needs to be a buffered O/P from port 3. How to code such that the pattern match trigger from port 2 triggers the trigger config.vi for port 3?
Bheem,
Unfortunately, you can not share the start trigger with another operation when using the pattern match operation as a trigger. The only way to share a start trigger is if you are triggering on the rising or falling edge of a digital signal. This is a limitation of using the pattern match operation as a start trigger.
Regards,
Todd D.
NI Applications Engineer -
Problem while using color pattern matching
Currently we are doing projects on real time object tracking where we found one doubt that irrespective of the object size whether this color pattern match works or not . My questions are as follows:
1. Whether it is applicable for objects moving far . Because as it moves far, the size of the object decreases such that the color pattern matching is not working what will be solution since we must use color image
2. What is the difference in using scale and rotate invarient in color pattern matching
3. How we can effectively decrease the ROI depending upon the object position as per below attached screen shots .
we have removed boundary box values of X and Y coordinates at the four corner but we can't track as the object moves far away or we can't decrease the ROI as the object moves far.
4. whether it is possible to see the value of particular pixel in LABVIEW vision development module as we seen only the coordinate position . whether it is applicable to see particular pixel value. Guide us
please, see the below screen shots and provide the solution how effectively decrease or increase the ROI depending on objects position using color pattern match
Attachments:
problem in matching while object moves far.png 515 KBHello,
I have not been using the color pattern matching a lot (especially not in real-time). But since the pattern matching considers only small scale changes, you could try updating the color template every n-th iteration (depending on your setup and requirements). The major problem is the template size, since the color pattern matching tends to take quite a lot of time in learning the template. You would of course need to come up with some idea on how to change the subimage size, where the new template will be learned.
This is the part of coarse (rough) object detection as was suggested by MoviJOHN. For example, if your object is distinctly red, you can extract the green channel from your rgb image and use threshold to roughly find the object and apply the new ROI - template.
So:
1. learn the template,
2. use pattern matching with bounding rectangle (ROI) for the next couple of frames (you would need to experiment here where the detection fails -> how fast can you move the object away so that the detection fails),
3. Before the detection fails -> rough object detection with some padded bounding rectangle (new ROI),
4. Re-learn te template of new ROI and go back to 2.
Again, the biggest issue is the template learning time - if you have a high resolution camera and the template is large, this won't satisfy your real-time application.
You should set up the appropriate illumination first. The resolution is also important, since your object is moved back and forth (but the resolution will have a direct impact on the template learning time).
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." -
Hello! I'm a student and I'm currently making a project using pattern matching.
My patterns are from chick foot/feet.
I'm created multiple pattern matching VI's to detect all the feet because I find it difficult/impossible to match all the feet with a single pattern/template.
However, when using multiple pattern matching VI's some pattern matches detect the same foot, hence overlapping.
So how can I make the overlaping pattern matches to be counted as one?
Thank you in advanceThank you for replying Sir Zwired1.
I'm still a newbie in using LabVIEW so pardon me if I can't understand fully
The objective of my project is to detect all the feet through pattern matching and count the pattern matches made.
"Keep a 2D array of counts, initialized to zero and the same size as your array of possible locations, and increment the value every time you get a match. If multiple pattern matching attempts result in a match a given location in your count array might be "3" but all you care about is if the number is greater than zero."
I'm sorry, but how do you do this? BTW, I'm using vision assistant. -
Trouble using a pattern match in the GO URL when the value starts with %
Hi guys,
We are trying to use a Go URL as follows:
[http://hostname.com:9704/analytics/saw.dll?Go&Path=/users/administrator/Test/TestReport&Action=Navigate&col1=TestReport.SUBJECT&op1=like&val1="%25D8D8%25"|http://hostname.com:9704/analytics/saw.dll?Go&Path=/users/administrator/Test/TestReport&Action=Navigate&col1=TestReport.SUBJECT&op1=like&val1="%25D8D8%25"]
Basically, we want to send the filter : SUBJECT like '%D8D8%' in the GoURL. However, the report that opens up does not fetch any rows because BI somehow messes up the clause by not recognizing the leading %25 (which is an escaped % character). Instead it resolves the %25D8D8%25 into something like �D8% .
As you can see, the %25 at the end however gets resolved correctly but somehow the one at the beginning gets clubbed with the leading D8 to give �.
Any idea, how to get BI to accept a leading escaped % character when doing a pattern match in the Go URL?I'm heading to the Apple Store in Danbury CT tomorrow to test out a MacBook Pro. I'll happily post what I like and dislike here.
Waiting for a MacBook Pro... Other OS -
Hey all,
I would like to know how can I read a template´s information to know if it is a pattern macthing or a geometric matching template?
In my code, users provide templates and the algorithm must match them using pattern matching or geometric matching depending on the template.
At the moment I am doing it by including a P or a G in the name of the file, but I would like to avoid this and read the information from the file.
Any ideas?
Thanks in advance,
Esteban
Solved!
Go to Solution.Hey Esteban,
you can use the VI "IMAQ Is Vision Info Present 2 VI" to reice the information:
IMAQ Is Vision Info Present 2 VI - NI Vision 2011 for LabVIEW Help - National Instruments
http://zone.ni.com/reference/en-XX/help/370281P-01/imaqvision/imaq_is_vision_info_present_2/
Take a look at the attached VI
Stephan
Attachments:
Determine Pattern type.zip 13 KB -
OBIEE 11G : Remove label (is like pattern match) in the prompt
Hi Experts,
I have Gone through this thread Re: OBIEE 11G : Remove label (is like pattern match) in the prompt and applied JS as mentioed but
It works for the first display of the page but its back as soon as you hit the apply button
can be it be removed permanently? Thanks in AdvanceHi Nagen,
You can try the following:
Create a variable prompt with the column vales that you want to match
Create a filter in the analysis criteria tab on the column, set to pick up the variable, and define the IS LIKE here.
It is effectively doing the same task as the standard prompt approach does, but in a round-a-bout way which doesn't include adding any of Oracle's text in. -
What I want to do is , have two images on image displays and the pass them through the same setup as the pattern matching example to get the number of matches , I have attached what I have done and also given the pattern matching example program as well.
Hope to get answers back soon,
Thanks Alan
Attachments:
screenshot.docx 48 KB
Pattern Matching Example.vi 100 KBHi there!
The example used can be adapted for comparing two images, however the algorithm and coding for finding the differences is more specific to your actual problem. In terms of the loading and displaying of the images, this can be done in the same way.
Once you have some sort of algorithm, then you can automate the learning and matching by simply wiring them in order. (in the example, these are put in case structures as they are waiting on response from the front panel)
I hope that this helps,
Liam A.
National Instruments
Applications Engineer -
Regular Expressions (Pattern/Matcher) --- Help
Hi,
I have an regex i.e. Pattern.compile("([0-9])D([0-9])'?(?:([0-9]+)\")?([NSEW])").{code}
It has to exactly match the input e.g *45D15'34"N*
I need to retrieve the values based on grouping.
Group1 = 45 (degree value)
Group2 = 15 (minutes value)
Group3 = 34 (seconds value) ----> this is a non-capturing group
Group4 = N (directions)
The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507
According to the bug report, they have said that are many different regex that can trigger the stack overflow....even though the length of my input is not as long as the one posted on the bug report.
I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
Thank you in advanceHi,
I missed the '+' in my original regex Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])"){code}.
I have also tried {code} Pattern.compile("(\\d+)D(\\d+)'?(?:(\\d+)\")?([NSEW])");And, the other 2 expressions as suggested by you.
The problem happens when Durham Lat=35D52N Lon=78D47W value is selected from a Jtree(the values are parsed from a xml file to the tree - the xml file has a bout 800 longitude/latitude elements for different cities in the US). It does not happen for other values and If I increment the degree or min by, then the expression works. I am not sure how else i could re-write this exp.
Below is the snippet of the xml file:
<State name="NORTH CAROLINA">
<City name="Asheville AP" Lat="35D26'N" Lon="82D32'W"/>
<City name="Charlotte AP" Lat="35D13'N" Lon="80D56'W"/>
<City name="Durham" Lat="35D52'N" Lon="78D47'W"/>
<City name="Elizabeth City AP" Lat="36D16'N" Lon="76D11'W"/>
<City name="Fayetteville, Pope AFB" Lat="35D10'N" Lon="79D01'W"/>
<City name="Goldsboro,Seymour-Johnson" Lat="35D20'N" Lon="77D58'W"/>
<City name="Greensboro AP (S)" Lat="36D05'N" Lon="79D57'W"/>
<City name="Greenville" Lat="35D37'N" Lon="77D25'W"/>
<City name="Henderson" Lat="36D22'N" Lon="78D25'W"/>
<City name="Hickory" Lat="35D45'N" Lon="81D23'W"/>
<City name="Jacksonville" Lat="34D50'N" Lon="77D37'W"/>
<City name="Lumberton" Lat="34D37'N" Lon="79D04'W"/>
<City name="New Bern AP" Lat="35D05'N" Lon="77D03'W"/>
<City name="Raleigh/Durham AP (S)" Lat="35D52'N" Lon="78D47'W"/>
<City name="Rocky Mount" Lat="35D58'N" Lon="77D48'W"/>
<City name="Wilmington AP" Lat="34D16'N" Lon="77D55'W"/>
<City name="Winston-Salem AP" Lat="36D08'N" Lon="80D13'W"/>
</State>
public final class GeoLine {
/* Enum for the possible directions of longitude and latitude*/
public enum Direction {
N, S, E, W;
public boolean isLongitude() {
return (this == E || this == W);
public boolean isLatitude() {
return (this == N || this == S);
public Direction getCanonicalDirection() {
if (this == S) {
return Direction.N;
} else if (this == W) {
return Direction.E;
} else {
return this;
private final int degree;
private final int minute;
private final int second;
private final Direction dir;
/* Recognizes longitude and latitude values that has degrees, minutes and seconds i.e. "45D15'34"N
* or "45D1534"N. The single-quotes for the minutes is optional. And, for the moment we do not support seconds
* validation although ilog library returns the longitude/latitude with second when NEs and Sub-networks are
* dragged and dropped on the map.*/
private static final Pattern PATTERN = Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])");
public GeoLine(int degree, int minute, Direction dir) {
this(degree, minute, 0, dir);
public GeoLine(int degree, int minute, int second, Direction dir) {
Log.logInfo(getClass().getSimpleName(), "PAU degree: " + degree + " minute: " + minute + " second: " + second + " direction: " + dir);
verifyLongitudeLatitude(degree, dir);
verifyMinute(degree, minute, dir);
this.degree = degree;
this.minute = minute;
this.second = second;
if (this.degree == 0 && this.minute == 0 && this.second == 0) {
this.dir = dir.getCanonicalDirection();
} else {
this.dir = dir;
public Direction getDirection() {
return dir;
public int getMinute() {
return minute;
public int getDegree() {
return degree;
public int getSecond() {
return second;
public static GeoLine parseLine(String location) {
* Matcher class will throw java.lang.NullPointerException if a null location
* is passed, null location validation is not needed.
Matcher m = PATTERN.matcher(location);
if(m.matches()) {
int deg;
int min;
int second;
Direction direction;
deg = Integer.parseInt(m.group(1));
min = Integer.parseInt(m.group(2));
if (m.group(3) == null) {
second = 0;
} else {
second = Integer.parseInt(m.group(3));
direction = Direction.valueOf(m.group(4));
return new GeoLine(deg, min, second, direction);
} else {
throw new IllegalArgumentException("Invalid location value. Expected format XXDXX'XX\"[NSEW] " + location);
private void verifyMinute(int deg, int min, Direction direction) {
/* This validation is to make sure that minute does not exceed 0 if maximum value for latitude == 90
* or longitude == 180 is specified */
int maxDeg = direction.isLatitude() ? 90 : 180;
if(min < 0 || min > 59) {
throw new NumberFormatException("Minutes is out of range. Value should be less than 60: " + min);
if (deg == maxDeg && min > 0) {
throw new NumberFormatException("Degree value " + deg + "D" + direction + " cannot have minute exceeding 0: " + min);
private void verifyLongitudeLatitude(int valDeg, Direction valDir) {
int max = valDir.isLatitude() ? 90 : 180;
if(valDeg < 0 || valDeg > max) {
throw new NumberFormatException("Degree " + valDeg + valDir + " is invalid");
public final boolean isLongitude() {
return dir.isLongitude();
public final boolean isLatitude() {
return dir.isLatitude();
@Override
public final String toString(){
if(minute < 10){
return degree + "D0" + minute + dir;
} else {
return degree + "D" + minute + dir;
@Override
public boolean equals(Object obj) {
if (obj instanceof GeoLine) {
GeoLine other = (GeoLine) obj;
return (this.degree == other.degree && this.minute == other.minute && this.second == other.second && this.dir == other.dir);
return false;
@Override
public int hashCode() {
int result = 17;
result = result * 37 + degree;
result = result * 37 + minute;
result = result * 37 + second;
result = result * 37 + dir.hashCode();
return result;
}Thank you again. -
Hi all,
After Cloning facing an issue
mod_security: Access denied with code 405. Pattern match "!(GET|HEAD|POST)"
and not able to get the login prompt
EBS: 12.1.3
DB:11G
Please help as this is urgent.
Regards,
Raj.Hi Hussein/Srini,
My OS details are as follows
Source OS : OE Linux 5X
Target : REHL
DB : 11.2.0.3
In my previous cloning the R12 login URL was not getting redirected to https from http. This backup was given by client last week and I completed the cloning and post cloning procedures without any error, but unable to login as the page is redirecting to https:/hostname:port/OA_HTML/AppsLogin.
I have done the following so far, but the issue is not getting resolved.
1) Generated JAR files using ADADMIN (Force)
2) Compiled JSP
3) Ran autoconfig multiple times without any error in both db and application tiers.
4) DB alert log did not have any error.
5) Executed relink all from APPL_TOP
6) Able to launch http://XXXXXXXXX:XXXX/forms/frmservlet?
Kindly help me out on this
Regards
Maybe you are looking for
-
Cannot connect to the Internet, help?
All of a sudden my connectivity to the Internet has dropped, when I try to connect to any source (ie. WiFi, ethernet, or Bluetooth via my phone) I get the same message: Wi-Fi has the self-assigned IP address xxx.xxx.xxx.xxx and will not be able to co
-
Message while printing POR swiss payoment form Output cannot be redirected to this printer (see long text) Message no. TD366 Diagnosis You tried to output a SAPscript spool request to an output device to which another device type is assigned than tha
-
hi i am having problem of connecting my iphone5 to my labtop, now i am bwosing on my pc by connecting my iphone but at the time of updating ios7.04, i get massage. ur internet connection or interne
-
How can i open the directory/folder and read all the files inside it in order and then close it? any example would be nice. thanks
-
Hello I bought a macbook pro on August this year and got a bonus to upgrade the OS from Lion to Mountain Lion for free. I started the donwload but it was interrupted due to internet failure so the upgrade process was aborted. When I tried to initiate