Recent

Author Topic: TOpenALPR with Lazarus - Issue at call to OpenALPR  (Read 5957 times)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #15 on: July 09, 2019, 08:07:31 pm »
I agree, if it works Delphi with cdecl, then forget about calling convention.

af0815

  • Hero Member
  • *****
  • Posts: 1409
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #16 on: July 09, 2019, 08:33:17 pm »
I have compiled all the samples with the actual community compiler of Delphi first. After i see it working with the (patched/recompiled) libraries, i do the try with Lazarus.

In the published libs of the OpenALPR Project the 'flattend' interface is complete missing. I have looked with CFF-Explorer. So the guy from TOpenALPR have recompiled it with the flattend interface.

I can send the compiled projects of Delphi if needed. PM
regards
Andreas

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #17 on: July 10, 2019, 02:49:33 am »
I did the smallest test using the straight function calls, and it works after masking FPU exceptions. Does not, using the class. Obviously the problem is in the Pascal code.

I'll work on it some more later when I get a chance.

af0815

  • Hero Member
  • *****
  • Posts: 1409
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #18 on: July 10, 2019, 06:40:23 am »
Interesting news, i will work on this too. I have setup a working chain with VS to rebuild the complete libraries. Tesseract and OpenCV libraries are rebuild correct, but in OpenALPR are some issue, prohibit the full recompile.
regards
Andreas

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #19 on: July 10, 2019, 07:02:41 am »
For testing I just tried with Delphi_console:
1-Add Math to your uses section
2-Disable all FPU exceptions before calling RecognizeFile:
Code: Pascal  [Select][+][-]
  1.   Math.SetExceptionMask([
  2.       exInvalidOp,
  3.       exDenormalized,
  4.       exZeroDivide,
  5.       exOverflow,
  6.       exUnderflow,
  7.       exPrecision
  8.       ]);
  9.  
  10.       alprResult := vOpenAlpr.RecognizeFile('samples\eu-3.jpg');
  11.  

Seems to work. Just make sure to rebuild your code, and notice that the example is not finished. It does not parse the JSON result.

You can see the result if you add WriteLn(pJSON):
Code: Pascal  [Select][+][-]
  1. function TOpenALPR.RecognizeFile(AFileName: String; AROI: PAlprCRegionOfInterest = nil): TOpenALPRResult;
  2. ...
  3.       pJSON := openalpr_recognize_encodedimage(FOpenALPRInstance, msEncodedImage.Memory, msEncodedImage.Size, roi);
  4.       WriteLn(pJSON)

af0815

  • Hero Member
  • *****
  • Posts: 1409
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #20 on: July 10, 2019, 07:56:06 am »
It looks indeed working now, with the math.SetExceptionmask.

The next step is, to proceed with the JSON-Part.

THX to engkin and thaddy.
regards
Andreas

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #21 on: July 10, 2019, 08:37:09 am »
It seems there are several differently compiled dll's: the one I found was definitely compiled with stdcall. I have seen that before with open source software.
Glad that masking out the exceptions at least helps. This is a very important issue on Windows. And well known.
I will also test to get the JSON stuff working, but I have little time the next two days.

Note that Windows uses winapi instead of stdcall or cdecl. winapi is an alias, depending on platform.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

af0815

  • Hero Member
  • *****
  • Posts: 1409
Re: TOpenALPR with Lazarus - Issue at call to OpenALPR
« Reply #22 on: July 10, 2019, 09:30:10 am »
Ok, now the TOpenALPR im my repro is working (actual in branch Lazarus). I have also fixed the JSON Part.


regards
Andreas

 

TinyPortal © 2005-2018