find rectangles in image, preferably with skimage
<p>I have an <a href="https://postimg.org/image/tnutzqvml/" rel="nofollow noreferrer">Image</a> obtained from a camera (inner part of my VW T5 Van). I would like to know how accurately I can reproduce the shapes. I corrected for lens distortion using lensfun and gimp. I would like to quantify the remaining distortions by utilizing the rectangular features. I can detect the rectangles using <code>match_template</code> but I do not know how to detect the rectangles.</p>

<p>In the end I would like to label them and measure the width and length. In order to visualize the centers better I tried to locate the centers but this is not as straightforward as I thought because a simple threshold counts the same spots several times. How can I find the centers of all detected rectangles ?</p>

<p>Can this be done with skimage ? Or should I use opencv ? </p>

<pre><code>import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage as ndi
from scipy.ndimage.filters import maximum_filter
from scipy.ndimage import center_of_mass
from skimage.color import rgb2grey
from skimage.feature import match_template
from skimage import feature, io
from skimage import img_as_float
%matplotlib inline

image = io.imread('../lensfun_cut.JPG')
imgray = rgb2grey(image)

    template = imgray[1365:1390,445:470]
    result = match_template(imgray, template)

    # 
    hit = np.where(result&gt;0.90)
    fig, ax = plt.subplots(ncols=1,figsize=(8,8))
    ax.imshow(result,cmap=plt.cm.spectral)

    # loop over the detected regions and draw a circe around them
    for i in range(len(hit[0])):
        rect = plt.Circle((hit[1][i],hit[0][i]), 20,linewidth=1, edgecolor='r', facecolor='none')
        ax.add_patch(rect)
</code></pre>

<p><a href="https://i.stack.imgur.com/ZKmZD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKmZD.png" alt="enter image description here"></a></p>