2

opencv 関数は cvSmooth で、これが私が書いた cffi コードです

;; void cvSmooth(const CvArr* src, CvArr* dst, int smoothtype=CV_GAUSSIAN,
;;               int size1=3, int size2=0, double sigma1=0, double sigma2=0)

(defmacro defanonenum (&body enums)
  "Converts anonymous enums to Lisp constants."
  `(cl:progn ,@(cl:loop for value in enums
            for index = 0 then (cl:1+ index)
            when (cl:listp value) 
        do (cl:setf index (cl:second value)
                value (cl:first value))
        collect `(cl:defconstant ,value ,index))))

(defanonenum
  +gaussian+
  +blur+
  +blur-no-scale+
  +median+
  +bilateral+)

C 関数インターフェイス:

(cffi:defcfun ("cvSmooth" %smooth) :void
  (src cv-array)                 ; source image
  (dest cv-array)                 ; destination image
  (smooth-type :int)
  (size1 :int)
  (size2 :int)
  (sigma1 :double)
  (sigma2 :double))

(defun smooth (src dest
               &optional
               (smooth-type +gaussian+)
               (size1 3)
               (size2 0)
               (sigma1 0)
               (sigma2 0))
  (%smooth src dest smooth-type size1 size2
           (coerce sigma1 'double-float)
           (coerce sigma2 'double-float)))

基本的に、+gaussian+ は opencv のように悪く見え、+bilateral+ はまったく動作しません。使用するコードは実行されませんが、残りは正常に動作します.....何が間違っていますか?

4

0 に答える 0