当前位置: 首页>>代码示例>>Python>>正文


Python GeomUtils.boundingboxOverlap方法代码示例

本文整理汇总了Python中Utils.GeomUtils.boundingboxOverlap方法的典型用法代码示例。如果您正苦于以下问题:Python GeomUtils.boundingboxOverlap方法的具体用法?Python GeomUtils.boundingboxOverlap怎么用?Python GeomUtils.boundingboxOverlap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Utils.GeomUtils的用法示例。


在下文中一共展示了GeomUtils.boundingboxOverlap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mergeCollections

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import boundingboxOverlap [as 别名]
    def mergeCollections( self, from_anno, to_anno ):
        "merge from_anno into to_anno if possible"
        # check that they have compatable scales
        scale_diff = to_anno.scale / from_anno.scale
        if scale_diff>2.5 or scale_diff<0.4:
            return False
        # check that they are not overlapping
        bb_from = GeomUtils.strokelistBoundingBox( from_anno.Strokes )
        bb_to = GeomUtils.strokelistBoundingBox( to_anno.Strokes )
        if GeomUtils.boundingboxOverlap( bb_from, bb_to ):
            return False

        #  bb[0]-------+
        #   |          |
        #   |          |
        #   | (0,0)    |
        #   +--------bb[1]

        # check that they are next to each other
        if    abs( bb_from[1].X - bb_to[0].X ) > to_anno.scale * 0.75 \
          and abs( bb_from[0].X - bb_to[1].X ) > to_anno.scale * 0.75 :
            return False
        # check y's overlap
        if   bb_from[0].Y - bb_to[1].Y < 0 \
          or bb_to[0].Y - bb_from[1].Y < 0 :
            return False

        # now we know that we want to merge these text annotations
        if bb_from[0].X - bb_to[0].X > 0 :
            to_anno.text = to_anno.text + from_anno.text 
        else :
            to_anno.text = from_anno.text + to_anno.text 
        to_anno.scale = max( to_anno.scale, from_anno.scale )
        return True
开发者ID:ASayre,项目名称:UCSBsketch,代码行数:36,代码来源:TextObserver.py

示例2: onStrokeAdded

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import boundingboxOverlap [as 别名]
    def onStrokeAdded( self, stroke ):
        "Compare this stroke to all templates, and annotate those matching within some threshold."
        logger.debug("Scoring stroke")
        #strokeVector = ( len(stroke.Points), GeomUtils.pointListOrientationHistogram(GeomUtils.strokeNormalizeSpacing(stroke, numpoints = len(stroke.Points) / 3.0).Points) )
        strokeVector = generateFeatureVector(stroke)
        logger.debug("Stroke Vector: %s" % (str(strokeVector)))
        if self._matchVector == None:
            self._matchVector = strokeVector
        else:
            bb1 = GeomUtils.strokelistBoundingBox([stroke])
            for prevStk in self._features.keys():
                bb2 = GeomUtils.strokelistBoundingBox([prevStk])
                if GeomUtils.boundingboxOverlap(bb1, bb2):
                    self.overlaps.setdefault(stroke, set()).add(prevStk)
                    self.overlaps.setdefault(prevStk, set()).add(stroke)
            self._features[stroke] = strokeVector
            score = scoreVector(self._matchVector, strokeVector)
            logger.debug("  Distance %s from baseline" % (score) )
            if score < 0.02:
                self.getBoard().AnnotateStrokes([stroke], MultiStrokeAnnotation("Match"))

            for stk in self.overlaps.get(stroke, []):
                multiVect = addVectors( [self._features[stroke], self._features[stk] ] )
                logger.debug("Multiple vector: %s" % (str(multiVect)))
                score = scoreVector(self._matchVector, multiVect)
                logger.debug("  Distance %s from baseline" % (score) )
                if score < 0.02:
                    self.getBoard().AnnotateStrokes([stroke, stk], MultiStrokeAnnotation("Match"))
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:30,代码来源:MultiStrokeFeatureObserver.py


注:本文中的Utils.GeomUtils.boundingboxOverlap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。