title: Fast cross correlation method in Python
body: <p>I have been recently trying to find a fast and efficient way to perform cross correlation check between two arrays using Python language. After some reading, I found these two options:</p>
  
  <ol>
  <li>The <code>NumPy.correlate()</code> method, which is too slow when it comes to large arrays.</li>
  <li>The <code>cv.MatchTemplate()</code> method, which seems to be much faster.</li>
  </ol>
  
  <p>For obvious reasons, I chose the second option. I tried to execute the following code:</p>
  
  <pre><code>import scipy
  import cv
  
  image = cv.fromarray(scipy.float32(scipy.asarray([1,2,2,1])),allowND=True)
  template = cv.fromarray(scipy.float32(scipy.asarray([2,2])),allowND=True)
  result = cv.fromarray(scipy.float32(scipy.asarray([0,0,0])),allowND=True)
  cv.MatchTemplate(image,template,result,cv.CV_TM_CCORR)
  </code></pre>
  
  <p>Even though this code suppose to be very simple, it throws the next error:</p>
  
  <pre><code>OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /builddir/build/BUILD/OpenCV-2.1.0/src/cxcore/cxarray.cpp, line 2476
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  cv.error: Unrecognized or unsupported array type
  </code></pre>
  
  <p>After a few hours of frustrating tries, I am still stuck! Does anybody have any suggestion?</p>
  
  <p>BTW, this is my Python version output:</p>
  
  <pre><code>Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) 
  [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  </code></pre>
  
  <p>Thank you all!</p>