Laex / Delphi-OpenCV

Project Delphi-OpenCV. Translation of OpenCV library header files in Delphi
500 stars 226 forks source link

Where is gone cvDelphiErrorHandler #149

Closed HuguesDug closed 1 year ago

HuguesDug commented 2 years ago

Hello,

In the previous versions of the lib, was existing the very helpful cvDelphiErrorHandler.

It was in ocv.utils.

No longer there. I can't find it in another unit. Any help ?

Laex commented 1 year ago

Create your

function cvDelphiErrorHandler( //
  status: Integer;             //
  const func_name: PCvChar;    //
  const err_msg: PCvChar;      //
  const file_name: PCvChar;    //
  line: Integer;               //
  user_data: pointer           //
  ): Integer; cdecl;
begin
  cvSetErrStatus(0);
  // Ignore
  // reset error status avoiding a cascade of subsequent errors
  Result := 0;
  // Or
  // Raise Exception
  Raise Exception.CreateFmt('OpenCV error: in file <<%s>> function <<%s>> line <<%d>> - %s', //
    [string(file_name), string(func_name), line, String(err_msg)]);
end;

and set handler

cvRedirectError(cvDelphiErrorHandler);