<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div style="" class=""><span style="" class="">Thank you very much for all the help recently, actually the Rect is a OpenCv C class here:</span></div><div class="" 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"><span style="" class=""><a style="" class="" href="http://docs.opencv.org/trunk/modules/core/doc/basic_structures.html?highlight=rect#Rect_">http://docs.opencv.org/trunk/modules/core/doc/basic_structures.html?highlight=rect#Rect_</a>...does your advice on making a defcstruct for it stand..Remember, the same code works evaluating the same way at the REPL creating a vector<Rectt> like this:</span></div><div class="" 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 style="" class=""></div><div class="" 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 style="" class=""></div><div class="" 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">Functions:</div><div class="" 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 style="" class=""></div><div class="" 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">;; template < class T, class Alloc = allocator<T> > class vector<br style="" class="">;; vector_##t * carray_to_std_vector##tn( t * a, size_t len )<br style="" class="">(defcfun ("carray_to_std_vectorr" %c-arr-to-vector-rect) (:pointer vector-rect)<br style="" class=""> (a :pointer)<br style="" class=""> (len :unsigned-int))</div><div class="" 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 style="" class=""></div><div class="" 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">;; template < class T, class Alloc = allocator<T> > class vector<br
style="" class="">;; t * std_vector##tn##_to_carray( vector_##t * v ) <br style="" class="">(defcfun ("std_vectorr_to_carray" %vector-rect-to-c-array) (:pointer rect) <br style="" class=""> (s (:pointer vector-rect)))<br style="" class=""><br style="" class=""><span style="" class=""></span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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"><span style="" class="">(%c-arr-to-vector-rect<br style="" class=""> (foreign-alloc :pointer :initial-contents <br style="" class="">
(list (rect 1 2 3 4) <br style="" class=""> (rect 5 6 7 8))) 2)</span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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"><span
style="" class="">VECTOR-RECT-SIZE just gets the size of the vector</span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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"><span style="" class="">(dotimes (ic (%vector-rect-size faces))<br style="" class="">(setf n (%vector-rect-to-c-array faces))<br style="" class="">(format t "~a~%" (rect-x
(mem-aref n :pointer ic))))<br style="" class="">; <br style="" class="">; caught WARNING:<br style="" class="">; undefined variable: N<br style="" class="">; <br style="" class="">; compilation unit finished<br style="" class="">; Undefined variable:<br style="" class="">; N<br style="" class="">; caught 1 WARNING condition<br style="" class="">1 <-- both x values<br style="" class="">5<br style="" class=""></span></div><div class="" 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 style="" class=""><span style="" class=""></span></div><div class="" 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 style=""
class=""><span style="" class=""></span></div><div class="" 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"><span style="" class=""><br style="" class=""></span></div><div style="display: block;" class="yahoo_quoted"> <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt"> <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt"> <div style="" class="" dir="ltr"> <font style="" class="" face="Arial" size="2"> On Saturday, April 26, 2014 4:41 AM, Willem Rein Oudshoorn <woudshoo@xs4all.nl> wrote:<br style="" class=""> </font> </div> <blockquote class="" style=""> <div style="" class="">Joeish W <<a style="" class="" ymailto="mailto:joeish80829@yahoo.com"
href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> writes:<br style="" class=""><br style="" class="">> Lisp code is here <a style="" class="" href="https://gist.github.com/W-Net-AI/11205892" target="_blank">https://gist.github.com/W-Net-AI/11205892</a><br style="" class="">> ...<br style="" class="">> LCV> (dotimes (ic (vector-rect-size faces)) <br style="" class="">> (setf n (%vector-rect-to-c-array faces))<br style="" class="">> (rect-x (mem-aref n :pointer ic)))<br style="" class="">><br style="" class="">> this is where it fails, rect-x, my Lisp wrapper for C wrapper for the<br style="" class="">> c++ Rect class member x in this statement isn't getting a Rect* so it<br style="" class="">> outputs error: Unhandled ;memory fault at #xC9000000D5. The<br style="" class="">> %vector-rect-to-c-array function is a
wrapper for the c function in<br style="" class="">> the posted c/c++ code. It works as expected on everything else but the<br style="" class="">> vector<Rect> output of detectMultiScale.<br style="" class=""><br style="" class="">This fails because `n` is a pointer the data of vector<Rect>. <br style="" class="">So it points to an array of Rect structures, NOT an array of Rect*<br style="" class="">(pointers to Rect).<br style="" class=""><br style="" class="">What would work (but I am advising against this), is:<br style="" class=""><br style="" class="">(rect-x (inc-pointer n (* ic SIZE_OF_RECT)))<br style="" class=""><br style="" class="">Where SIZE_OF_RECT is the size of the Rect struct.<br style="" class=""><br style="" class="">What you should do is look into `defcstruct` to properly wrap the Rect<br style="" class="">struct and start from there.<br style="" class=""><br style="" class="">Wim Oudshoorn.<br style=""
class=""><br style="" class=""><br style="" class="">_______________________________________________<br style="" class="">Cffi-devel mailing list<br style="" class=""><a style="" class="" ymailto="mailto:Cffi-devel@common-lisp.net" href="mailto:Cffi-devel@common-lisp.net">Cffi-devel@common-lisp.net</a><br style="" class=""><a style="" class="" href="http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel" target="_blank">http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel</a><br style="" class=""><br style="" class=""><br style="" class=""></div> </blockquote> </div> </div> </div> </div></body></html>