title: Passing a numpy array to Delphi dll
body: <p>I am trying to implement an image classification algorithm in Python. The problem is that python takes very long with looping through the array. That's why I decided to write a Delphi dll which performs the array-processing. My problem is that I don't know how to pass the multidimensional python-array to my dll-function.</p>
  
  <p>Delphi dll extract: (I use this function only for testing)</p>
  
  <pre><code>type
      TImgArray = array of array of Integer;
  
  function count(a: TImgArray): Integer; cdecl;
  begin
      result:= high(a);
  end;
  </code></pre>
  
  <p>relevant Python code:</p>
  
  <pre><code>arraydll = cdll.LoadLibrary("C:\\ArrayFunctions.dll")
  
  c_int_p = ctypes.POINTER(ctypes.c_int32)
  data = valBD.ReadAsArray()
  data = data.astype(np.int32)
  data_p = data.ctypes.data_as(c_int_p)
  
  print arraydll.count(data_p)
  </code></pre>
  
  <p>The value returned by the dll-function is not the right one (it is 2816 instead of
   7339). That's why I guess that there's somethin wrong with my type-conversion :(
  Thanks in advance,
  Mario</p>