# CxxWrap How to handle Array of Array

**URL:** <https://discourse.julialang.org/t/cxxwrap-how-to-handle-array-of-array/107498>\
**Category:** General Usage\
**Tags:** cxxwrap\
**Created:** [December 12, 2023, 1:10pm UTC](https://discourse.julialang.org/t/cxxwrap-how-to-handle-array-of-array/107498 "2023-12-12T13:10:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kemu](https://avatars.discourse-cdn.com/v4/letter/k/7993a0/32.png) [@kemu](https://discourse.julialang.org/u/kemu)\
**Post date:** [December 12, 2023, 1:10pm UTC](https://discourse.julialang.org/t/cxxwrap-how-to-handle-array-of-array/107498/1 "2023-12-12T13:10:07Z")

</div>

I am using CxxWrap to create a simple wrapper for OpenCV.

cv::decomposeHomographyMat() takes `std::vector<cv::Mat>` as an argument, how can I wrap this?

I tried `jlcxx::ArrayRef<jlcxx::ArrayRef<double, 2>, 1>` but I get static\_assert as shown below.

```cpp
int decomposeHomographyMat(
    jlcxx::ArrayRef<double, 2> H,
    jlcxx::ArrayRef<double, 2> K,
    jlcxx::ArrayRef<jlcxx::ArrayRef<double, 2>, 1> rotations,
    jlcxx::ArrayRef<jlcxx::ArrayRef<double, 2>, 1> translations,
    jlcxx::ArrayRef<jlcxx::ArrayRef<double, 2>, 1> normals )		
{
    cv::Mat HMat(3, 3, CV_64F, H.data());
    cv::Mat KMat(3, 3, CV_64F, K.data());
    std::vector<cv::Mat> rMat,tMat,nMat;
    auto n = cv::decomposeHomographyMat(HMat, KMat, rMat, tMat, nMat);

    double* data;
    for(int i = 0 ; i < n ; ++i)
    {
        data = new double[3*3];
        memcpy( data, (double*)(rMat[i].data), 3*3*sizeof(double));
        rotations.push_back(jlcxx::ArrayRef<double, 2>(true, data, 3, 3));

        data = new double[3];
        memcpy( data, (double*)(tMat[i].data), 3*sizeof(double));
        translations.push_back(jlcxx::ArrayRef<double, 2>(true, data, 3, 1));

        data = new double[3];
        memcpy( data, (double*)(nMat[i].data), 3*sizeof(double));
        normals.push_back(jlcxx::ArrayRef<double, 2>(true, data, 3, 1));
    }

    return n;
}

```

```julia
[build] /Users/kemu/.julia/artifacts/9fbaafa4a3ec669b8c626f20771d9056d16f4f5a/include/jlcxx/array.hpp:223:5: error: static assertion failed due to requirement 'std::is_same<jl_array_t *, jlcxx::ArrayRef<double, 2>>::value': ArrayRef::push_back is only for arrays of fundamental types
[build] static_assert(std::is_same<julia_t,ValueT>::value, "ArrayRef::push_back is only for arrays of fundamental types");
[build] ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

```

The OpenCV.jl and Python version of OpenCV using PyCall.jl and PythonCall.jl have their own problems from my point of view, so let these methods be out of scope for this time.
