'**SUMMARY**
findLines will find line segments in your image and returns line feature
objects in a FeatureSet. This method uses the Hough (pronounced "HUFF") transform.
See http://en.wikipedia.org/wiki/Hough_transform
**PARAMETERS**
* *threshold* - which determines the minimum "strength" of the line.
* *minlinelength* - how many pixels long the line must be to be returned.
* *maxlinegap* - how much gap is allowed between line segments to consider them the same line .
* *cannyth1* - thresholds used in the edge detection step, refer to :py:meth:`_getEdgeMap` for details.
* *cannyth2* - thresholds used in the edge detection step, refer to :py:meth:`_getEdgeMap` for details.
* *useStandard* - use standard or probabilistic Hough transform.
* *nLines* - maximum number of lines for return.
* *maxpixelgap* - how much distance between pixels is allowed to consider them the same line.
**RETURNS**
Returns a :py:class:`FeatureSet` of :py:class:`Line` objects. If no lines are found the method returns None.
**EXAMPLE**
>>> img = Image("lenna")
>>> lines = img.findLines()
>>> lines.draw()
>>> img.show()
**SEE ALSO**
:py:class:`FeatureSet`
:py:class:`Line`
:py:meth:`edges`'

def findLines(self, threshold=80, minlinelength=30, maxlinegap=10, cannyth1=50, cannyth2=100, useStandard=False, nLines=(-1), maxpixelgap=1):

    em = self._getEdgeMap(cannyth1, cannyth2)
    linesFS = FeatureSet()
    if useStandard:
        lines = cv.HoughLines2(em, cv.CreateMemStorage(), cv.CV_HOUGH_STANDARD, 1.0, (cv.CV_PI / 180.0), threshold, minlinelength, maxlinegap)
        if (nLines == (-1)):
            nLines = len(lines)
        em = Image(em)
        (x, y) = np.where((em.getGrayNumpy() > 128))
        pts = dict(((p, 1) for p in zip(x, y)))
        (w, h) = ((self.width - 1), (self.height - 1))
        for (rho, theta) in lines[:nLines]:
            ep = []
            ls = []
            a = math.cos(theta)
            b = math.sin(theta)
            if (round(b, 4) == 0):
                ep.append((int(round(abs(rho))), 0))
                ep.append((int(round(abs(rho))), h))
            elif (round(a, 4) == 0):
                ep.append((0, int(round(abs(rho)))))
                ep.append((w, int(round(abs(rho)))))
            else:
                x = (rho / float(a))
                if (0 <= x <= w):
                    ep.append((int(round(x)), 0))
                x = ((rho - (h * b)) / float(a))
                if (0 <= x <= w):
                    ep.append((int(round(x)), h))
                y = (rho / float(b))
                if (0 <= y <= h):
                    ep.append((0, int(round(y))))
                y = ((rho - (w * a)) / float(b))
                if (0 <= y <= h):
                    ep.append((w, int(round(y))))
            ep = list(set(ep))
            ep.sort()
            brl = self.bresenham_line(ep[0], ep[1])
            dist = float('inf')
            len_l = float('-inf')
            for p in brl:
                if (p in pts):
                    if (dist > maxpixelgap):
                        if (len_l >= minlinelength):
                            if ls:
                                l = ls[(-1)]
                                gap = round(math.sqrt((((start_p[0] - l[1][0]) ** 2) + ((start_p[1] - l[1][1]) ** 2))))
                                if (gap <= maxlinegap):
                                    ls.pop()
                                    start_p = l[0]
                            ls.append((start_p, last_p))
                        dist = 1
                        len_l = 1
                        start_p = p
                    else:
                        len_l += dist
                        dist = 1
                    last_p = p
                else:
                    dist += 1
            for l in ls:
                linesFS.append(Line(self, l))
        linesFS = linesFS[:nLines]
    else:
        lines = cv.HoughLines2(em, cv.CreateMemStorage(), cv.CV_HOUGH_PROBABILISTIC, 1.0, (cv.CV_PI / 180.0), threshold, minlinelength, maxlinegap)
        if (nLines == (-1)):
            nLines = len(lines)
        for l in lines[:nLines]:
            linesFS.append(Line(self, l))
    return linesFS
