Detector.py 文件源码

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

项目:UAV-ODF 作者: rixmit 项目源码 文件源码
def matchDetectionsOverlap(self, detections, truthDetections, frameSize):
        self.log.info("Calculating overlap for each detection..")

        truthCanvas = np.zeros((frameSize[0], frameSize[1], 1), np.uint8)
        for truthDetection in truthDetections:
            truthCanvas[truthDetection['ymin']:truthDetection['ymax'], truthDetection['xmin']:truthDetection['xmax']] = 255

        overlapRatios = []
        for detection in detections:
            detectionCanvas = np.zeros((frameSize[0], frameSize[1], 1), np.uint8)
            detectionCanvas[detection['ymin']:detection['ymax'], detection['xmin']:detection['xmax']] = 255

            canvas = cv2.bitwise_and(detectionCanvas, truthCanvas)
            detectionCount = np.count_nonzero(detectionCanvas)
            overlapCount = np.count_nonzero(canvas)
            overlap = (overlapCount*1.0)/detectionCount

            overlapRatios.append(overlap)

        return overlapRatios
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号