the below function create-trackbar-example  works except for the last parameter 
of create-trackbar, "test" ..the test parameter is supposed to be a function 
that gets called  when the trackbar moves.  cvCreateTrackbar, the function I'm 
wrapping, creates a gui slider on the Opencv output window it can either change 
the variable of a running program or call a function when the slider is moved

more info on the last parameter of cvCreateTrackbar, called onChange,  
herehttp://docs.opencv.org/modules/highgui/doc/user_interface.html?highlight=createt#int%20cvCreateTrackbar(const%20char*%20trackbar_name,%20const%20char*%20window_name,%20int*%20value,%20int%20count,%20CvTrackbarCallback%20on_change)


In the documentation for cvCreateTrackbar it says: for onChange: 

"onChange – Pointer to the function to be called every time the slider changes 
position. This function should be prototyped as void Foo(int,void*); , where 
the first parameter is the trackbar position and the second parameter is the 
user data (see the next parameter). If the callback is the NULL pointer, no 
callbacks are called, but only value is updated."  

im trying to convert the second code on this page to lisp 
http://opencv-srf.blogspot.com/2011/11/track-bars.html
...Im pretty sure i have all functions wrapped correctly but in theory 
create-trackbar could be wrong the last parameter in my wrapper is a defctype 
of :pointer type called cv-trackbar-callback


here is my attempt but i have no idea how to define a function as a pointer and 
ive tried alot of  variations but is too long to post.  The defun change 
contrast compiles btw...i tried using make-pointer to make the change-contrast 
function a pointer but make-pointer wants it to be a real...so cant use 
foreign-alloc i dont think because the function needs to be converted to a 
pointer first to use that...any guidance is appreciated



(defun change-contrast (&optional contrast img dest)
(if (< contrast 10) (scale img dest (/ 1 (coerce (- 11 contrast) 
'double-float)))
    (if (>= contrast 10) (scale img dest (- contrast 9))))
     (show-image "MyImage" dest))

(defun display (filename)
  "Open the image FILENAME and show it in a window."
  (let* ((img (load-image filename 1))
        (img-size (get-size img))
       (dest (create-image img-size +ipl-depth-8u+ 3))
       (contrast (cffi:foreign-alloc :int :initial-contents '(10))
      (test "not sure what to do here"))) 
    (named-window "MyWindow" 1)
   (create-trackbar "conrast" "MyWindow" contrast 21 test)
 (princ (mem-ref contrast :int))
  (change-contrast (mem-ref contrast :int) img dest)
    (loop while (not (= (wait-key 0) 27)))
    (release-image img)
    (release-image dest)
    (destroy-window "MyWindow")))

Reply via email to