tracking.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:ATLeS 作者: liffiton 项目源码 文件源码
def _do_filter(self, frame):
        ''' Process a single frame. '''
        # blur to reduce noise
        frame = cv2.GaussianBlur(frame, (5, 5), 0, borderType=cv2.BORDER_CONSTANT)

        # threshold to find contiguous regions of "bright" pixels
        # ignore all "dark" (<1/8 max) pixels
        max = numpy.max(frame)
        min = numpy.min(frame)
        # if the frame is completely dark, then just return it
        if max == min:
            return frame
        threshold = min + (max - min) / 8
        _, frame = cv2.threshold(frame, threshold, 255, cv2.THRESH_BINARY)

        # filter out single pixels and other noise
        frame = cv2.erode(frame, self._element_shrink)

        # restore and join nearby regions (in case one fish has a skinny middle...)
        frame = cv2.dilate(frame, self._element_grow)

        return frame
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号