What am I doing wrong in this attempt to convert an opencv function to lisp with cffi

200 views Asked by At

The opencv function is cvSmooth and here is the cffi code I wrote

;; 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+)

The C function interface:

(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)))

basically the +gaussian+ looks bad not like in opencv at all and +bilateral+ doesn't work at all it makes the code I use it not even run but the rest work fine.....what am I doing wrong?

0

There are 0 answers