FormFix v6.0 for .NET - Updated
Detect Similar Templates before Adding to the Form Set
Developer Guide > How To > Use FormFix > Prevent & Detect Similar Templates > Detect Similar Templates with the Identification Processor > Detect Similar Templates before Adding to the Form Set

In the same way that the Identify method is used to find the best matching templates for an unknown (filled) image, it can also be used to find the matching templates to a candidate template.

For that:

C# Example
Copy Code
FormFix.IdentificationProcessor myIDProc
= new FormFix.IdentificationProcessor(workspace);
// add all of the templates in your form set, to the
// ID processor’s FormModels collection
LoadFormModels(myIDProc);
// configure the identification processor
myIDProc.IdentificationCertainty = 30;
myIDProc.IdentificationQuality = 100;
myIDProc.MaximumIdentificationBestMatches = 3;

Create a FormImage object representing the candidate template image, and then call the Identify method. The state of the returned IdentificationResult should be the first indication of similar templates already in the form set. If the state is NoMatch, then there is a high level of certainty that the candidate template is not too similar to any already in the set. If the state is MatchFound or MultipleMatchesFound, the further processing should be done. At this point a manual human review can be performed, or since identification confidence is available, an automated selection process can be performed.

To automate the review process, a simple method is to threshold the match results based on confidence. To detect presence of similar forms a threshold around 80 should be sufficient. This threshold may be varied depending on the acceptable level of similarity that you wish to be present in the final form set. A slightly higher threshold should be used to detect the presence of identical forms in the image; use a threshold closer to 90.

The code example below demonstrates the concept discussed above.

C# Example
Copy Code
// load the image of the candidate template
System.Drawing.Bitmap candidateTemplateBitmap;
candidateTemplateBitmap = LoadCandidateTemplateImage();
// create a FormImage from the candidate template
using (FormFix.FormImage candidateTemplate = FormFix.FormImage.FromBitmap(candidateTemplateBitmap, workspace))
{
    Accusoft.FormFixSdk.IdentificationResult idResult;

    // perform identification
    idResult = myIDProc.Identify(candidateTemplate);

    // check ID result state
    if (idResult.State == Accusoft.FormFixSdk.IdentificationState.NoMatchFound)
    {
        // there are no similar forms already in the form set
        // continue adding the form to form set
    }
    else
    {
        // there may be similar forms already in the form set
        // we know that there are one or more best matches
        // but we'll go ahead and check the count of best matches
        // incase we forgot to set the value of MaximumIdentificationBestMatches
        if (idResult.BestMatches.Count == 0)
        {
            // the method cannot complete
            // throw exception or return
        }
        // Get the confidence of the best match in the BestMatches collection
        int bestConfidence;
        bestConfidence =
            idResult.GetConfidence(idResult.BestMatches[0].FormModelIndex,
            idResult.BestMatches[0].Orientation);
        // compare the identification confidence
        // of the best matching existing template
        // to the confidence threshold
        if (bestConfidence >= 80)
        {
            // handle the case of a similar
            // template already in the form set
        }
    }
    if (idResult != null)
    {
        idResult.Dispose();
        idResult = null;
    }
}

 

 

Is this page helpful?
Yes No
Thanks for your feedback.