Alright, there are lots of problems here:
%module AesAutoWhiteBalance
%{
#define SWIG_FILE_WITH_INIT
#include "AesAutoWhiteBalance.h"
%}
// Include the NumPy typemaps
%include "numpy.i"
%init %{
import_array();
%}
%fragment("NumPy_Fragments");
// Wrap the AesAutoWhiteBalance_Balance function
%apply (unsigned short* IN_ARRAY1, int DIM1) {
(unsigned short* measurementsR, int size_r),
(unsigned short* measurementsG, int size_g),
(unsigned short* measurementsB, int size_b) };
// Apply the typemaps for output argument
%apply (float* INPLACE_ARRAY1, int DIM1) { (float* balancingCoeffs, int out_size) };
/* Manual wrapping comes here */
%inline %{
/* takes as input two numpy arrays */
void balance(
unsigned short * measurementsR, int size_r,
unsigned short * measurementsG, int size_g,
unsigned short * measurementsB, int size_b,
int bitWidth,
float* balancingCoeffs, int out_size
) {
if(3 != out_size)
{
PyErr_Format(PyExc_ValueError, "Parameter balancingCoeffs must have length 3.");
return;
}
if((size_r != size_g) || (size_r != size_b))
{
PyErr_Format(PyExc_ValueError, "The measurement arrays have different lengths: R:%d, G:%d, B:%d", size_r, size_g, size_b);
return;
}
/* calls the original funcion, providing only the size of the first */
AesAutoWhiteBalance_Balance(measurementsR, measurementsG, measurementsB, size_r, bitWidth, balancingCoeffs);
return;
}
%}