Exemplo n.º 1
0
    def houghDetect(img, radiusMin, radiusMax):
        """

        :param img: grayscale image with some circles
        :return:[bounding rectangles]
        """
        circles = cv2.HoughCircles(img,
                                   cv2.HOUGH_GRADIENT,
                                   1,
                                   150,
                                   param1=101,
                                   param2=11,
                                   minRadius=radiusMin,
                                   maxRadius=radiusMax)
        rois = []
        radii = []
        if circles is not None:
            circles = np.uint16(np.around(circles))
            for i in circles[0, :]:
                center = (i[0], i[1])
                cv2.circle(img, center, 1, (0, 100, 100), 3)
                radius = i[2]
                if radiusMin < radius < radiusMax:
                    cv2.circle(img, center, radius, (255, 0, 255), 3)
                    roi = ImgUtils.findBoxAroundCircle(center, radius)
                    rois.append(roi)
                    radii.append(radius)
        return rois, radii
Exemplo n.º 2
0
    def postbake1Debug(self, feed):
        radiusMin = self.dim1Lower
        radiusMax = self.dim1Upper
        img = self.transform(feed)

        circles = cv2.HoughCircles(img,
                                   cv2.HOUGH_GRADIENT,
                                   1,
                                   150,
                                   param1=101,
                                   param2=11,
                                   minRadius=radiusMin,
                                   maxRadius=radiusMax)
        dets = []
        if circles is not None:
            circles = np.uint16(np.around(circles))
            for i in circles[0, :]:
                center = (i[0], i[1])
                cv2.circle(img, center, 1, (0, 100, 100), 3)
                radius = i[2]
                if radiusMin < radius < radiusMax:
                    cv2.circle(img, center, radius, (255, 0, 255), 3)
                    dets.append(ImgUtils.findBoxAroundCircle(center, radius))
        return dets