detector.py 文件源码

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

项目:object-detector 作者: penny4860 项目源码 文件源码
def _generate_negative_patches(self, negative_image_files, window_size, step, pyramid_scale, threshold_prob):

        widgets = ["Generating negative samples which represent high probability: ", 
        progressbar.Percentage(), " ", progressbar.Bar(), " ", progressbar.ETA()]
        pbar = progressbar.ProgressBar(maxval=len(negative_image_files), widgets=widgets).start()

        for i, image_file in enumerate(negative_image_files):
            image = cv2.imread(image_file)
            image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

            # detect objects in the image
            (boxes, probs) = self.run(image, 
                                      window_size, step, pyramid_scale, 
                                      threshold_prob, 
                                      do_nms=False, 
                                      show_result=False, 
                                      show_operation=False)

            pbar.update(i)

            for (y1, y2, x1, x2), prob in zip(boxes, probs):
                negative_patch = cv2.resize(image[y1:y2, x1:x2], (window_size[1], window_size[0]), interpolation=cv2.INTER_AREA)
                yield negative_patch, prob

        pbar.finish()

    # todo: code review
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号