PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 23 → [WD22] API Question
[WD22] API Question
Débuté par Michael Drechsel, 28 aoû. 2018 15:57 - 12 réponses
Posté le 28 août 2018 - 15:57
Hi API Gurus,

I need some help.

I use a OCR API which has the following function:

HRESULT OCR_MakeSearchable(
PXODocument Doc,
PXO_Options* pOptions,
PXO_Pagelist PageList = NULL
);

PXO_Options is a structure

My Code:


OCR_MakeSearchable is API Description
OCR_MakeSearchable..DLLName="OcrTools.x86.dll"
OCR_MakeSearchable..FunctionName="OCR_MakeSearchable"
OCR_MakeSearchable..ReturnType=apiSystemInt
OCR_MakeSearchable..Parameter[1]..Type=apiSystemInt//PDF
OCR_MakeSearchable..Parameter[2]..Type=stMyPXO //Structur <<<<<<<<<<<<ERROR
OCR_MakeSearchable..Parameter[3]..Type=apiSystemInt //NULL

How to declare a structure parameter ?
Membre enregistré
85 messages
Posté le 29 août 2018 - 08:18
Hi,
we are using the same library ;)

we got this working by
defining the Options-Structure as

PXO_Options is structure
lang is int //OCR language identifier; ensure language is installed in correct 0-englisch, 1-französisch, 2-deutsch
RegionMode is int // OCR_RegionMode A region mode specifier. Useful for increasing OCR accuracy
Whitelist is UNICODE string //A list of character to accept as recognizable symbols.
Blacklist is UNICODE string //BSTR A list of characters to deny as acceptable symbols for recognition.
DataPath is UNICODE string //The path to the language pack directory containing the subfolder
ImageFlags is int //Flags for image processing. See OCR_ImageProcessingFlags
raster_dpi is int //DPI setting for rasterizing / resampling pages for OCR. The OCR
accMode is int //Reserved for future use. Please set to zero.
END


using this description of makeSearchable

OCR_MakeSearchable is API Description
OCR_MakeSearchable..CallingConvention = STDCALL
OCR_MakeSearchable..DLLName = "ocrtools.dll"
OCR_MakeSearchable..FunctionName = "OCR_MakeSearchable"
OCR_MakeSearchable..Parameter[1]..Type = apiSystemInt
OCR_MakeSearchable..Parameter[2]..Type = apiSystemInt
OCR_MakeSearchable..Parameter[3]..Type = apiSystemInt
OCR_MakeSearchable..ReturnType = apiSystemInt


and calling it by this way

nRes = OCR_MakeSearchable(PXO_Document,&OCROptions, Null) //Makesearchable



hope this helps

meikl ;)
Posté le 30 août 2018 - 08:37
Hi,

first problem resolved. But I have another:

I have to create a Callback function in Windev and these function should be called with his adress:

nRes = OCR_SetCallback(doc, AddressOf Callback, 0)


I have no idea, how to do that in WD.

Any hints ?
Membre enregistré
85 messages
Posté le 30 août 2018 - 11:38
Well...

Api Description

OCR_SetCallBack is API Description
OCR_SetCallBack..CallingConvention = STDCALL
OCR_SetCallBack..DLLName = "ocrtools.dll"
OCR_SetCallBack..FunctionName = "OCR_SetCallback"
OCR_SetCallBack..Parameter[1]..Type = apiSystemInt
OCR_SetCallBack..Parameter[2]..Type = apiSystemInt
OCR_SetCallBack..Parameter[3]..Type = apiSystemInt
OCR_SetCallBack..ReturnType = apiSystemInt



Define your Callback-Procedure

Procedure ocrCallback(pStage, pLevel, pLparam are int):boolean
//sample using a progressbar
SWITCH pStage
CASE 1:
STC_Progress = "Preparing"
rProgress = 0
SourceToScreen(WIN_main)
CASE 2:
STC_Progress = "Processing"
rProgress = pLevel/pLparam * 100
SourceToScreen(WIN_main)
CASE 3:
STC_Progress = "Finishing"
OTHER CASE

END


and calling it by this way

...
nRes = OCR_SetCallBack(PXO_Document,&ocrCallback, nPages * 4)
...


hope this helps

meikl ;)
Posté le 30 août 2018 - 11:46
Hi Michael,

If I recall correctly you should simply provide an ampersand in front of the callback procedure.
nRes = OCR_SetCallback(doc, &MyProcedureName, 0)
Cheers,

Peter Holemans
Posté le 30 août 2018 - 11:59
Hi Peter,

nope.

WD says: Error:The & operator applies to variables only.
pService.OCR, Local Procedure, line 59, column 33


Can I put the adress of the function in a variable ? And if yes, how ?
Posté le 30 août 2018 - 15:45
Hi Michael,

It's all in the help: http://doc.windev.com/en-US/…

See section: "Procedure called in CallBack"

Cheers,

Peter H.
Posté le 30 août 2018 - 16:26
Hi Michael,

as you must know, the mysnip forum is duplicated on the pcsoft us forum...

As a result from time to time, some people are answering the mysnip questions on the pcsoft forum and we don't see their answers here.

You are in this case, and the developer answering has used the same api and is giving you full code examples over there...

Now you know :-)

Best regards
Posté le 30 août 2018 - 18:54
Quote
Fabrice Harari

Hi Michael,



as you must know, the mysnip forum is duplicated on the pcsoft us forum...



As a result from time to time, some people are answering the mysnip questions on the pcsoft forum and we don't see their answers here.



You are in this case, and the developer answering has used the same api and is giving you full code examples over there...



Now you know :-)



Best regards


So the 'duplication' is only one way... mysnip >> pcsoft, and not mysnip <<->> pcsoft?
Posté le 30 août 2018 - 20:12
yep...

it was bidirectionnal in the beginning, a few years back, but it never worked correctly (duplicates)...

I suppose that considering the small number of messages ORIGINATING on their forum, they didn't bother rewriting that part.

Or they just want to suck the substance from here without adding anything... you choose...

Best regards
Posté le 30 août 2018 - 20:15
Hi Mikle, Fabrice

@Fabrice: Many thanks for your hint to show in this forum
@meikl: You save my day !!! Sorry for the delayed reply but my initial message was in the mysnip forum and PCSoft doesn´t forwarded all messages in both forums ...

one question: We use the tracker ocr as a service at a server to manipulate all incoming pdfs of our document management system. How can I separate the pdfs with images from the "normal" pdfs to reduce the time to run ?
My idea was to use windevs pdf2text function. Has it a result <> "" so its a normal pdf, otherwise it is a image.

regards Michael
Posté le 30 août 2018 - 20:51
Hi Fabrice,

many thanks. Without your hint I didn´t have get the answer from the pcs forum ....
Posté le 31 août 2018 - 07:41
Hi Art,

in principle, we could duplicate the answers from the PCS forum to our forum as well. PCS has a guy for that, transfer from here to there doesn't come through the cheap lane. Whenever the transfer of the forum is done and all the pain is over, we could officially deal with the issue.