Page 1 of 1

How To Find 2nd Closest Image

Posted: Sat Oct 02, 2010 10:07 am
by PeterH
Two questions:

Is there a way to find the second closest template? Maybe find closest, delete that template, then execute ADRGetCloserTemplate... again?

Did you intend this ADR only to tell apart document types or has it been designed to distinguish, for example, a purchase order from one customer compared to a purchase order from another customer?

Re: How To Find 2nd Closest Image

Posted: Thu Oct 07, 2010 4:25 pm
by Loïc
Hi Peter,
Is there a way to find the second closest template?
Yes, you have to use the ADRGetLastConfidenceFromTemplate() method with all templates and use the 2nd highest value.
Did you intend this ADR only to tell apart document types or has it been designed to distinguish, for example, a purchase order from one customer compared to a purchase order from another customer?
The engine is designed to make distinction between document content. For example, you should be able to distinguish 2 different invoices if these invoices have 2 different logos.

Hope this helps !

loïc

Re: How To Find 2nd Closest Image

Posted: Tue Oct 12, 2010 6:55 pm
by PeterH
Thx. I didn't entirely follow your reply.

Code: Select all

'Now, we will try to identify an image.
nCloserTemplate = oGdPictureImaging.ADRGetCloserTemplateForFile("document.tif")
ADRGetCloserTemplate will always find the closest. Do I have to delete it from the configuration and then repeat the statement to get the 2nd closest?

I don't otherwise understand how to use ADRGetLastConfidenceFromTemplate because that is only returned when a ADRGetCloserTemplate has been executed and that statement will always find the same one each time unless I change the configuration.

Thx

Re: How To Find 2nd Closest Image

Posted: Wed Oct 13, 2010 10:13 am
by Loïc
Hi,

Please find a code snippet demonstrating how to get last confidence for all templates (just 2 in the snippet but you can extend the number).

Code: Select all

        Dim oGdPictureImaging As New GdPicture.GdPictureImaging

        oGdPictureImaging.SetLicenseNumber("XXX")
        Dim ImageID1 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("C:\test.tif")
        Dim TemplateID1 As Integer = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(ImageID1)
        oGdPictureImaging.ReleaseGdPictureImage(ImageID1)
        Dim ImageID2 As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("C:\test2.tif")
        Dim TemplateID2 As Integer = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(ImageID2)
        oGdPictureImaging.ReleaseGdPictureImage(ImageID2)


        Dim ImageIDTest As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("C:\test3.tif")
        oGdPictureImaging.ADRGetCloserTemplateForGdPictureImage(ImageIDTest) 'starts ADR process
        oGdPictureImaging.ReleaseGdPictureImage(ImageIDTest)


        MsgBox("Confidence for TemplateID1 " & Str(oGdPictureImaging.ADRGetLastConfidenceFromTemplate(TemplateID1)))
        MsgBox("Confidence for TemplateID2 " & Str(oGdPictureImaging.ADRGetLastConfidenceFromTemplate(TemplateID2)))

        oGdPictureImaging.ADRDeleteTemplate(TemplateID1)
        oGdPictureImaging.ADRDeleteTemplate(TemplateID2)
Hope this will be a bit more clear !

Kind regards,

Loïc