<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 Saturday, November 2, 2013 10:44 PM, 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="yiv7495666987"><div><div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande,
sans-serif;font-size:10pt;"><div>here is the c code with explanation didn't add all code to keep it short but i know it is still long...if this seems daunting because all the code I added....pls know 1. I worked on this a long time and added the minimal code i could think to explain the issue 2. if it does seem daunting...if you would be so kind as to look through this and tell me how i could edit my ? to make it easier to answer...with that being said... though this is a very simple post .... Im hoping at the end of the explanation you might be able to help me re-wrap my CV-SEQ struct so i get the same resultt as i do in c<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>CvSeq* contours; //hold the pointer to a contour in the memory block<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;">// adds data to CvSeq* contours with &contours call<br>cvFindContours(imgGrayScale, storage, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));</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;">// This is how its supposed to work ....no matter how many times you dereference contours to get the h_next struct member</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 value of contours->h_next is always the same</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;">cout << "c1 = " << endl << " " <<
contours->h_next << endl << endl; //output same as next line - see output below<br>cout << "c2 = " << endl << " " << contours->h_next << endl << endl; //output same as above line see output below</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;">// If you assign contours->h_next to a new variable "c" </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>CvSeq* c = contours->h_next;</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;">// then cout contours->h_next the output of the below 2 cout's is still the same as the output of the above 2 - see output below</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>cout << "c3 = " << endl << " " << contours->h_next << endl << endl;<br>cout << "c4 = " << endl << " " << contours->h_next << endl << endl;</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;">// but if you assign contours->h_next back to contours the output of the next 2 couts is different than above 4 <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;">// see output below</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> contours = contours->h_next;<br>cout
<< "c5 = " << endl << " " << contours->h_next << endl << endl;<br>cout << "c6 = " << endl << " " << contours->h_next << endl << endl;<br><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;">here is the cout output</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;">c1 = <br> 0x182f730</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;">c2 = <br> 0x182f730<br><br>c3 = <br> 0x182f730<br><br>c4 = <br> 0x182f730<br><br>c5 = <br> 0x182f560<br><br>c6 = <br> 0x182f560</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;">The struct CvSeq is defined as this</div><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;">#define CV_TREE_NODE_FIELDS(node_type) \
<br> int flags; /* Miscellaneous flags.
*/ \
<br> int header_size; /* Size of sequence header. */ \
<br> struct node_type* h_prev; /* Previous sequence. */ \
<br> struct node_type* h_next; /* Next sequence. */ \
<br> struct node_type* v_prev; /* 2nd previous sequence. */ \
<br> struct node_type* v_next /* 2nd next sequence. */
<br> <br>/*
<br> Read/Write sequence.
<br> Elements can be dynamically inserted to or deleted from the sequence.
<br>*/
<br>#define CV_SEQUENCE_FIELDS() \
<br> CV_TREE_NODE_FIELDS(CvSeq); \
<br> int total; /* Total number of elements. */ \
<br> int elem_size; /* Size of
sequence element in bytes. */ \
<br> schar* block_max; /* Maximal bound of the last block. */ \
<br> schar* ptr; /* Current write pointer. */ \
<br> int delta_elems; /* Grow seq this many at a time. */ \
<br> CvMemStorage* storage; /* Where the seq is stored. */ \
<br> CvSeqBlock* free_blocks; /* Free blocks
list. */ \
<br> CvSeqBlock* first; /* Pointer to the first sequence block. */
<br> <br>typedef struct CvSeq
<br>{
<br> CV_SEQUENCE_FIELDS()
<br>}
<br>CvSeq;<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;">Im not getting the same thing as in lisp with my struct like this - SWIG wrapped <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>(cffi:defcstruct cv-seq<br> (flags :int)<br> (header-size :int)<br> (h-prev :pointer)<br> (h-next :pointer)<br> (v-prev :pointer)<br> (v-next :pointer)<br> (total :int)<br> (elem-size :int)<br> (block-max
:pointer)<br> (ptr :pointer)<br> (delta-elems :int)<br> (storage :pointer)<br> (free-blocks :pointer)<br> (first :pointer))</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;">with the below code my output is the same for both princ...not newline of course =)<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;">(with-foreign-object (contours '(:pointer (:struct cv-seq)))<br> (find-contours img-grayscale storage contours<br> (size-of cv-contour) +retr-list+ <br> +chain-approx-simple+
(point 0 0))<br><br> (with-foreign-slots ((h-next) contours (:struct cv-seq))<br> (setf contours h-next)<br> (princ contours)<br> (princ #\newline)<br> (setf contours h-next)<br> (princ contours)))</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;">any help on fixing my struct, my coding or editing this post =) is much appreciated</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;">Cheers!<br></div></div></div></div><br><br></div> </blockquote> </div> </div> </div> </div></body></html>