Zonal OCR Position is off at certain PCs

PDF-X OCR SDK is a New product from us and intended to compliment our existing PDF and Imaging Tools to provide the Developer with an expanding set of professional tools for Optical Character Recognition tasks

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Tracker Supp-Stefan

Post Reply
M P
User
Posts: 2
Joined: Thu Dec 01, 2016 10:42 am

Zonal OCR Position is off at certain PCs

Post by M P » Thu Dec 01, 2016 11:10 am

I use the selection of an Area in the pdf for text recognition, now on most PCs this works but on certain PCs I have the Problem
that not the selected Area is analyzed but the Area slightly above the selection. Now I first expected the DPI settings of the Monitor but this
Seem not the be the reason, I am not shure what is causing the problem.

The user also told me it worked till a certain point in time but now not anymore.

Is there a known issue which can cause the problem, the only thing I found was this:
Also any Ideas what can cause the problem? On the client maschine I already tried to reduce the windows DPI from 125% to 100% but the Problem stayed.
https://www.tracker-software.com/forum3 ... creenPoint

This is my code (C#)
The problem maschine in example is a Windows 10 Maschine.

The Problem can't be the PDF by the way, since I downloaded the PDF the customer had problems with and ony my maschine it worked without problems.

Code: Select all


// first I get the mouse position.
vwr.GetProperty("Notifications.Mouse.Page", out oPage);

           // First I track the mouse position pf start and and end by the Notifications.Mouse event.
           object mouseX = null;
           object mouseY = null;
           _viewer.GetProperty("Notifications.Mouse.x", ref mouseX);
           _viewer.GetProperty("Notifications.Mouse.y", ref mouseY);

       
            // This part of the method translates them into PDF coordinates.
            mouseCoordinates ret = new mouseCoordinates();

            // get the current page
            object oPage = null;
            int iPage;
            vwr.GetProperty("Notifications.Mouse.Page", out oPage);
            iPage = int.Parse(oPage.ToString());
            ret.page = (uint)iPage;

            // translate start mouse coordinates
            int[] cInputStart = new int[2];
            cInputStart[0] = int.Parse(startX.ToString());
            cInputStart[1] = int.Parse(startY.ToString());

            Object cOutStart = new Object();
            vwr.DoDocumentVerb(iDoc, String.Format("Pages[{0}]", iPage.ToString()), "TranslateScreenPoint", cInputStart, out cOutStart, 0);

            ret.startX = ((double[])cOutStart)[0];
            ret.startY = ((double[])cOutStart)[1];

            // get and translate coordinates of act mouse pos
            int[] cInputEnd = new int[2];
            cInputEnd[0] = endX;
            cInputEnd[1] = endY;

            Object cOutEnd = new Object();
            vwr.DoDocumentVerb(iDoc, String.Format("Pages[{0}]", iPage.ToString()), "TranslateScreenPoint", cInputEnd, out cOutEnd, 0);

            ret.endX = ((double[])cOutEnd)[0];
            ret.endY = ((double[])cOutEnd)[1];

            return ret;


            // Running the ocr:

            PDFXOCR_Funcs.PXO_Options options = new PDFXOCR_Funcs.PXO_Options();
            options.blacklist = "";
            options.whitelist = "";
            options.raster_dpi = 600; // DPI for resolution of document after precessing it (less DPIs can make the document ugly)

            // coordinate calculcation of selection rectangle
            double nl, nr, nt, nb;
            nl = Math.Min(ret.startX, ret.endX);
            nr = Math.Max(ret.startX, ret.endX);
            nt = Math.Max(ret.startY, ret.endY);
            nb = Math.Min(ret.startY, ret.endY);

            // Create input field
            // set zone to ocr
            PDFXOCR_Funcs.OCR_NewInputFields(out inFields);
            PDFXOCR_Funcs.PXO_InputField nif = new PDFXOCR_Funcs.PXO_InputField();
            nif.left = nl;
            nif.right = nr;
            nif.top = nt;
            nif.bottom = nb;
            nif.nPage = page;
            PDFXOCR_Funcs.OCR_AddInputField(inFields, nif);

            // extract the text at the given position
            string ret = "";
            hResult = PDFXOCR_Funcs.OCR_GetFields(pdf, ref options, out ret, inFields, "\n", (int)PDFXOCR_Funcs.PXO_FieldInputFlags.PXO_Origin_BottomLeft);
            if (PDFXOCR_Funcs.IS_DS_FAILED(hResult))
            {
                throw new OCRException(string.Format("Unable to extract region OCR: {0}{1}ErrorCode: {2}", sourcePdf, Environment.NewLine, hResult.ToString()));
            }

            try
            {
                PDFXOCR_Funcs.OCR_Delete(out pdf);
            }
            catch { }

            return ret.Replace("\n", " ").Replace(Environment.NewLine, " ").Trim();



M P
User
Posts: 2
Joined: Thu Dec 01, 2016 10:42 am

Re: Zonal OCR Position is off at certain PCs

Post by M P » Wed Dec 07, 2016 10:59 am

Ok we found a solution for the Problem, but we still don't know what exactly was the reason for this.
Problem was that the Laptop had Intel Graphics card on the processor and a seperate one for graphic intense applications, and their profiles got mixed up.

Hiere is what the Administrator told me:

The Laptop has two graphic cards.
One integrated in processor another nvidia graphics card.
First one he uses in normal work, when you start graphic intensive application then he switches automatically to the nvidia card.
there is no way to disable the first one.
There are some profiles for nvidia
and I experimented with those profiles
and found out that there must be nvidia profile selected for normal use and for 3d graphic must be selected automatic
only in that combination our application start working normaly
but visualy (for normal user) we can't see difference, and we dont know when laptop use integrated card when external
and that's it.

For the future it would be nice to know that there is a better fix for the problem.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13324
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Zonal OCR Position is off at certain PCs

Post by Tracker Supp-Stefan » Wed Dec 07, 2016 4:13 pm

Hello M P,

Glad to hear you figured it out.
Our OCR relies only on the CPU, and does not use the GPU processing power for it's needs, so is there any other part of your application that could be causing the problems? Or could it be that this particular processor is defective, and when both it's main and gpu modules are loaded it starts throwing errors?

Regards,
Stefan

Post Reply