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