<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div>What am i doing wrong in my conversion of this c code to lisp<br>I think the issue is with my callback function but not 100% when i run the c code and print<br>with these 2 lines(from c callback):<br><br>cout << "a = " << "(" << "" << "," << _a << ")" << endl ;<br> cout << "b = " << "(" << "" << "," << _b << ")" << endl;<br><br> i get 53 elements printed not icluding the other printf output<br>and in the lisp code i converterd <br><br>when i print with this line(from lisp defcallback):<br><br>(format t "~%x~a~%b~a" _a _b)<br><br> in the defcallback i get 114 elements<br><br>Hoping someone can look at my code and tell me if my coding
is off<br>the -> is a macro for with-foreign-slots (and if not a pointer just a getf for a plist)<br><br>;;;;;;;;C CODE;;;;;;;;;;;;;;;;;;;<br><br> static int cmp_func( const void* _a, const void* _b, void* userdata )<br> {<br> CvPoint* a = (CvPoint*)_a;<br> CvPoint* b = (CvPoint*)_b;<br> cout << "a = " << "(" << "" << "," << _a << ")" << endl ;<br> cout << "b = " << "(" << "" << "," << _b << ")" << endl;<br> int y_diff = a->y - b->y;<br> int x_diff = a->x -
b->x;<br> return y_diff ? y_diff : x_diff;<br> }<br><br><br> <br>;;;;;;;;;;;;;;;;;;;;;;;;;LISP CODE;;;;;;;;;;;;;;;;;;;;<br>(defcallback cmp-func :void ((_a :pointer) (_b :pointer) (user-data :pointer) (a :int) (b :int) (y-diff :int) (x-diff :int))<br> (format t "~%x~a~%b~a" _a _b)<br> (setf a (mem-aref _a '(:struct cv-point)))<br> (setf b (mem-aref _b '(:struct cv-point)))<br> ;(format t "~%a~a~%b~a" a b)<br> (setf y-diff (- (-> cv-point a y) (-> cv-point b y)))<br> (setf x-diff (- (-> cv-point a x) (-> cv-point b x)))<br> (if y-diff y-diff x-diff))<br><br><br>using callback with (callback cmp-func) in the OpenCV function cvSeqSort ....here is documentation for cvSeqSort</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;">http://docs.opencv.org/modules/core/doc/dynamic_structures.html?highlight=cvseqs#seqsort</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;">the code the wrapper is used in is posted in the "Help with defcallback" post below this one</div></div></body></html>