Example #1
0
    def __findColorContours(self, frame):
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

        h_min = self.__settings.colorSettings.grayColorFilter[0]
        h_max = self.__settings.colorSettings.grayColorFilter[1]

        # накладываем фильтр на кадр в модели HSV
        monochromeFrame = cv2.inRange(hsv, h_min, h_max)
        monochromeFrame = self.__invertColors(monochromeFrame)

        if self.__settings.tuneMonochromeColorsView:
            self.__showFrame(monochromeFrame, "monochromeColors")

        cnts = cv2.findContours(monochromeFrame, cv2.RETR_EXTERNAL,
                                cv2.CHAIN_APPROX_SIMPLE)
        contours = imutils.grab_contours(cnts)
        shapeDetector = ShapeDetector()

        contours = list(
            filter(
                lambda item: shapeDetector.isShape(
                    item, self.__settings.minColorShapeHeight, self.__settings.
                    minColorShapeWidth), contours))
        contours.sort(key=lambda item: item[0][0][0])
        return contours
Example #2
0
    def __findContours(self, monochromeFrame):
        cnts = cv2.findContours(monochromeFrame.copy(), cv2.RETR_EXTERNAL,
                                cv2.CHAIN_APPROX_SIMPLE)
        contours = imutils.grab_contours(cnts)
        shapeDetector = ShapeDetector()

        contours = list(
            filter(
                lambda item: shapeDetector.isShape(
                    item, self.__settings.minMeasurementShapeHeight, self.
                    __settings.minMeasurementShapeWidth), contours))
        contours.sort(key=lambda item: item[0][0][0])
        return contours