<html><body><div style="color:#000; background-color:#fff; font-family:Courier New, courier, monaco, monospace, sans-serif;font-size:14pt"><div id="question-header">
<h1 itemprop="name"><font size="3"><a href="http://stackoverflow.com/questions/19133763/how-do-i-write-a-comparable-cffitranslate-into-foreign-defmethod-for-this-cffi" class="question-hyperlink">How do i write a comparable cffi:translate-into foreign defmethod for this cffi:translate-from-foreign?</a></font></h1><font size="3">
</font></div><font size="3">
</font><div class="everyonelovesstackoverflow" id="adzerk650293910">
</div><font size="3">
</font><table><tbody><tr><td class="votecell">
<div class="vote">
<font size="3"><a href="" class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>
<span class="vote-count-post ">0</span>
<a href="" class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>
<a class="star-off" href="http://stackoverflow.com/questions/19133763/how-do-i-write-a-comparable-cffitranslate-into-foreign-defmethod-for-this-cffi#" title="This is a favorite question (click again to undo)">favorite</a></font>
</div>
</td><font size="3">
</font><td class="postcell"><font size="3">
</font><div><font size="3">
</font><div class="post-text" itemprop="description"><font size="3">
</font><div>ok I tried this translate-from-foreign method and it did work
i have these defined in my structs.lisp file in my library which loads first before all my other dependencies</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">defcstruct </span><span class="pun">(</span><span class="pln">cv</span><span class="pun">-</span><span class="pln">size </span><span class="pun">:</span><span class="kwd">class</span><span class="pln"> cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">-</span><span class="pln">type</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">width </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">height </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">defmethod cffi</span><span class="pun">:</span><span class="pln">translate</span><span class="pun">-</span><span class="kwd">from</span><span class="pun">-</span><span class="pln">foreign </span><span class="pun">(</span><span class="pln">p </span><span class="pun">(</span><span class="pln">type cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">-</span><span class="pln">type</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="kwd">let</span><span class="pln"> </span><span class="pun">((</span><span class="pln">plist </span><span class="pun">(</span><span class="pln">call</span><span class="pun">-</span><span class="kwd">next</span><span class="pun">-</span><span class="pln">method</span><span class="pun">)))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">make</span><span class="pun">-</span><span class="pln">size </span><span class="pun">:</span><span class="pln">width </span><span class="pun">(</span><span class="pln">getf plist </span><span class="str">'width)
:height (getf plist '</span><span class="pln">height</span><span class="pun">))))</span></code></pre>
<div>and my opencv wrappers for CvGetSize and cvCreateImage, get-size and create-image, are defined like this</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pun">;;</span><span class="pln"> </span><span class="typ">CvSize</span><span class="pln"> cvGetSize</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">CvArr</span><span class="pun">*</span><span class="pln"> arr</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">defcfun </span><span class="pun">(</span><span class="str">"cvGetSize"</span><span class="pln"> </span><span class="kwd">get</span><span class="pun">-</span><span class="pln">size</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(:</span><span class="kwd">struct</span><span class="pln"> cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">arr cv</span><span class="pun">-</span><span class="pln">arr</span><span class="pun">))</span><span class="pln">
</span><span class="pun">;;</span><span class="pln"> </span><span class="typ">IplImage</span><span class="pun">*</span><span class="pln"> cvCreateImage</span><span class="pun">(</span><span class="typ">CvSize</span><span class="pln"> size</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> depth</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> channels</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">defcfun </span><span class="pun">(</span><span class="str">"cvCreateImage"</span><span class="pln"> </span><span class="pun">%</span><span class="pln">create</span><span class="pun">-</span><span class="pln">image</span><span class="pun">)</span><span class="pln"> ipl</span><span class="pun">-</span><span class="pln">image
</span><span class="pun">(</span><span class="pln">size </span><span class="pun">:</span><span class="pln">int64</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">depth </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">channels </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">defun create</span><span class="pun">-</span><span class="pln">image </span><span class="pun">(</span><span class="pln">size depth channels</span><span class="pun">)</span><span class="pln">
</span><span class="str">"Create an image with dimensions given by SIZE, DEPTH bits per
channel, and CHANNELS number of channels."</span><span class="pln">
</span><span class="pun">(</span><span class="kwd">let</span><span class="pln"> </span><span class="pun">((</span><span class="pln">nsize </span><span class="pun">(</span><span class="pln">size</span><span class="pun">-></span><span class="pln">int64 size</span><span class="pun">)))</span><span class="pln">
</span><span class="pun">(%</span><span class="pln">create</span><span class="pun">-</span><span class="pln">image nsize depth channels</span><span class="pun">)))</span></code></pre>
<div>here is the definition of size->int64</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pun">(</span><span class="pln">DEFUN SIZE</span><span class="pun">-></span><span class="pln">INT64 </span><span class="pun">(</span><span class="pln">S</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(+</span><span class="pln"> </span><span class="pun">(</span><span class="pln">SIZE</span><span class="pun">-</span><span class="pln">WIDTH S</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ASH </span><span class="pun">(</span><span class="pln">SIZE</span><span class="pun">-</span><span class="pln">HEIGHT S</span><span class="pun">)</span><span class="pln"> </span><span class="lit">32</span><span class="pun">)))</span><span class="pln">
it converts </span><span class="kwd">get</span><span class="pun">-</span><span class="pln">size output which </span><span class="kwd">is</span><span class="pln"> a structure here</span><span class="pun">:</span><span class="pln">
</span><span class="com">#S(SIZE :WIDTH 640 :HEIGHT 480)</span><span class="pln">
</span><span class="kwd">into</span><span class="pln"> </span><span class="lit">64</span><span class="pun">-</span><span class="pln">bit integer</span><span class="pun">,</span><span class="pln"> which CFFI can handle </span></code></pre>
<div>but i love the idea of the translate-foreign defmethod's</div>
<div>so i was wondering if you can show my how to make the
translate-into-foreign version of the below from method this would
really make my library awesome</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pun">(</span><span class="pln">defmethod cffi</span><span class="pun">:</span><span class="pln">translate</span><span class="pun">-</span><span class="kwd">from</span><span class="pun">-</span><span class="pln">foreign </span><span class="pun">(</span><span class="pln">p </span><span class="pun">(</span><span class="pln">type cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">-</span><span class="pln">type</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="kwd">let</span><span class="pln"> </span><span class="pun">((</span><span class="pln">plist </span><span class="pun">(</span><span class="pln">call</span><span class="pun">-</span><span class="kwd">next</span><span class="pun">-</span><span class="pln">method</span><span class="pun">)))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">make</span><span class="pun">-</span><span class="pln">size </span><span class="pun">:</span><span class="pln">width </span><span class="pun">(</span><span class="pln">getf plist </span><span class="str">'width)
:height (getf plist '</span><span class="pln">height</span><span class="pun">))))</span></code></pre>
<div>I was going to try stuff and add it but for the get-size output
structure, it isnt a plist so not really sure what to put there for the</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pun">(</span><span class="kwd">let</span><span class="pln"> </span><span class="pun">((</span><span class="pln">plist </span><span class="pun">(</span><span class="pln">call</span><span class="pun">-</span><span class="kwd">next</span><span class="pun">-</span><span class="pln">method</span><span class="pun">)))</span></code></pre>
<div>part, for the </div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun">(</span><span class="pln">make</span><span class="pun">-</span><span class="pln">size </span><span class="pun">:</span><span class="pln">width </span><span class="pun">(</span><span class="pln">getf plist </span><span class="str">'width)
:height (getf plist '</span><span class="pln">height</span><span class="pun">))))</span></code></pre>
<div>part, i was hoping to find another method other than the size->64 function because that was made 2 years ago when cl-opencv <a href="https://github.com/ryepup/cl-opencv" rel="nofollow">https://github.com/ryepup/cl-opencv</a>
first came out and
i would like to make an even better wrapper than that...i've already
taken cl-opencv added 100 new function 5000 lines of code samples and
documentation and a new structs.lisp file so i would love if someone
could help me with all the latest cffi tools so i could do something
else than int64...plus the if i have a funtion to wrap where the int64
thing wouldnt work ill be ready</div>
<div>Thanks again to all the answerers cffi-devel. you all really have helped my library great.</div><br>Edit: I also tried it this way, Below is my repl history showing my steps<br><pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln">
</span><span class="pun">;;</span><span class="pln"> </span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">foreign</span><span class="pun">-</span><span class="pln">type</span><span class="pun">-</span><span class="pln">size </span><span class="str">'(:struct cv-size)) = 8
(cffi:defcstruct (cv-size :class cv-size-type)
(width :int)
(height :int))
(defmethod cffi:translate-from-foreign (p (type cv-size-type))
(let ((plist (call-next-method)))
(make-size :width (getf plist '</span><span class="pln">width</span><span class="pun">)</span><span class="pln">
</span><span class="pun">:</span><span class="pln">height </span><span class="pun">(</span><span class="pln">getf plist </span><span class="str">'height))))
(defmethod cffi:translate-to-foreign (value (type cv-size-type))
(let ((plist ()))
(setf (getf plist '</span><span class="pln">width</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(</span><span class="pln">size</span><span class="pun">-</span><span class="pln">width value</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">getf plist </span><span class="str">'height) (size-height value))
(call-next-method plist type)))
;; CvSize cvGetSize(const CvArr* arr)
(cffi:defcfun ("cvGetSize" get-size) (:struct cv-size)
(arr (:pointer cv-arr)))
;; IplImage* cvCreateImage(CvSize size, int depth, int channels)
(cffi:defcfun ("cvCreateImage" create-image) (:pointer (:struct ipl-image))
(size (:struct cv-size))
(depth :int)
(channels :int))
CREATE-IMAGE
CL-OPENCV> (defparameter capture (create-camera-capture 0))
(defparameter frame (query-frame capture))
(defparameter img-size (get-size frame))
(defparameter img (create-image img-size +ipl-depth-8u+ 3))</span></code></pre>
<div>but i get error </div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="typ">There</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">no</span><span class="pln"> applicable method </span><span class="kwd">for</span><span class="pln"> the </span><span class="kwd">generic</span><span class="pln"> </span><span class="kwd">function</span><span class="pln">
</span><span class="com">#<STANDARD-GENERIC-FUNCTION</span><span class="pln">
CFFI</span><span class="pun">:</span><span class="pln">TRANSLATE</span><span class="pun">-</span><span class="pln">INTO</span><span class="pun">-</span><span class="pln">FOREIGN</span><span class="pun">-</span><span class="pln">MEMORY </span><span class="pun">(</span><span class="lit">5</span><span class="pun">)></span><span class="pln">
</span><span class="kwd">when</span><span class="pln"> called </span><span class="kwd">with</span><span class="pln"> arguments
</span><span class="pun">(#</span><span class="pln">S</span><span class="pun">(</span><span class="pln">SIZE </span><span class="pun">:</span><span class="pln">WIDTH </span><span class="lit">640</span><span class="pln"> </span><span class="pun">:</span><span class="pln">HEIGHT </span><span class="lit">480</span><span class="pun">)</span><span class="pln"> </span><span class="com">#<CV-SIZE-TYPE CV-SIZE></span><span class="pln">
</span><span class="com">#.(SB-SYS:INT-SAP #X7FFFE5427FF0)).</span><span class="pln">
</span><span class="pun">[</span><span class="typ">Condition</span><span class="pln"> of type SIMPLE</span><span class="pun">-</span><span class="pln">ERROR</span><span class="pun">]</span></code></pre>
<div>because the translate-from-foreign function i have is converting the output from cv-size
into a structure </div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln">CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln"> img</span><span class="pun">-</span><span class="pln">size
</span><span class="com">#S(SIZE :WIDTH 640 :HEIGHT 480)</span></code></pre>
<div>I appreciate the translate-into foreign function but with the old
translate-from-foreign function it isnt woking, because of the make-size
part...would you help me figure out what cvCreateImage needs to satisfy
it ....here is the link 4 that:</div>
<div><a href="http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=eimage#createimage" rel="nofollow">http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=eimage#createimage</a></div>
<div>I can get this version below to run right(i show the repl session)</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="lit">5</span><span class="pln">
CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln"> </span><span class="pun">;</span><span class="pln"> TODO SIZE</span><span class="pun">-</span><span class="pln">WIDTH AND HEIGHT
</span><span class="pun">;;</span><span class="pln"> </span><span class="typ">CvSize</span><span class="pln"> cvGetSize</span><span class="pun">(</span><span class="kwd">const</span><span class="pln"> </span><span class="typ">CvArr</span><span class="pun">*</span><span class="pln"> arr</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">defcfun </span><span class="pun">(</span><span class="str">"cvGetSize"</span><span class="pln"> </span><span class="kwd">get</span><span class="pun">-</span><span class="pln">size</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(:</span><span class="pln">pointer </span><span class="pun">(:</span><span class="kwd">struct</span><span class="pln"> cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">arr cv</span><span class="pun">-</span><span class="pln">arr</span><span class="pun">))</span><span class="pln">
</span><span class="pun">;;</span><span class="pln"> </span><span class="typ">IplImage</span><span class="pun">*</span><span class="pln"> cvCreateImage</span><span class="pun">(</span><span class="typ">CvSize</span><span class="pln"> size</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> depth</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> channels</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="pln">defcfun </span><span class="pun">(</span><span class="str">"cvCreateImage"</span><span class="pln"> create</span><span class="pun">-</span><span class="pln">image</span><span class="pun">)</span><span class="pln"> </span><span class="pun">(:</span><span class="pln">pointer </span><span class="pun">(:</span><span class="kwd">struct</span><span class="pln"> ipl</span><span class="pun">-</span><span class="pln">image</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">size </span><span class="pun">(:</span><span class="pln">pointer </span><span class="pun">(:</span><span class="kwd">struct</span><span class="pln"> cv</span><span class="pun">-</span><span class="pln">size</span><span class="pun">)))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">depth </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">)</span><span class="pln">
</span><span class="pun">(</span><span class="pln">channels </span><span class="pun">:</span><span class="kwd">int</span><span class="pun">))</span><span class="pln">
STYLE</span><span class="pun">-</span><span class="pln">WARNING</span><span class="pun">:</span><span class="pln"> redefining CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">:</span><span class="pln">GET</span><span class="pun">-</span><span class="pln">SIZE </span><span class="kwd">in</span><span class="pln"> DEFUN
STYLE</span><span class="pun">-</span><span class="pln">WARNING</span><span class="pun">:</span><span class="pln"> redefining CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">:</span><span class="pln">CREATE</span><span class="pun">-</span><span class="pln">IMAGE </span><span class="kwd">in</span><span class="pln"> DEFUN
CREATE</span><span class="pun">-</span><span class="pln">IMAGE
CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln"> </span><span class="pun">(</span><span class="pln">defparameter capture </span><span class="pun">(</span><span class="pln">create</span><span class="pun">-</span><span class="pln">camera</span><span class="pun">-</span><span class="pln">capture </span><span class="lit">0</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">defparameter frame </span><span class="pun">(</span><span class="pln">query</span><span class="pun">-</span><span class="pln">frame capture</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">defparameter img</span><span class="pun">-</span><span class="pln">size </span><span class="pun">(</span><span class="kwd">get</span><span class="pun">-</span><span class="pln">size frame</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">defparameter img </span><span class="pun">(</span><span class="pln">create</span><span class="pun">-</span><span class="pln">image img</span><span class="pun">-</span><span class="pln">size </span><span class="pun">+</span><span class="pln">ipl</span><span class="pun">-</span><span class="pln">depth</span><span class="pun">-</span><span class="lit">8u</span><span class="pun">+</span><span class="pln"> </span><span class="lit">3</span><span class="pun">))</span><span class="pln">
IMG
CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln"> </span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="kwd">with</span><span class="pun">-</span><span class="pln">foreign</span><span class="pun">-</span><span class="pln">slots </span><span class="pun">((</span><span class="pln">n</span><span class="pun">-</span><span class="pln">size id n</span><span class="pun">-</span><span class="pln">channels
alpha</span><span class="pun">-</span><span class="pln">channel depth color</span><span class="pun">-</span><span class="pln">model
channel</span><span class="pun">-</span><span class="pln">seq data</span><span class="pun">-</span><span class="pln">order origin
align width height roi
mask</span><span class="pun">-</span><span class="pln">roi image</span><span class="pun">-</span><span class="pln">id tile</span><span class="pun">-</span><span class="pln">info
image</span><span class="pun">-</span><span class="pln">size image</span><span class="pun">-</span><span class="pln">data width</span><span class="pun">-</span><span class="pln">step
border</span><span class="pun">-</span><span class="pln">mode border</span><span class="pun">-</span><span class="kwd">const</span><span class="pln"> image</span><span class="pun">-</span><span class="pln">data</span><span class="pun">-</span><span class="pln">origin</span><span class="pun">)</span><span class="pln">
img</span><span class="pun">(:</span><span class="kwd">struct</span><span class="pln"> ipl</span><span class="pun">-</span><span class="pln">image</span><span class="pun">))</span><span class="pln">
</span><span class="pun">(</span><span class="pln">format t </span><span class="str">"n-size = ~a~%id = ~a~%n-channels = ~a~%alpha-channel = ~a~%depth = ~a~%color-model = ~a~%channel-seq = ~a~%data-order = ~a~%origin = ~a~%align = ~a~%width = ~a~%height = ~a~%roi = ~a~%mask-roi = ~a~%image-id = ~a~%tile-info = ~a~%image-size = ~a~%image-data = ~a~%width-step = ~a~%border-mode = ~a~%border-const = ~a~%image-data-origin = ~a~%"</span><span class="pln">
n</span><span class="pun">-</span><span class="pln">size id n</span><span class="pun">-</span><span class="pln">channels
alpha</span><span class="pun">-</span><span class="pln">channel depth color</span><span class="pun">-</span><span class="pln">model
channel</span><span class="pun">-</span><span class="pln">seq data</span><span class="pun">-</span><span class="pln">order origin
align width height roi
mask</span><span class="pun">-</span><span class="pln">rOI image</span><span class="pun">-</span><span class="pln">id tile</span><span class="pun">-</span><span class="pln">info
image</span><span class="pun">-</span><span class="pln">size image</span><span class="pun">-</span><span class="pln">data width</span><span class="pun">-</span><span class="pln">step
border</span><span class="pun">-</span><span class="pln">mode border</span><span class="pun">-</span><span class="kwd">const</span><span class="pln"> image</span><span class="pun">-</span><span class="pln">data</span><span class="pun">-</span><span class="pln">origin</span><span class="pun">))</span><span class="pln">
n</span><span class="pun">-</span><span class="pln">size </span><span class="pun">=</span><span class="pln"> </span><span class="lit">144</span><span class="pln">
id </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln">
n</span><span class="pun">-</span><span class="pln">channels </span><span class="pun">=</span><span class="pln"> </span><span class="lit">3</span><span class="pln">
alpha</span><span class="pun">-</span><span class="pln">channel </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln">
depth </span><span class="pun">=</span><span class="pln"> </span><span class="lit">8</span><span class="pln">
color</span><span class="pun">-</span><span class="pln">model </span><span class="pun">=</span><span class="pln"> </span><span class="lit">4343634</span><span class="pln">
channel</span><span class="pun">-</span><span class="pln">seq </span><span class="pun">=</span><span class="pln"> </span><span class="lit">5392194</span><span class="pln">
data</span><span class="pun">-</span><span class="pln">order </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln">
origin </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln">
align </span><span class="pun">=</span><span class="pln"> </span><span class="lit">4</span><span class="pln">
width </span><span class="pun">=</span><span class="pln"> </span><span class="lit">640</span><span class="pln">
height </span><span class="pun">=</span><span class="pln"> </span><span class="lit">480</span><span class="pln">
roi </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
mask</span><span class="pun">-</span><span class="pln">roi </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
image</span><span class="pun">-</span><span class="pln">id </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
tile</span><span class="pun">-</span><span class="pln">info </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
image</span><span class="pun">-</span><span class="pln">size </span><span class="pun">=</span><span class="pln"> </span><span class="lit">921600</span><span class="pln">
image</span><span class="pun">-</span><span class="pln">data </span><span class="pun">=</span><span class="pln">
width</span><span class="pun">-</span><span class="pln">step </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1920</span><span class="pln">
border</span><span class="pun">-</span><span class="pln">mode </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
border</span><span class="pun">-</span><span class="kwd">const</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="com">#.(SB-SYS:INT-SAP #X00000000)</span><span class="pln">
image</span><span class="pun">-</span><span class="pln">data</span><span class="pun">-</span><span class="pln">origin </span><span class="pun">=</span><span class="pln"> NIL
NIL</span></code></pre>
<div>so i get data from the slots for ipl-image but this does'nt seem like correct way
because <br></div><div>id have to be able to derefrence the cv-size poiner output by get-size </div>
<div>here is documentation on cvGetSize the function im wrapping</div>
<div><a href="http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=eimage#getsize" rel="nofollow">http://docs.opencv.org/modules/core/doc/old_basic_structures.html?highlight=eimage#getsize</a></div>
<div>as u can see it is a pointer</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln">CL</span><span class="pun">-</span><span class="pln">OPENCV</span><span class="pun">></span><span class="pln"> img</span><span class="pun">-</span><span class="pln">size
</span><span class="com">#.(SB-SYS:INT-SAP #X1E000000280)</span></code></pre>
<div>so when i do :</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="kwd">with</span><span class="pun">-</span><span class="pln">foreign</span><span class="pun">-</span><span class="kwd">object</span><span class="pln"> </span><span class="pun">(</span><span class="pln">img</span><span class="pun">-</span><span class="pln">size </span><span class="str">'(:pointer (:struct cv-size)))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) img-size
(list width height)))</span></code></pre>
<div>i get</div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="typ">There</span><span class="pln"> </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">no</span><span class="pln"> applicable method </span><span class="kwd">for</span><span class="pln"> the </span><span class="kwd">generic</span><span class="pln"> </span><span class="kwd">function</span><span class="pln">
</span><span class="com">#<STANDARD-GENERIC-FUNCTION CFFI::SLOTS (1)></span><span class="pln">
</span><span class="kwd">when</span><span class="pln"> called </span><span class="kwd">with</span><span class="pln"> arguments
</span><span class="pun">(#<</span><span class="pln">CFFI</span><span class="pun">::</span><span class="pln">FOREIGN</span><span class="pun">-</span><span class="pln">POINTER</span><span class="pun">-</span><span class="pln">TYPE </span><span class="pun">(:</span><span class="pln">POINTER </span><span class="pun">(:</span><span class="pln">STRUCT CV</span><span class="pun">-</span><span class="pln">SIZE</span><span class="pun">))>).</span><span class="pln">
</span><span class="pun">[</span><span class="typ">Condition</span><span class="pln"> of type SIMPLE</span><span class="pun">-</span><span class="pln">ERROR</span><span class="pun">]</span><span class="pln"> </span></code></pre>
<div>and when i do </div>
<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="pun">(</span><span class="pln">cffi</span><span class="pun">:</span><span class="kwd">with</span><span class="pun">-</span><span class="pln">foreign</span><span class="pun">-</span><span class="kwd">object</span><span class="pln"> </span><span class="pun">(</span><span class="pln">img</span><span class="pun">-</span><span class="pln">size </span><span class="str">'(:struct cv-size))
;; Initialize the slots
;; Return a list with the coordinates
(cffi:with-foreign-slots ((width height) img-size (:struct cv-size))
(list width height)))</span></code></pre>
<div style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: monospace; background-color: transparent; font-style: normal;">i get <br><br></div>
<div style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: monospace; background-color: transparent; font-style: normal;">(346539 0)<br><br></div>
<div>just nonsensical output</div>
<div>i try mem-refing and mem-arefing the pointer and get unhandled memory fault errors</div>
<div>if you can help me figure out how to write compatible </div>
<div>translate-from-foreign</div>
<div>and</div>
<div>translate-into-foreign functions i would be very grateful =).<br><br>but if i use make-size or size-width,height anywhere in them the <br></div><div style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: transparent; font-style: normal;">create-image would have to have the size->int64 in it because they
work <br></div><div style="color: rgb(0, 0, 0); font-size: 18.6667px; font-family: Courier New,courier,monaco,monospace,sans-serif; background-color: transparent; font-style: normal;">only because that function.<br></div>
</div>
<div class="post-taglist">
</div></div></td></tr></tbody></table></div></body></html>