示例#1
0
    def track(self, frame):
        # Resize for efficiency
        frame = cv2.pyrDown(frame)
        frame = cv2.cvtColor(frame, cv.CV_BGR2Lab)
        self.frame = frame

        l,a,b = self.hist
        # Convert to float32 so we can represent probability values
        frame = frame.astype(np.float32)
        lback = cv2.calcBackProject([frame], [0], l, [0,255], 1)
        aback = cv2.calcBackProject([frame], [1], a, [0,255], 1)
        bback = cv2.calcBackProject([frame], [2], b, [0,255], 1)

        # Combine channels and convert to image
        self.back = (aback * bback * lback ) * 255
        self.back = self.back.astype(np.uint8)

        tmp = np.array(self.back)
        loc, contours = util.contour(tmp)

        self.contours = contours

        # Scale loc back up due to pyrDown
        if loc != None:
            loc = [x*2 for x in loc if loc != None]

        return loc
示例#2
0
    def track(self, frame):
        # IDEA: Hugh transform to look for circle shape
        #frame = cv2.pyrDown(frame)
        thresh = cv2.cvtColor(frame, cv.CV_RGB2GRAY)
        self.frame = thresh
        _, thresh = cv2.threshold(thresh, self.threshold, 255, cv.CV_THRESH_BINARY)

        #contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
        #loc = bestcontour(contours, 10)
        loc, contours = util.contour(thresh)

        self.shape = frame.shape
        self.contours = contours

        return loc
示例#3
0
    def track(self, frame):
        # Resize for efficiency
        frame = cv2.pyrDown(frame)
        frame = cv2.cvtColor(frame, cv.CV_BGR2Lab)
        self.frame = frame

        capture = cv2.inRange(frame, self.minbound, self.maxbound)

        #contours, _ = cv2.findContours(capture, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
        # Stupid hack to fix some numpy / opencv bug
        #contours = [c.astype(np.int32) for c in contours]

        loc, contours = util.contour(capture)

        #loc = bestcontour(contours, 10)

        if loc != None:
            loc = [x*2 for x in loc if loc != None]

        self.shape = frame.shape
        self.contours = contours

        return loc