<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><span style="" class="">You have 
been so kind helping me with these issues, If you don't mind I would 
like to iclunde you in my contributions.lisp file with a Thank You.  Can 
you look over my suggested add on and let me know if the information is 
correct and if there is a URL I can include. I like to include URL's as 
an extra thank you. If you don't want to be included pls let me know. 
Trust me no harm done.<br style="" class=""><br style="" class=""><br style="" class="">;;Thank you to Willem Rein Oudshoorn from CFFI-DEVEL who has made possible my inclusion of finalizers <br style="" class="">;;in this library. He has helped me to iron out a few bugs and has answered quite a few questions of <br style="" class="">;;mine. The knowledge I gained from those answers has really made this a much better library.<br style="" class=""></span><div style="" class=""><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 , Joeish W
 <joeish80829@yahoo.com> wrote:<br style="" class=""> </font> </div> <blockquote class="" style="">  <div style="" class=""><div style="" class="" id="yiv7774309674"><div style="" class=""><div class="" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div class="" style=""><span class="" style="">I have 2 examples of how I was planning to call functions. 1 example is the function that just creates the mat. I changed the name to %mat instead of %cv-mat so it would match OpenCV's Mat class name better. The other example, add, I provide because it is an example of a function that would accept a mat as a parameter, I use add here as an example of all functions that would accept either my garbarge collected verion or my non garbage collected. <br class="" style="" clear="none"><br class="" style="" clear="none">I plan to provide both so, if you absolutely need
 to, you can get a speed increase. Also fnalizers seem to be twice as slow as manual memory management and 4 times slower than with-* macros, and I was advised by my tutor to include all 3 forms of MM.  All of
 the functions to create the %mat and %mat-expr type are written correctly for both. I was hoping you can give me a thumbs up on if the 2 examples are good, so I can go ahead and write all of my finalizers for all of my types. <br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">Example 1:<br class="" style="" clear="none"><br class="" style="" clear="none">;; Mat::Mat()<br class="" style="" clear="none">;; Mat* cv_create_Mat()<br class="" style="" clear="none">(defcfun ("cv_create_Mat" %mat) %mat<br class="" style="" clear="none">  "MAT constructor")<br class="" style="" clear="none"><br class="" style="" clear="none">;; Mat::Mat()<br class="" style="" clear="none">;; Mat* cv_create_Mat()<br class="" style="" clear="none">(defcfun ("cv_create_Mat" %%mat) (%mat :garbage-collect t))<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">(defun mat
 (&rest args)<br class="" style="" clear="none">  (cond ((eq (first args) nil) (%mat))<br class="" style="" clear="none">    ((eq :t (car args)) (%%mat))<br class="" style="" clear="none">    (t
 nil)))<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">Example 2:<br class="" style="" clear="none"><br class="" style="" clear="none">;; MatExpr + operator<br class="" style="" clear="none">;; MatExpr* cv_Mat_add(Mat* m1, Mat* m2)<br class="" style="" clear="none">(defcfun ("cv_Mat_add" %add) (:pointer mat-expr)<br class="" style="" clear="none">  (m1 %mat)<br class="" style="" clear="none">  (m2 %mat))<br class="" style="" clear="none"><br class="" style="" clear="none">;; MatExpr + operator<br class="" style="" clear="none">;; MatExpr* cv_Mat_add(Mat* m1, Mat* m2)<br class="" style="" clear="none">(defcfun ("cv_Mat_add" %%add) (%mat-expr :garbage-collect t)<br class="" style="" clear="none">  (m1 %mat)<br class="" style="" clear="none">  (m2 %mat))<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style=""
 clear="none">(defun add (&rest args)<br class="" style="" clear="none">  (cond ((eq :t (last args)) (%%add (first args) (second args)))<br class="" style="" clear="none">           (t (%add (first args) (second
 args)))))<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">Btw you asked what my motivation for writing an OpenCV wrapper was and it's because of these 4 reasons:<br class="" style="" clear="none"><br class="" style="" clear="none">1. The libraries that exist are wrappers for the deprecated C OpenCV interface,  mine is for the consistently updated C++ interface<br class="" style="" clear="none"><br class="" style="" clear="none">2: They are incomplete, mine is 3 times bigger or more than the two that exist now , and it aims to be complete within 3 months max<br class="" style="" clear="none"><br class="" style="" clear="none">3. Mine is aiming for inclusion in OpenCV proper, a generator is being built that will automatically generate all of my low-level functions/types/constants when OpenCV is built...so it will always be up to date<br class="" style=""
 clear="none"><br class="" style="" clear="none">4: I'm helping the C wrappers for the C++ interface that this library binds to so I will be at the forefront of
 the knowledge needed to keep this library, supported and revolutionary as the first complete Lisp computer vision library<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"></span></div><div style="" class="" id="yiv7774309674yqt46204"><div class="" style="display:block"> <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 class="" dir="ltr" style=""> <font class="" style="" face="Arial" size="2"> On Saturday, April 26, 2014 5:55 AM, Joeish W <joeish80829@yahoo.com> wrote:<br class="" style="" clear="none"> </font> </div> <blockquote class="" style="">  <div class="" style=""><div class="" id="yiv7774309674" style=""><div
 class="" style=""><div class="" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div class="" id="yiv7774309674" style=""><div class="" style=""><div class="" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt">Some new exciting information...I ran the create-mat function a million times and my memory went up a slight bit,  I ran a million more and it went up a gain..I ran a million more and it actually leveled off. After running a million more times it actually started going down.  I was able to see the Lisp GC at work...It doesn't seem to kick in until memory becomes an issue, again sir ...it was an honor<br class="" style="" clear="none"><div class="" id="yiv7774309674yui_3_13_0_12_1398512961307_8" style=""><span class=""
 id="yiv7774309674yui_3_13_0_12_1398512961307_15" style=""><br class="" style="" clear="none"></span></div><div class="" id="yiv7774309674yqt36003" style=""><div class="" id="yiv7774309674yqt74208" style=""><div class="" id="yiv7774309674yui_3_13_0_12_1398512961307_10" style="display:block"> <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 class="" dir="ltr" style=""> <font class="" style="" face="Arial" size="2"> On Saturday, April 26, 2014 4:24 AM, Willem Rein Oudshoorn <woudshoo@xs4all.nl> wrote:<br class="" style="" clear="none"> </font> </div> <blockquote class="" style="">  <div class="" style="">Joeish W <<a rel="nofollow" shape="rect" class="" style="" ymailto="mailto:joeish80829@yahoo.com" target="_blank"
 href="mailto:joeish80829@yahoo.com">joeish80829@yahoo.com</a>> writes:<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">> (defcfun ("cv_create_Mat" create-mat) (%cv-mat :garbage-collect t))<br class="" style="" clear="none">><br class="" style="" clear="none">> a million times to bench mark it it was actually 4 times slower than<br class="" style="" clear="none">> my original code....I really do need this all to be fast code, since<br class="" style="" clear="none">> computer vision  can benefit from the speed.  Also I noticed when I<br class="" style="" clear="none">> ran the (create-mat) function 1,000,000
 times my ram went up a tiny<br class="" style="" clear="none">> bit and didn't go down..Is that normal for finalizers.<br class="" style="" clear="none"><br class="" style="" clear="none">Well, that it is a bit slower is not really surprising because:<br class="" style="" clear="none"><br class="" style="" clear="none">1. CLOS classes are instantatied to wrap the pointer <br class="" style="" clear="none">2. The trivial garbage needs to keep track of the objects<br class="" style="" clear="none">3. The conversion code is done by generic functions.<br class="" style="" clear="none"><br class="" style="" clear="none">However, this is solvable.  But I really would not focus on this right<br class="" style="" clear="none">now.  I cannot really imagine that creating the matrix is the<br class="" style="" clear="none">bottleneck.  <br class="" style="" clear="none"><br class="" style="" clear="none">With respect to the memory, as long as it
 does not grow indefinitely I<br class="" style="" clear="none">would not worry about it.  The trivial garbage package might introduce<br class="" style="" clear="none">some memory overhead which is not directly reclaimed by the garbage<br class="" style="" clear="none">collector.  <br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">> When I use<br class="" style="" clear="none">> with-* macros or manual MM I don't get an increase in ram on my<br class="" style="" clear="none">> system.  I would like to include finalizers in my library but is there<br class="" style="" clear="none">> any way to
 overcome these obstacles to make that happen...Again the<br class="" style="" clear="none">> time you took to help me on this is much appreciated. :)You really<br class="" style="" clear="none">> helped me to understand.<br class="" style="" clear="none"><br class="" style="" clear="none">Using `with-*` macros is a good idea.  Inside these macros you can<br class="" style="" clear="none">do the manual garbage collection and avoid maybe the generic type<br class="" style="" clear="none">conversion.    But to make it robust the `with-*` macros will not (I<br class="" style="" clear="none">expect) be faster than the code you have now.  <br class="" style="" clear="none"><br class="" style="" clear="none">Making the code fast is certainly doable and not hard, but you should<br class="" style="" clear="none">first make it work and figure what needs to be fast and which<br class="" style="" clear="none">conveniences you are willing
 to give up for the speed improvement.<br class="" style="" clear="none"><br class="" style="" clear="none">Wim Oudshoorn<br class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none">_______________________________________________<br class="" style="" clear="none">Cffi-devel mailing list<br class="" style="" clear="none"><a rel="nofollow" shape="rect" class="" style="" ymailto="mailto:Cffi-devel@common-lisp.net" target="_blank" href="mailto:Cffi-devel@common-lisp.net">Cffi-devel@common-lisp.net</a><br class="" style="" clear="none"><a rel="nofollow" shape="rect" class="" style="" 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 class="" style="" clear="none"><br class="" style="" clear="none"><br class="" style="" clear="none"></div> </blockquote>  </div> </div>   </div></div></div>
 </div></div></div></div></div></div><br class="" style="" clear="none"><br class="" style="" clear="none"></div> </blockquote>  </div> </div>   </div></div> </div></div></div><br style="" class=""><br style="" class=""></div> </blockquote>  </div> </div>   </div> </div></body></html>