Пример #1
0
class OpenCloseClassifier():
    DEFECTS_DEPTH_FACTOR = config.DEFECTS_DEPTH_FACTOR
    NUM_DEFECTS = config.NUM_DEFECTS
    OPEN = config.HAND_OPEN
    CLOSE = config.HAND_CLOSE
    NONE = config.HAND_NONE

    def __init__(self):
        self._cvxdefects = ConvexityDefects()

    def run(self, contour):
        (defects, box) = self._cvxdefects.run(contour)

        if not defects:
            return self.NONE

        if defects == None:
            return self.CLOSE

        if self._is_open(defects, box):
            pose = self.OPEN
        else:
            pose = self.CLOSE

        return pose

    def _is_open(self, defects, box):
        asd  = (box[2] * box[3]) / 2.0
        num  = defects.size
        mean = defects[:, :, -1].mean()

        c1 = mean >= (float(asd) / self.DEFECTS_DEPTH_FACTOR)
        c2 = num >= self.NUM_DEFECTS

        return (c1 and c2)
Пример #2
0
class OpenCloseClassifier():
    DEFECTS_DEPTH_FACTOR = config.DEFECTS_DEPTH_FACTOR
    NUM_DEFECTS = config.NUM_DEFECTS
    OPEN = config.HAND_OPEN
    CLOSE = config.HAND_CLOSE
    NONE = config.HAND_NONE

    def __init__(self):
        self._cvxdefects = ConvexityDefects()

    def run(self, contour):
        (defects, box) = self._cvxdefects.run(contour)

        if not defects:
            return self.NONE

        if defects == None:
            return self.CLOSE

        if self._is_open(defects, box):
            pose = self.OPEN
        else:
            pose = self.CLOSE

        return pose

    def _is_open(self, defects, box):
        asd = (box[2] * box[3]) / 2.0
        num = defects.size
        mean = defects[:, :, -1].mean()

        c1 = mean >= (float(asd) / self.DEFECTS_DEPTH_FACTOR)
        c2 = num >= self.NUM_DEFECTS

        return (c1 and c2)
Пример #3
0
 def __init__(self):
     self._cvxdefects = ConvexityDefects()
Пример #4
0
 def __init__(self):
     self._cvxdefects = ConvexityDefects()