12-18-2008 09:13 AM - edited 12-18-2008 09:18 AM
hi,
i have a created a Geometric Template in my C#-Application.
Now i want to give this Template the necessary options
The current problem is that i get no error message when i save the template with the vision infos, but when i use it to search a picture, the template isn't found.
this is my method (i know it's a bit much code, but i don't know what you need):
i hope somebody can help me
12-18-2008 10:44 AM
Im creating an application using c# also, maybe I can help you. Sometimes its a pain to use the VB.net examples as a reference coz some function parameters in VB.net cant be of the same signature in C#...especially when C# forces you to use out and ref keywords. VisualStudios intellisence is of great help for me...
Anyways, Whats the error message your getting?
Did you use the ReadImageAndVisionInfo function before using the template?
Riscoh
01-04-2009 01:47 PM
hallo,
first happy new year and sorry that i'm a bit late to respond, but i wasn't here over the holidays.
So to the error-message i get:
"invalid geometric matching template image."
But i don't understand why.
In my oppinion i have set all the right template options....
And yes: i used ReadImageAndVisionInfo to load the Template File into the program.
kumi
01-04-2009 07:22 PM
I have encountered the same error message with color pattern matching and it turns out the images are not of the same type.
LearnGeometricPattern and MatchGeometricPattern uses U8 images as per imaq help file might wanna double check.
Riscoh
01-15-2009 10:33 AM
thanks for the advice.
i tried it with this function:
Create_Viewer_Template.Image.Type = CWIMAQImageTypes.cwimaqImageTypeU8;
but i don't know where to use it.
i tried it in the method
- when i save the template
- when i load the picture from which the template is made
- when i extract the template in another viewer
where have you put it?
01-15-2009 12:02 PM
MatchGeometricPattern Method
You also have to change the image type of the image you are tying to inspect not just the template
SearchImage.Type = CWIMAQImageTypes.cwimaqImageTypeU8
CWIMAQVision.MatchGeometricPattern(SearchImage, Template, MatchGeometricOptions, GeometricPatternMatchReport , Regions)
If the image you are trying to inspect is already loaded onto the viewer you can change the type like this
viewer.Image.Type = CWIMAQImageTypes.cwimaqImageTypeU8 before calling the MatchGeometricPattern function
It would be better to post your code where you have the MatchGeometricPattern function so I could try and figure out whats going on with your code....
01-16-2009 06:48 AM
i´ve tried your advice but it didn't worked ![]()
here is my code (i put the whole method here, don't know what is really important for you):
---------------------------------------------------------------
private void MatchTemplate_Click(object sender, EventArgs e)
{
Match_Viewer_Picture.Regions.RemoveAll();
CWIMAQMatchGeometricPatternOptions MatchOptions = new CWIMAQMatchGeometricPatternOptions();
CWIMAQGeometricPatternMatchReport MatchReport = new CWIMAQGeometricPatternMatchReport();
CWIMAQRegions Regions = new CWIMAQRegions();
MatchOptions.CurveOptions.ExtractionMode = CWIMAQExtractionModes.cwimaqExtractionModeUniformRegions;
MatchOptions.CurveOptions.FilterSize = CWIMAQEdgeFilterSizes.cwimaqEdgeFilterNormal;
MatchOptions.MinimumMatchScore = (float)System.Convert.ToSingle(MinMatchScore.Value);
MatchOptions.NumMatchesRequested = (int)System.Convert.ToSingle(MinNrMatches.Value);
if( Occlusion.Checked)
MatchOptions.MatchMode = CWIMAQGeometricMatchModes.cwimaqGeometricMatchOcclusionInvariant;
if (Rotation.Checked)
{
MatchOptions.MatchMode = CWIMAQGeometricMatchModes.cwimaqGeometricMatchRotationInvariant;
MatchOptions.RotationAngleRanges.Add(1);
MatchOptions.RotationAngleRanges.Initialize((int)System.Convert.ToSingle(RotatedMin.Value), (int)System.Convert.ToSingle(RotatedMax.Value));
}
if (Scale.Checked)
{
MatchOptions.MatchMode = CWIMAQGeometricMatchModes.cwimaqGeometricMatchScaleInvariant;
MatchOptions.ScaleRange.Min = (int)System.Convert.ToSingle(ScaledMin.Value);
MatchOptions.ScaleRange.Max = (int)System.Convert.ToSingle(ScaledMax.Value);
}
Match_Viewer_Template.Image.Type = CWIMAQImageTypes.cwimaqImageTypeU8;
Match_Viewer_Picture.Image.Type = CWIMAQImageTypes.cwimaqImageTypeU8;
try
{
axCWIMAQVision1.MatchGeometricPattern(Match_Viewer_Picture.Image, Match_Viewer_Template.Image, MatchOptions, MatchReport, Regions);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Match_Viewer_Picture.Image.Overlays.Item(1).Clear();
for (int i = 0; i < MatchReport.Count; i++)
DrawGeometricPatternMatch(Match_Viewer_Picture.Image.Overlays.Item(1), MatchReport.Item(i+1), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LawnGreen));
MatchesFound.Text = (String)System.Convert.ToString(MatchReport.Count);
}
-------------------------------------------------
kumi
01-16-2009 12:41 PM
Could you also post the images(template and the image to be inspected) I'll try and create an application to see if we get the same result...
Match_Viewer_Picture.Regions.RemoveAll();
The only potential problem I see on the code is there are no regions although you defined a CWIMAQRegions object but it doesnt contain any CWIMAQRegion object. CWIMAQRegions object must contain exactly one rectangle or one rotated rectangle region as per help file...
But I doubt if you would get this "invalid geometric matching template image." error message if there arre no regions defined.
Riscoh
01-17-2009 06:24 AM
01-17-2009 06:17 PM
Ive tested the images on Vision assitant and the template didnt work I created a new template using the default values and it worked right away
You get this "invalid geometric matching template image." error message when you try to inspect an image using a template that does not contain enough features for geometric matching...
try use the template Ive used and see what happens... Also I would suggest to just use pattern matching for this application coz I think the results are more repeatable...
and forget about the image type the viewer defaults to U8 images...
Riscoh