[Cffi-devel] Wrapping a C wrapper for OpenCV's vector<Mat>

Joeish W joeish80829 at yahoo.com
Tue Apr 1 06:49:59 UTC 2014


Here is the C wrapper for vector<Mat> which is just a typename for a C++ vector:

vector_Mat* std_carrayTovectorm(Mat* a, size_t len) {
    vector<Mat>* v = new vector<Mat>;
    for(size_t i = 0; i < len; i++) 
        v->push_back(a[i]);
    return v;
}

Here is my wrapper in CFFI:

;; vector_Mat*
(defctype vector-mat :pointer)


(defcfun ("std_carrayTovectorm" %c-arr-to-vector-mat) (:pointer vector-mat)
  (a (:pointer mat))
  (len :unsigned-int))


When I use it as below I get "unhandled memory fault error",  If anyone can check my work I would be much appreciative. I can post my mat-value wrapper if necessary. It works fine though.



(%c-arr-to-vector-mat (foreign-alloc :pointer :initial-contents(list  (mat-value 4 4 +32s+ (scalar 1 2 3)) (mat-value 4 4 +32s+ (scalar 1 2 3)))) 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20140331/8cba9039/attachment.html>


More information about the cffi-devel mailing list