3rd party c wrapper functions for harbour

Re: 3rd party c wrapper functions for harbour

Postby Antonio Linares » Sun Mar 26, 2017 8:08 pm

The TOCRdll.dll that you posted here:

http://lac.structuredsystems.com/temp/

is loading fine
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: 3rd party c wrapper functions for harbour

Postby Antonio Linares » Sun Mar 26, 2017 8:11 pm

Now I get this error:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: 3rd party c wrapper functions for harbour

Postby Antonio Linares » Sun Mar 26, 2017 8:16 pm

I guess it is related with the license:

Looking inside the TOCRdll.dll I find this:
Invalid licence number Software\Transym\TOCR\1.1\Paths Failed to find Paths
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: 3rd party c wrapper functions for harbour

Postby reinaldocrespo » Sun Mar 26, 2017 8:29 pm

I was hoping that by installing the key code here before coping over to the temp directory where you are download from would take care of that.

I will email you and anyone interested on trying the key code to install the license. That should fix that problem.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: 3rd party c wrapper functions for harbour

Postby Enrico Maria Giordano » Mon Mar 27, 2017 8:15 am

Ok, now I'm also getting "Failed to find Paths".

Some other notes:

1. Change this line from

Code: Select all  Expand view
JobInfo2.InputFile = InputFile;


to

Code: Select all  Expand view
JobInfo2.InputFile = ( char * ) InputFile;


to shut up the warning. But first check if it's correct to remove the constness from InputFile.

2. Change this line from

Code: Select all  Expand view
TOCRRESULTS     *Results = 0;


to

Code: Select all  Expand view
TOCRRESULTSEX     *Results = 0;


as GetResults() function expects a TOCRRESULTSEX type as the second parameter.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: 3rd party c wrapper functions for harbour

Postby reinaldocrespo » Mon Mar 27, 2017 2:44 pm

Thank you very much Enrico. Good observations. The problem I'm having now is linking the app. It complains of missing TOCR functions as if I wasn't linking TOCRdll.lib but I am.

Code: Select all  Expand view

xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6741)
Copyright 1999-2010, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'transym.prg' and generating preprocessed output to 'transym.ppo'...

100

Lines 15, Functions/Procedures 1
Generating C source output to 'transym.c'...
Done.
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
transym.c:
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external 'TOCRSetConfig' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRInitialise' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRShutdown' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRDoJob2' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRWaitForJob' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRGetConfig' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRGetJobStatusMsg' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
Error: Unresolved external 'TOCRGetJobResultsEx' referenced from F:\FWH_2012_04\SAMPLES\TRANSYM.OBJ
* Linking errors *
 


This is my Transym.prg
Code: Select all  Expand view

#define TOCRJOBTYPE_TIFFFILE 0      // TOCRJOBINFO.InputFile specifies a tiff file

FUNCTION MAIN()
LOCAL TestTifFile := "sample.tif"

   IF !FILE( TestTifFile )
      Alert( "testfile sample.tif not found" )
      return NIL
   ENDIF

   MsgInfo( OCRFromFileUsingTransym( TestTifFile, TOCRJOBTYPE_TIFFFILE ) )
   
RETURN NIL

//-----------------------------------------------------------

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include "TOCRdll.h"
#include "TOCRuser.h"
#include "TOCRerrs.h"

BOOL OCRWait( long JobNo, TOCRJOBINFO2 JobInfo2 );
BOOL GetResults( long JobNo, TOCRRESULTSEX ** Results );
BOOL FormatResults( TOCRRESULTSEX * Results, char * Msg );

//--------------------------------------------------------
//parameters
// 1. input file with image
// 2. type of file to ocr //should default to TIFF
//returns OCRed text

HB_FUNC( OCRFROMFILEUSINGTRANSYM )
{
    TOCRJOBINFO2 JobInfo2;
    TOCRRESULTSEX  * Results = 0;
    long                Status;
    long                JobNo;
    char                Msg[8192];
    char * InputFile = ( char * ) hb_parcx( 1 );   //parm 1 is input file

   //Sets Transym to print error to log file tocr.log
    TOCRSetConfig( TOCRCONFIG_DEFAULTJOB, TOCRCONFIG_DLL_ERRORMODE, TOCRERRORMODE_MSGBOX );

    memset( &JobInfo2, 0, sizeof( TOCRJOBINFO2 ) );

    JobInfo2.JobType = hb_parni( 2 ) ; //TOCRJOBTYPE_TIFFFILE;
    JobInfo2.InputFile = InputFile;
    Status = TOCRInitialise( &JobNo );

    if ( Status == TOCR_OK ) {
        if ( OCRWait( JobNo, JobInfo2 ) ) {
            if ( GetResults( JobNo, &Results ) ) {

                FormatResults( Results, Msg );
            hb_xfree( Results );    //free( Results );
            }
        }

        TOCRShutdown( JobNo );
    }
    hb_retc( Msg ) ;
}

//--------------------------------------------------------
BOOL OCRWait( long JobNo, TOCRJOBINFO2 JobInfo2 )
{
    long                Status;
    long                JobStatus;
    long                ErrorMode;
    char                Msg[4096];

    Status = TOCRDoJob2( JobNo, &JobInfo2 );
    if (Status == TOCR_OK) {
        Status = TOCRWaitForJob(JobNo, &JobStatus);
    }
   
    if (Status == TOCR_OK && JobStatus == TOCRJOBSTATUS_DONE)
    {
        return TRUE;
    } else {
        // If something hass gone wrong display a message
        // (Check that the OCR engine hasn't already displayed a message)
        TOCRGetConfig(JobNo, TOCRCONFIG_DLL_ERRORMODE, &ErrorMode);
        if ( ErrorMode == TOCRERRORMODE_NONE ) {
            TOCRGetJobStatusMsg(JobNo, Msg);
            //MessageBox( NULL, Msg, "OCRWait", MB_TASKMODAL | MB_TOPMOST | MB_ICONSTOP );
        }
        return FALSE;
    }
} // OCRWait()


//--------------------------------------------------------
// Get the results from TOCR
BOOL getresults(long JobNo, long mode, void **Results)
{
    long                Status;
    long                ResultsInf;
    char                Msg[4096];


    Status = TOCRGetJobResultsEx(JobNo, mode, &ResultsInf, 0);
    if ( Status != TOCR_OK ) {
        //sprintf(Msg, "TOCRGetJobResultsEx failed - %d\n", Status);
        //MessageBox(NULL, Msg, "getresults", MB_TASKMODAL | MB_TOPMOST | MB_ICONSTOP);
        return FALSE;

    }
    if ( ResultsInf > 0 ) {
        // Allocate memory for results
      *Results = ( char * ) hb_xgrab( ResultsInf + 1 );
       //memset( &Results, 0, sizeof( ResultsInf ) );

      // Retrieve the results
        Status = TOCRGetJobResultsEx(JobNo, mode, &ResultsInf, *Results);
        if ( Status != TOCR_OK ) {
           //sprintf(Msg, "TOCRGetJobResultsEx failed - %d\n", Status);
            //MessageBox(NULL, Msg, "getresults", MB_TASKMODAL | MB_TOPMOST | MB_ICONSTOP);
         hb_xfree( Results );    //free(*Results);
            *Results = 0;
            return FALSE;
        }
    } else {
        //MessageBox(NULL, "No results found\n", "getresults", MB_TASKMODAL | MB_TOPMOST | MB_ICONSTOP);
        return FALSE ;
    }
   
    return TRUE;
} // getresults()


//--------------------------------------------------------
// Get extended results
BOOL GetResults( long JobNo, TOCRRESULTSEX **Results )
{
    return getresults( JobNo, TOCRGETRESULTS_EXTENDED, (void **)Results );
} // GetResults()


//--------------------------------------------------------
// Convert extended results to a string
BOOL FormatResults(TOCRRESULTSEX *Results, char *Msg)
{
    long            ItemNo;
    long            APos = 0;
    BOOL            Status = FALSE;

    if ( Results->Hdr.NumItems > 0 ) {
        for (ItemNo = 0; ItemNo < Results->Hdr.NumItems; ItemNo ++ ) {
            if ( Results->Item[ItemNo].OCRCha == '\r' )
                Msg[APos] = '\n';
            else
                Msg[APos] = (char)Results->Item[ItemNo].OCRCha;
            APos ++;
        }
        Msg[APos] = 0;
        Status = TRUE;
    }

    return Status;
} // FormatResults()


#pragma ENDDUMP
 


and my link script is adding Tocrdll.lib
Code: Select all  Expand view

@ECHO OFF
CLS

if A%1 == A GOTO :SINTAX
if NOT EXIST %1.prg GOTO :NOEXIST

ECHO Compiling...

set FWDIR=.\..\
set XHDIR=f:\xharbour_1.2.1_6741
rem if "%2" == "/b" set GT=gtwin
rem if not "%2" == "/b" set GT=gtgui
set GT=gtgui

set hdir=%XHDIR%
set hdirl=%hdir%\lib
set bcdir=f:\borland\bcc582
set fwh=%FWDIR%

%hdir%\bin\harbour %1 /n /i%fwh%\include;%hdir%\include /w /p %2 %3 > comp.log
IF ERRORLEVEL 1 GOTO COMPILEERRORS
@type comp.log

echo -O2 -e%1.exe -I%hdir%\include -I%bcdir%\include %1.c > b32.bc
%bcdir%\bin\bcc32 -M -c -v @b32.bc
:ENDCOMPILE

IF EXIST %1.rc %bcdir%\bin\brc32 -r -I%bcdir%\include %1

echo %bcdir%\lib\c0w32.obj + > b32.bc
echo %1.obj, + >> b32.bc
echo %1.exe, + >> b32.bc
echo %1.map, + >> b32.bc
echo %fwh%\lib\Fivehx.lib %fwh%\lib\FiveHC.lib + >> b32.bc
echo %hdirl%\rddads.lib + >> b32.bc
echo %hdirl%\ace32.lib + >> b32.bc
echo %hdirl%\rtl.lib + >> b32.bc
echo %hdirl%\vm.lib + >> b32.bc
echo %hdirl%\%GT%.lib + >> b32.bc
echo %hdirl%\lang.lib + >> b32.bc
echo %hdirl%\macro.lib + >> b32.bc
echo %hdirl%\rdd.lib + >> b32.bc
echo %hdirl%\dbfntx.lib + >> b32.bc
echo %hdirl%\dbfcdx.lib + >> b32.bc
echo %hdirl%\dbffpt.lib + >> b32.bc
echo %hdirl%\hbsix.lib + >> b32.bc
echo %hdirl%\debug.lib + >> b32.bc
echo %hdirl%\common.lib + >> b32.bc
echo %hdirl%\pp.lib + >> b32.bc
echo %hdirl%\pcrepos.lib + >> b32.bc
echo %hdirl%\ct.lib + >> b32.bc
echo %hdirl%\zlib.lib + >> b32.bc
echo %hdirl%\hbzip.lib + >> b32.bc
echo %hdirl%\png.lib + >> b32.bc
echo %hdirl%\tocrdll.lib + >> b32.bc

rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc

echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc
echo %bcdir%\lib\uuid.lib + >> b32.bc
echo %bcdir%\lib\psdk\odbc32.lib + >> b32.bc
echo %bcdir%\lib\psdk\rasapi32.lib + >> b32.bc
echo %bcdir%\lib\psdk\nddeapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\msimg32.lib + >> b32.bc
echo %bcdir%\lib\psdk\psapi.lib + >> b32.bc
echo %bcdir%\lib\psdk\gdiplus.lib + >> b32.bc
echo %bcdir%\lib\psdk\iphlpapi.lib, >> b32.bc

IF EXIST %1.res echo %1.res >> b32.bc

rem uncomment this line to use the debugger and comment the following one
if %GT% == gtwin %bcdir%\bin\ilink32 -Gn -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
if %GT% == gtgui %bcdir%\bin\ilink32 -Gn -aa -Tpe -s -v @b32.bc
IF ERRORLEVEL 1 GOTO LINKERROR
ECHO * Application successfully built *
%1
GOTO EXIT
ECHO

rem delete temporary files
@del %1.c

:COMPILEERRORS
@type comp.log
ECHO * Compile errors *
GOTO EXIT

:LINKERROR
ECHO * Linking errors *
GOTO EXIT

:SINTAX
ECHO    SYNTAX: Build [Program]     {-- No especifiques la extensi¢n PRG
ECHO                                {-- Don't specify .PRG extension
GOTO EXIT

:NOEXIST
ECHO The specified PRG %1 does not exist

:EXIT
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: 3rd party c wrapper functions for harbour

Postby Enrico Maria Giordano » Mon Mar 27, 2017 2:52 pm

I can't see the reason of the problem, sorry. But as a side note, you are using a seven years old release of xHarbour! Time to update, both xHarbour and BCC. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: 3rd party c wrapper functions for harbour

Postby cnavarro » Tue Mar 28, 2017 11:33 pm

When I obtain this errors has been usually because the parameter types did not match the definitions of the functions, so, although with the same name, they are not recognized
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: 3rd party c wrapper functions for harbour

Postby reinaldocrespo » Tue Mar 28, 2017 11:40 pm

Thank you.

I found that this particular lib needs to be imported without the -a option. After doing Implib with out the -a option, it worked great. I shared the wrapper functions on another thread on this forum in case it helps some else wanting to use Transym TOCR dll from API.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: 3rd party c wrapper functions for harbour

Postby cnavarro » Wed Mar 29, 2017 2:43 am

Yes, I saw your post after replying in this thread
Regards
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: 3rd party c wrapper functions for harbour

Postby Enrico Maria Giordano » Wed Mar 29, 2017 8:07 am

cnavarro wrote:When I obtain this errors has been usually because the parameter types did not match the definitions of the functions, so, although with the same name, they are not recognized


This is not true. In C language, a function declaration is used exactly so the compiler knows what parameters and types it needs and can emit an error it they not match (Type mismatch in parameter, or something similar). If the declaration is missing, the compiler (as I already said) assumes all the parameters (and the return value) as int type. If the linker complains with "Unresolved symbol", it means that the unresolved symbol is not found in the source code or in the linked libraries.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: 3rd party c wrapper functions for harbour

Postby jnavas » Mon Apr 03, 2017 5:13 am

Cristobal
Saludos,
Lograste ejecutar el programa TOCR?
User avatar
jnavas
 
Posts: 479
Joined: Wed Nov 16, 2005 12:03 pm
Location: Caracas - Venezuela

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 78 guests