ADR Issues with 6.4

Discussions about Automatic Document Recognition in GdPicture.NET.
Post Reply
susanth
Posts: 2
Joined: Wed Dec 02, 2009 11:49 am

ADR Issues with 6.4

Post by susanth » Wed Dec 02, 2009 12:02 pm

I recently upgraded from 6.3 to 6.4 (6.3.0.4 to 6.4.0.10 of GDPicture.Net.dll). In 6.3 ADR used to work beautifully, but the same code compiled with 6.4 doesn't give the same confidence level. If I use the exact image as that of the template, ADRGetLastConfidence() method returns a confidence value of only 44%. With version 6.3, ADRGetLastConfidence() used to return 100%.

Is this an intentional change? Or is it a bug? ::bug::

Susanth

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

Re: ADR Issues with 6.4

Post by Loïc » Wed Dec 02, 2009 4:08 pm

Hi,

Strange behavior. Could you try to update to GdPicture.NET 6.5 ?

If your problem persists, please attach your image used as template and give us some code you are using to retrieve confidence.

With best regards,

Loïc

susanth
Posts: 2
Joined: Wed Dec 02, 2009 11:49 am

Re: ADR Issues with 6.4

Post by susanth » Fri Dec 04, 2009 9:18 am

Hi,

I just upgraded to 6.5, but the problem persists. Please find the code used to create the template as well as to do ADR. I get confidence only between 40 and 60 for the exact same image (actually the exact same ImageID) only. It is not image specific. I tried with many imaged. The same code used to give confidence level of 100 with version 6.3.

I was using .Net 2.0. Tried the same code with .Net 3.5 as well. Same behaviour.

I would appreciate any help here.

Susanth

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;
using GdPicture;
using System.Drawing.Drawing2D;

namespace iRead
{
    public partial class iReadForm : Form
    {
        private GdPictureImaging m_GdImaging = new GdPictureImaging();
        private int m_ImageID = 0;

        public iReadForm()
        {
            InitializeComponent();
            m_GdImaging.SetLicenseNumber("my license number");
        }

        private void iReadForm_Load(object sender, EventArgs e)
        {
            m_ImageID = m_GdImaging.CreateGdPictureImageFromFile("c:\\sample.tif");
        }

        private void CreateTemplate()
        {
            int nBits = m_GdImaging.GetBitDepth(m_ImageID);
            TiffCompression tc = TiffCompression.TiffCompressionJPEG;
            switch (nBits)
            {
                case 1: tc = TiffCompression.TiffCompressionCCITT4; break;
                default: tc = TiffCompression.TiffCompressionLZW; break;
            }

            string strTempID = Guid.NewGuid().ToString();
            string templateFile = GetApplicationDirectory() + "Templates\\" + "templateconfig.t";
            if (File.Exists(templateFile))
            {
                m_GdImaging.ADRLoadTemplateConfig(templateFile);
            }
            else
            {
                m_GdImaging.ADRStartNewTemplateConfig();
            }

            if (!Directory.Exists(GetApplicationDirectory() + "Templates\\" + strTempID))
                Directory.CreateDirectory(GetApplicationDirectory() + "Templates\\" + strTempID);

            int TemplateID = m_GdImaging.ADRCreateTemplateEmpty();
            string strSampleFullPath = GetApplicationDirectory() + "Templates\\" + strTempID + "\\" + Convert.ToString(TemplateID) + ".tif";
            m_GdImaging.SaveAsTIFF(m_ImageID, strSampleFullPath, tc);

            bool bStatus = m_GdImaging.ADRSetTemplateTag(TemplateID, strTempID);
            m_GdImaging.ADRAddGdPictureImageToTemplate(TemplateID, m_ImageID);

            bStatus = m_GdImaging.ADRSaveTemplateConfig(templateFile);
            m_GdImaging.ADRDeleteTemplate(TemplateID);
        }

        private void ADRButton_Click(object sender, EventArgs e)
        {
            try
            {
                string templateFile = GetApplicationDirectory() + "Templates\\" + "templateconfig.t";
                m_GdImaging.ADRLoadTemplateConfig(templateFile);
                int count = m_GdImaging.ADRGetTemplateCount();
                int template = m_GdImaging.ADRGetCloserTemplateForGdPictureImage(m_ImageID);
                m_GdImaging.ReleaseGdPictureImage(m_ImageID);

                string strTempTag = m_GdImaging.ADRGetTemplateTag(template);
                double confLevel = m_GdImaging.ADRGetLastConfidence();

                string strMessage = "Template : " + template + "\n" +
                                    "Tag : " + strTempTag + "\n" +
                                    "Confidence : " + confLevel + "%";
                MessageBox.Show(strMessage);
            }
            catch (Exception ex)
            {
            }
        }
    }
}

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

Re: ADR Issues with 6.4

Post by Loïc » Fri Dec 04, 2009 11:49 am

Hi Susanth,

I was unable to run your code "as is"

Please, create a standalone application or a simple code file without reference to other objects.

Also, I really need on of your image file for test.

Kind regards,

Loïc

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

Re: ADR Issues with 6.4

Post by Loïc » Fri Dec 04, 2009 12:17 pm

Hi again,

After other investigation we found a stupid bug in the ADR engine :oops:

The problem will be fixed in next minor release.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 0 guests