<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div><span></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On , Joeish W <joeish80829@yahoo.com> wrote:<br> </font> </div> <blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;">  <div class="y_msg_container"><div id="yiv1682111243"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"><div><span><br
 clear="none"></span></div><div class="yiv1682111243yahoo_quoted" style="display:block;"> I got the callback working somewhat to illustrate here is my code so far below and again im attempting to convert the lowest function on this page: http://opencv-srf.blogspot.com/2011/11/track-bars.html<br clear="none"><br clear="none">(defcallback a :void  ((contrast :int) (img cv-arr) (dest cv-arr))<br clear="none"> (format t "img-1: ~a~%~%" img)<br clear="none">(format t "dest-1: ~a~%~%" dest)<br clear="none">(format t "Trackbar level-1: ~a~%~%" contrast))<br clear="none"><br clear="none"><br clear="none"><br clear="none">(defun create-trackbar-example (&optional (camera-index *camera-index*) (width *default-width*)<br clear="none">                (height *default-height*))<br clear="none">  "Creates a trackbar and attaches it to the specified window.<br clear="none">   Move
 the
 slider to adjust the brightess of the camera output"<br clear="none">  (with-capture (capture (create-camera-capture camera-index))<br clear="none">    (let ((window-name "CREATE-TRACKBAR Example")<br clear="none">      (contrast (foreign-alloc :int :initial-contents '(10)))<br clear="none">      (dest (create-image (size width height) +ipl-depth-8u+ 3)))<br clear="none">      (set-capture-property capture +cap-prop-frame-width+ width)<br clear="none">      (set-capture-property capture +cap-prop-frame-height+ height)<br clear="none">      (named-window window-name)<br clear="none">      (move-window window-name 600 175)<br clear="none">      (do* ((img (query-frame capture) (query-frame capture))<br
 clear="none">            (img (clone-image img))<br clear="none">            (scale
 0)<br clear="none">            (n 0))<br clear="none">       ((plusp (wait-key *millis-per-frame*)) nil)<br clear="none">    (create-trackbar "Contrast" window-name contrast 21 (callback a))<br clear="none">    (format t "img-2: ~a~%~%" img)<br clear="none">    (format t "dest-2: ~a~%~%" dest)<br clear="none">    (format t "Trackbar level-2: ~a~%~%" (mem-ref contrast :int))<br clear="none">    (show-image window-name img))<br clear="none">      (release-image dest)<br clear="none">      (destroy-window window-name))))<br clear="none"><br clear="none"><br clear="none">im testing the callback function and it works, it is called when the trackbar is moved, i know this  because the Trackbar level-2 format output from the callback function prints which
 it should and the output  of the contrast variable in that format function also changes.....the contrast variable is changed in the
 create-trackbar-example function and the callback function picks up that variable with the (contrast :int) parameter...  my new question is how do i get the callback function to pick up the img and dest variables from the create-trackbar-example function....when the code runs the output of the format t functions from the call back with the img and dest variables in them are different from the output of the format t functions from the create-trackbar-example  with the img and dest in them which means the callback isnt picking those up but it is picking up the variable contrast...and oddly enough i dont have to mem-ref the contrast variable in the callback function....when i just evaluate the variable contrast it prints a number....I think the parameters of the callback are defined righ,t the img and dest are defined as cv-arr (a defctype :pointer) in my library<br clear="none"> ...any help is appreciated<br clear="none"> <div
 class="yiv1682111243yqt0998713669" id="yiv1682111243yqt90431"><div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;"> <div style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Sunday, October 27, 2013 12:03 AM, "f9cef2aa@yandex.ru" <f9cef2aa@yandex.ru> wrote:<br clear="none"> </font> </div> <blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;margin-top:5px;padding-left:5px;">  <div class="yiv1682111243y_msg_container"><div class="yiv1682111243yqt0773183188" id="yiv1682111243yqtfd11468">>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 clear="none">><br clear="none">>(defun change-contrast (&optional contrast img dest)<br clear="none">>(if (< contrast 10) (scale img dest (/ 1 (coerce (- 11 contrast) 'double-float)))<br clear="none">>    (if (>= contrast 10) (scale img dest (- contrast 9))))<br clear="none">>     (show-image "MyImage" dest))<br clear="none">><br clear="none">>(defun display (filename)<br clear="none">>  "Open the image FILENAME and show it in a window."<br clear="none">>  (let* ((img (load-image filename 1))<br clear="none">>        (img-size (get-size img))<br clear="none">>       (dest (create-image img-size +ipl-depth-8u+ 3))<br clear="none">>       (contrast (cffi:foreign-alloc :int :initial-contents '(10))<br
 clear="none">>      (test "not sure what to do here"))) <br clear="none">>    (named-window "MyWindow" 1)<br clear="none">>   (create-trackbar "conrast" "MyWindow" contrast 21 test)<br clear="none">> (princ (mem-ref contrast :int))<br clear="none">>  (change-contrast (mem-ref contrast :int) img dest)<br clear="none">>    (loop while (not (= (wait-key 0) 27)))<br clear="none">>    (release-image img)<br clear="none">>    (release-image dest)<br clear="none">>    (destroy-window "MyWindow")))</div><br clear="none"><br clear="none">Have you read defcallback documentation? If no, read it and try to use<br clear="none">defcallback. If yes, what was your problem when using defcallback?<div class="yiv1682111243yqt0773183188" id="yiv1682111243yqtfd67880"><br clear="none"><br clear="none"><br clear="none"><br
 clear="none"><br clear="none"></div><br clear="none"><br clear="none"></div> </blockquote>  </div> </div></div>   </div> </div></div></div><br><br></div> </blockquote>  </div> </div>   </div> </div></body></html>