title: python opencv TypeError: Layout of the output array incompatible with cv::Mat
body: <p>I'm using the selective search here: <a href="http://koen.me/research/selectivesearch/" rel="noreferrer">http://koen.me/research/selectivesearch/</a>
  This gives possible regions of interest where an object might be. I want to do some processing and retain only some of the regions, and then remove duplicate bounding boxes to have a final neat collection of bounding boxes. To discard unwanted/duplicated bounding boxes regions, I'm using the <code>grouprectangles</code> function of opencv for pruning.</p>
  
  <p>Once I get the interesting regions from Matlab from the "selective search algorithm" in the link above, I save the results in a <code>.mat</code> file and then retrieve them in a python program, like this:</p>
  
  <pre><code> import scipy.io as sio
   inboxes = sio.loadmat('C:\\PATH_TO_MATFILE.mat')
   candidates = np.array(inboxes['boxes'])
   # candidates is 4 x N array with each row describing a bounding box like this: 
   # [rowBegin colBegin rowEnd colEnd]
   # Now I will process the candidates and retain only those regions that are interesting
   found = [] # This is the list in which I will retain what's interesting
   for win in candidates: 
       # doing some processing here, and if some condition is met, then retain it:
       found.append(win)
  
  # Now I want to store only the interesting regions, stored in 'found', 
  # and prune unnecessary bounding boxes
  
  boxes = cv2.groupRectangles(found, 1, 2) # But I get an error here
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>    boxes = cv2.groupRectangles(found, 1, 2)
  TypeError: Layout of the output array rectList is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)
  </code></pre>
  
  <p>What's wrong?
  I did something very similar in another piece of code which gave no errors. This was the error-free code:</p>
  
  <pre><code>inboxes = sio.loadmat('C:\\PATH_TO_MY_FILE\\boxes.mat')
  boxes = np.array(inboxes['boxes'])
  pruned_boxes = cv2.groupRectangles(boxes.tolist(), 100, 300)
  </code></pre>
  
  <p>The only difference I can see is that <code>boxes</code> was a numpy array which I then converted to a list. But in my problematic code, <code>found</code> is already a list.</p>