ADR Templates How to use them?

Example requests & Code samples for GdPicture Toolkits.
Post Reply
Bnorfolk
Posts: 6
Joined: Fri Oct 10, 2008 4:10 pm

ADR Templates How to use them?

Post by Bnorfolk » Fri Mar 13, 2009 6:17 pm

Would like to use the ADR Template function, how can I get some documentation on the feature?

Template Config
object.ADRStartNewTemplateConfig () ?
object.ADRSaveTemplateConfig (sFileConfig) ?
object.ADRLoadTemplateConfig (sFileConfig) ?
object.ADRAddImageToTemplate (nTemplateID, nImageID) ?

How do they work together?

1 Do I start a New TemplateConfig
2 Add All my Templates
3 Save the Templates
4 Load the templates when I want to compare it to the scan Image?

I have look at the example on line and it just read the template from the file then compares it to another file.
But, it has no examples with using the Template config.

please help me understand it seems like a great feature, just don't understand how to us it.

Thank you Bill

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: ADR Templates How to use them?

Post by Loïc » Sat Mar 14, 2009 11:09 am

Hi Bill,
how can I get some documentation on the feature?
On the reference guide of your toolkit: https://www.gdpicture.com/guides/gdpicture
How do they work together?

1 Do I start a New TemplateConfig
2 Add All my Templates
3 Save the Templates
4 Load the templates when I want to compare it to the scan Image?
Yes, more exactly:

1 - Starting a new template configuration

Code: Select all

Imaging1.ADRStartNewTemplateConfig
2 - Adding templates - I give you an example to create 2 templates based on 4 images (2 invoices of company A for first template, and 2 invoices of company B for the second template).

Code: Select all

'Creating our first template related to invoices of company A
TemplateID1 = Imaging1.ADRCreateTemplateEmpty
Status = Imaging1.ADRSetTemplateTag(TemplateID1, "Invoice of companyA")

'Adding first invoice of company A to our first template
Invoice1CompanyA = Imaging1.CreateImageFromFile("Invoice1CompanyA.tif")
Status = Imaging1.ADRAddImageToTemplate(TenplateID1, Invoice1CompanyA)
Imaging1.CloseImage (Invoice1CompanyA)
'Adding second invoice of company A to our first template
Invoice2CompanyA = Imaging1.CreateImageFromFile("Invoice2CompanyA.tif")
Status = Imaging1.ADRAddImageToTemplate(TenplateID1, Invoice2CompanyA)
Imaging1.CloseImage (Invoice2CompanyA)


'Creating our second template related to invoices of company B
TemplateID2 = Imaging1.ADRCreateTemplateEmpty
Status = Imaging1.ADRSetTemplateTag(TemplateID1, "Invoice of companyB")

'Adding first invoice of company B to our first template
Invoice1CompanyA = Imaging1.CreateImageFromFile("Invoice1CompanyB.tif")
Status = Imaging1.ADRAddImageToTemplate(TenplateID1, Invoice1CompanyB)
Imaging1.CloseImage (Invoice1CompanyB)
'Adding second invoice of company B to our first template
Invoice2CompanyA = Imaging1.CreateImageFromFile("Invoice2CompanyB.tif")
Status = Imaging1.ADRAddImageToTemplate(TenplateID1, Invoice2CompanyB)
Imaging1.CloseImage (Invoice2CompanyB)
- 3 Saving the configuration for a later usage

Code: Select all

'Saving configuration
Status = Imaging1.ADRSaveTemplateConfig("templateconfig.t")

'Releasing configuration data form memory
Imaging1.ADRDeleteTemplate (TemplateID1)
Imaging1.ADRDeleteTemplate (TemplateID2)
- 4 Later, you will be able to reload the saved configuration to make a document recognition process

Code: Select all

'Loading configuration
Imaging1.ADRLoadTemplateConfig ("templateconfig.t")

'Making a document recognition process on an invoice -> Company A or Company B ?

Invoice = Imaging1.CreateImageFromFile("whatisthisinvoice.tif")
InvoiceTemplate = Imaging1.ADRGetCloserTemplateForGdPictureImage(Invoice)
Imaging1.CloseImage (Invoice) ' Dont forget to close each loaded image to avoid memory leak

'Retrieving the recognition result
MsgBox "The template ID is: " & Str(InvoiceTemplate)
MsgBox "The template Tag is: " & Str(Imaging1.ADRGetTemplateTag(InvoiceTemplate))
MsgBox "The relevance of the identification is: " & Str(Imaging1.ADRGetLastRelevance) & " %"

Hope this helps, let me know if you need more information.

Kind regards,

Loïc

User avatar
kketterman
Posts: 32
Joined: Tue Apr 21, 2009 6:55 pm

Re: ADR Templates How to use them?

Post by kketterman » Fri Apr 24, 2009 8:25 pm

Hello,
I'm trying to use this in the GdPicture.NET and it seems to be failing at adding documents to the template.
The status message is OK even after the fail.

Code: Select all

Private Sub StartNewTemplate()
        'resets the template configs
        oImage.ADRStartNewTemplateConfig()
    End Sub
    Private Sub setupTemplates()
        'Creating our first template related to invoices of company A
        TemplateID1 = oImage.ADRCreateTemplateEmpty
        Status = oImage.ADRSetTemplateTag(TemplateID1, "Invoice of companyA")
        
        'Adding first invoice of company A to our first template
        Invoice1CompanyA = oImage.CreateGdPictureImageFromFile("image005.tif")
        Status = oImage.ADRAddGdPictureImageToTemplate(TemplateID1, Invoice1CompanyA)
        oImage.ReleaseGdPictureImage(Invoice1CompanyA)
        
        'Adding second invoice of company A to our first template
        Invoice2CompanyA = oImage.CreateGdPictureImageFromFile("image005b.tif")
        Status = oImage.ADRAddGdPictureImageToTemplate(TemplateID1, Invoice2CompanyA)
        oImage.ReleaseGdPictureImage(Invoice2CompanyA)
        

        'Creating our second template related to invoices of company B
        TemplateID2 = oImage.ADRCreateTemplateEmpty
        Status = oImage.ADRSetTemplateTag(TemplateID1, "Invoice of companyB")
        
        'Adding first invoice of company B to our first template
        Invoice1CompanyA = oImage.CreateGdPictureImageFromFile("image005c.tif")
        Status = oImage.ADRAddGdPictureImageToTemplate(TemplateID1, Invoice1CompanyB)
        oImage.ReleaseGdPictureImage(Invoice1CompanyB)
        
        'Adding second invoice of company B to our first template
        Invoice2CompanyA = oImage.CreateGdPictureImageFromFile("image005d.tif")
        Status = oImage.ADRAddGdPictureImageToTemplate(TemplateID1, Invoice2CompanyB)
        oImage.ReleaseGdPictureImage(Invoice2CompanyB)
        
    End Sub
    Private Sub saveTemplate()
        Status = oImage.ADRSaveTemplateConfig("template.t")
        'Saving configuration
        
        'Releasing configuration data form memory
        oImage.ADRDeleteTemplate(TemplateID1)
        oImage.ADRDeleteTemplate(TemplateID2)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        StartNewTemplate()
        Timer1.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        setupTemplates()
    End Sub
    Private Sub recog()
        'Making a document recognition process on an invoice -> Company A or Company B ?

        Invoice = oImage.CreateGdPictureImageFromFile("image005.tif")
        InvoiceTemplate = oImage.ADRGetCloserTemplateForGdPictureImage(Invoice)
        oImage.ReleaseGdPictureImage(Invoice) ' Dont forget to close each loaded image to avoid memory leak
    End Sub
    
    Private Sub getResults()
        'Retrieving the recognition result
        MsgBox("The template ID is: " & Str(InvoiceTemplate))
        MsgBox("The template Tag is: " & Str(oImage.ADRGetTemplateTag(InvoiceTemplate)))
        MsgBox("The relevance of the identification is: " & Str(oImage.ADRGetLastConfidence) & " %")
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        recog()
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        getResults()
    End Sub
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        'Loading configuration
        oImage.ADRLoadTemplateConfig("template.t")
    End Sub
Status = oImage.ADRAddGdPictureImageToTemplate(TemplateID1, Invoice1CompanyA) is returning false.

User avatar
kketterman
Posts: 32
Joined: Tue Apr 21, 2009 6:55 pm

Re: ADR Templates How to use them?

Post by kketterman » Fri Apr 24, 2009 10:21 pm

Are there plans of implementing a pdf to gdimage method?

I would like to use PDF files in association with the ADR.

I am currently trying to convert pdf to multipage tiff and then create templates base on those.

Thanks.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: ADR Templates How to use them?

Post by Loïc » Mon Apr 27, 2009 11:34 am

Hi,

This feature is already implemented. See this thread: viewtopic.php?t=314
Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest