[Cffi-devel] (no subject)

Joeish W joeish80829 at yahoo.com
Sat May 3 18:08:02 UTC 2014



have thes 3 defcfuns, for OpenCV functions (C++) which have been wrapped in C(C and C+++ function definitions have been included), the top 2,%brisk and surf0 can both can be used as the (self feature-detector) param in the bottom one, %feat-detect-detect. If the output of the top two and the self param of feat-detect-detect are just :pointer, But I need to have all three of their types defined similiarly to the (four type functions) on the bottom of the page so I can use finalizers. 



All of the finalizers and types for the three are the same, just substitute in brisk and surf for feature-detector in the four functions at the bottom of the page and you will know what each looks like. 


 Should I just call the types for the output of brisk and surf and the input type of feat-detect-detect by the same name, and make them all use the same 4 function 
type/finalizer combo at the bottom of the page, or is there a better way.


    ;; BRISK::BRISK(int thresh=30, int octaves=3, float patternScale=1.0f)
    ;; BRISK* cv_create_BRISK(int thresh, int octaves, float patternScale)
    (defcfun ("cv_create_BRISK" %brisk) brisk
      (thresh :int)
      (octaves :int)
      (pattern-scale :float))


    ;; SURF::SURF()
    ;; SURF* cv_create_SURF() 
    (defcfun ("cv_create_SURF" surf0) surf)


    ;; void FeatureDetector::detect(const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const
    ;; void cv_FeatureDetector_detect3(FeatureDetector* self, Mat* image, vector_KeyPoint* keypoints, Mat* mask)
    (defcfun ("cv_FeatureDetector_detect3" %feat-detector-detect) :void
      (self feature-detector)
      (image mat)
      (keypoints (:pointer vector-keypoint))
      (mask mat))




    (define-foreign-type feature-detector ()
      ((garbage-collect  :reader garbage-collect :initform nil :initarg 
                         :garbage-collect))
      (:actual-type :pointer)
      (:simple-parser feature-detector))


    (defclass cv-feature-detector ()
      ((c-pointer :reader c-pointer :initarg :c-pointer)))



    (defmethod translate-to-foreign ((lisp-value cv-feature-detector) (c-type feature-detector))
      (c-pointer lisp-value))




    (defmethod translate-from-foreign (c-pointer (c-type feature-detector))
      (let ((feature-detector (make-instance 'cv-feature-detector :c-pointer c-pointer)))
        (when (garbage-collect c-type)
          (tg:finalize feature-detector (lambda () (del-feature-detector c-pointer))))
        feature-detector))
    ound matches of keypoints from two images."
       (%draw-matches img1 keypoints1 img2 keypoints2 matches1to2 outimg match-color single-point-color matches-mask flags))




More information about the cffi-devel mailing list