<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"> <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 Saturday, April 26, 2014 5:39 AM, 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="yiv9875950221"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt;">Thank you very much,
I should have went back to my C ways of doing things, but it was so odd to see a struct in the OpenCv C++ interface I must have got a little cocky. Again I really appreciate all your attention to these 3 matters today<br clear="none"><div><span><br clear="none"></span></div><div class="yiv9875950221yqt9413599154" id="yiv9875950221yqt61340"><div class="yiv9875950221yahoo_quoted" style="display:block;"> <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 Saturday, April 26, 2014 4:32 AM, Willem Rein Oudshoorn <woudshoo@xs4all.nl> 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="yiv9875950221y_msg_container">Joeish W <<a rel="nofollow" shape="rect" ymailto="mailto:joeish80829@yahoo.com" target="_blank" href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> writes:<br clear="none"><br clear="none">> I have this C wrapper <br clear="none">><br clear="none">><br clear="none">> DMatch* cv_create_DMatch3(int _queryIdx, int _trainIdx, float _distance) {<br clear="none">> return new DMatch(_queryIdx, _trainIdx, _distance);<br clear="none">> }<br clear="none">><br clear="none">><br clear="none">> it is a wrapper for these struct members<br clear="none">><br clear="none">> <a rel="nofollow" shape="rect" target="_blank" href="http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=dmatch#DMatch">http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_descriptor_matchers.html?highlight=dmatch#DMatch</a><br
clear="none">><br clear="none">><br clear="none">> here is my lisp wrapper for it:<br clear="none">><br clear="none">> (defctype dmatch :pointer)<br clear="none">><br clear="none">> (defcfun ("cv_create_DMatch3" dmatch3) (:pointer dmatch) <br clear="none">> "DMatch
constructor"<br clear="none">> (-query-idx :int)<br clear="none">> (-train-idx :int)<br clear="none">> (-distance :float))<br clear="none">><br clear="none">> In C I can do this:<br clear="none">><br clear="none">> DMatch* a = cv_create_DMatch3(1, 2, 3.0);<br clear="none">> cout << a->distance ;<br clear="none">><br clear="none">> and the output is 3<br clear="none">><br clear="none">> but in lisp when I do this:<br clear="none">><br clear="none">> (defparameter a (dmatch3 1 2 3f0))<br clear="none">><br clear="none">> LCV> (mem-aref a :int 0) <br clear="none">> 1<br clear="none">> LCV> (mem-aref a :int 1) <br clear="none">> 2<br clear="none">> LCV> (mem-aref a :float 2) <br clear="none">> #<SINGLE-FLOAT quiet NaN> <--- this is output<br clear="none">><br clear="none">><br clear="none">> Any help on figuring out the reason
would be much appreciated<br clear="none"><br clear="none"><br clear="none">This is not really suprising. You are treating the resulting pointer<br clear="none">`a` as an untyped pointer. <br clear="none">When you do `(mem-aref a :float 2)` you are basically saying:<br clear="none"><br clear="none">1. Assume a is a pointer to an array of floats<br clear="none">2. Give me the third element (element at
index 2).<br clear="none"><br clear="none">Unfortunately `a` is not a pointer to an array of floats, but a pointer<br clear="none">to a struct DMatch.<br clear="none"><br clear="none">You should lookup `defcstruct` in the CFFI documentation:<br clear="none"><br clear="none"><a rel="nofollow" shape="rect" target="_blank" href="http://common-lisp.net/project/cffi/manual/html_node/defcstruct.html#defcstruct">http://common-lisp.net/project/cffi/manual/html_node/defcstruct.html#defcstruct</a><br clear="none"><br clear="none">Wim Oudshoorn.<br clear="none"><br clear="none"><br clear="none">_______________________________________________<br clear="none">Cffi-devel mailing list<br clear="none"><a rel="nofollow" shape="rect" ymailto="mailto:Cffi-devel@common-lisp.net" target="_blank" href="mailto:Cffi-devel@common-lisp.net">Cffi-devel@common-lisp.net</a><br clear="none"><a rel="nofollow" shape="rect" target="_blank"
href="http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel">http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel</a><br clear="none"><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>