<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">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<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style:
 normal;">more info on the last parameter of cvCreateTrackbar, called onChange,  here http://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)<br></div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">In the documentation for cvCreateTrackbar it says: for onChange: </div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;
 background-color: transparent; font-style: normal;">"<strong>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.</strong>"  <br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div>im trying to convert the second code on this page to lisp http://opencv-srf.blogspot.com/2011/11/track-bars.html<br>...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<br><div
 style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br>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<br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
 Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">(defun change-contrast (&optional contrast img dest)<br>(if (< contrast 10) (scale img dest (/ 1 (coerce (- 11 contrast) 'double-float)))<br>    (if (>= contrast 10) (scale img dest (- contrast 9))))<br>     (show-image "MyImage" dest))<br><br>(defun display (filename)<br>  "Open the image FILENAME and show it in a window."<br>  (let* ((img (load-image filename 1))<br>        (img-size (get-size img))<br>       (dest (create-image img-size +ipl-depth-8u+ 3))<br>       (contrast (cffi:foreign-alloc :int :initial-contents '(10))</div><div
 style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">      (test "not sure what to do here"))) <br>    (named-window "MyWindow" 1)<br>   (create-trackbar "conrast" "MyWindow" contrast 21 test)<br> (princ (mem-ref contrast :int))<br>  (change-contrast (mem-ref contrast :int) img dest)<br>    (loop while (not (= (wait-key 0) 27)))<br>    (release-image img)<br>    (release-image dest)<br>    (destroy-window "MyWindow")))<br></div></div></body></html>