Laex / Delphi-OpenCV

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

FeatureDetector.dpr is not compiling #68

Closed ertankucukoglu closed 7 years ago

ertankucukoglu commented 7 years ago

Hello,

I am getting below error when trying to compile the project. [dcc32 Error] ocv.cls.features2d.pas(46): E2003 Undeclared identifier: 'TKeyPoint'

Related lines are as follows:

type

  // ---------------------------- KeyPoint --------------------------

  pKeyPoint = ^TKeyPoint;
  TKeyPointArray = TArray<TKeyPoint>;  // <--- ERROR LINE
  TKeyPointArrayOfArray = TArray<TKeyPointArray>;

  TKeyPoint = record
    pt: TcvPoint2f; // !< coordinates of the keypoints
    size: Float; // !< diameter of the meaningful keypoint neighborhood
    angle: Float; // !< computed orientation of the keypoint (-1 if not applicable);
    // !< it's in [0,360) degrees and measured relative to
    // !< image coordinate system, ie in clockwise.
    response: Float; // !< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
    octave: Integer; // !< octave (pyramid layer) from which the keypoint has been extracted
    class_id: Integer; // !< object class (if the keypoints need to be clustered by an object they belong to)
    procedure KeyPoint(_pt: TcvPoint2f; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
      _class_id: Integer = -1); overload;
    procedure KeyPoint(x: Float; y: Float; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
      _class_id: Integer = -1); overload;
    function hash: size_t;
    procedure convert(const keypoints: TKeyPointArray; Var points2f: TArrayOfcvPoint2f); overload;
    procedure convert(const points2f: TArrayOfcvPoint2f; Var keypoints: TKeyPointArray); overload;
    function overlap(const kp1, kp2: TKeyPoint): Float;
  end;

It seems like a recursive call to TKeyPoint at some point. But this maybe me lacking Delphi knowledge.

blaisexen commented 7 years ago

hi,

try to compile using Delphi XE6 and later,

What exact version you have now?

ertankucukoglu commented 7 years ago

My version is Delphi 10.2 Tokyo.

If you see below definition. That recursively points TKeyPoint and I couldn't solve problem with my knowledge.

procedure convert(const keypoints: TKeyPointArray; Var points2f: TArrayOfcvPoint2f); overload;

blaisexen commented 7 years ago

Hello,

at-least you should try compiling it with Delphi Tokyo below, well see if Tokyo has the problem, not the Structure of the codes.

Blaise

ertankucukoglu commented 7 years ago

I believe, features2d port is not complete, yet. I read it in another issue post here.

Below code is compiling. It should be compiled in Delphi 2010, too. Learned from a forum that advanced types support nested parts in it.

I do not know how to commit any change using Git. I appreciate if someone else can do it, please. File modification made is: ocv.cls.features2d.pas

  pKeyPoint = ^TKeyPoint;

  TKeyPoint = record
  public type
    TKeyPointArray = TArray<TKeyPoint>;
    TKeyPointArrayOfArray = TArray<TKeyPointArray>;
  public
    pt: TcvPoint2f; // !< coordinates of the keypoints
    size: Float; // !< diameter of the meaningful keypoint neighborhood
    angle: Float; // !< computed orientation of the keypoint (-1 if not applicable);
    // !< it's in [0,360) degrees and measured relative to
    // !< image coordinate system, ie in clockwise.
    response: Float; // !< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
    octave: Integer; // !< octave (pyramid layer) from which the keypoint has been extracted
    class_id: Integer; // !< object class (if the keypoints need to be clustered by an object they belong to)
    procedure KeyPoint(_pt: TcvPoint2f; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
      _class_id: Integer = -1); overload;
    procedure KeyPoint(x: Float; y: Float; _size: Float; _angle: Float = -1; _response: Float = 0; _octave: Integer = 0;
      _class_id: Integer = -1); overload;
    function hash: size_t;
    procedure convert(const keypoints: TKeyPointArray; Var points2f: TArrayOfcvPoint2f); overload;
    procedure convert(const points2f: TArrayOfcvPoint2f; Var keypoints: TKeyPointArray); overload;
    function overlap(const kp1, kp2: TKeyPoint): Float;
  end;

  TKeyPointArray = TKeyPoint.TKeyPointArray;
  TKeyPointArrayOfArray = TKeyPoint.TKeyPointArrayOfArray;
blaisexen commented 7 years ago

Suggestion, Try to comment the functions or procedure not involved from your codes, if it's really needed then put empty body on it.

Blaise

ertankucukoglu commented 7 years ago

Actually, I already shared working code above. I tested it and application EXE file also works.

BTW, I still need ability to save/read these keypoints extracted from a picture into a disk file (XML, YAML, JSON). This is not implemented, yet in current state of the Delphi-OpenCV.

I am willing to work with someone to complete that part anyway.

blaisexen commented 7 years ago

May I know where did you put the link of your shared working code above or the application project?

I might try it, Blaise

ertankucukoglu commented 7 years ago

My last code post above is the working code.