|
From: Martin B. <ba...@ki...> - 2010-07-23 15:52:46
|
Hi,
I have written some typemaps that convert numpy arrays to cv::Mat and back,
using fragments from the excellent numpy.i. Basically they look like:
typemap(in) const cv::Mat& {
$1 = array_to_mat($input);
if ($1 == NULL)
SWIG_fail;
}
typemap(int) cv::Mat& {
...
}
...
This works fine. I'm having problems however with generating proper
conversion function for std::vector<cv::Mat> from a *list* of numpy arrays.
Basically I have a function
void do_something(const std::vector<cv::Mat>& input);
and I want to call it with
input = [numpy.zeros((10,10)) for i in range(10)]
do_something(input)
I tried
namespace std {
%template(MatVector) vector<cv::Mat>;
}
but this did not have the desired effect. Looking at the generated code, it
seems as if swig does not use my defined typemaps to convert the input numpy
arrays within the list to cv::Mats. I have also tried understanding how
std_vector.i works but I was not able to wrap my head around it...
Is there any way to achieve this?
Thanks
Martin
|