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


Python GeomUtils.pointInBox方法代码示例

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


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

示例1: onStrokeAdded

# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import pointInBox [as 别名]
    def onStrokeAdded(self, stroke):
        """ Attempts to classify a stroke using the given training data """
        bbox1 = (stroke.BoundTopLeft, stroke.BoundBottomRight)
        s1_eps = (stroke.Points[0], stroke.Points[-1]) #Stroke 1 endpoints
        matchStks = set()
        for stk2, connectStrokes in self.allStrokes.items():
            bbox2 = (stroke.BoundTopLeft, stroke.BoundBottomRight)
            s2_eps = (stk2.Points[0], stk2.Points[-1]) #Stroke 2 endpoints

            for ep in s1_eps: #Do any of the stroke's endpoints overlap stroke2?
                if GeomUtils.pointInBox(ep, bbox2[0], bbox2[1]):
                    if ep in stk2.Points:
                        matchStks.update(connectStrokes)
                        break
            if len(connectStrokes) > 0:
                break

            for ep in s2_eps: #Do any of stroke2's endpoints overlap stroke?
                if GeomUtils.pointInBox(ep, bbox1[0], bbox1[1]):
                    if ep in stroke.Points:
                        matchStks.update(connectStrokes)
                        break
            if len(connectStrokes) > 0:
                break

        matchStks.add(stroke) #Update the connected strokes list
        for stk in matchStks:
            self.allStrokes[stk] = matchStks

        strokeList = list(matchStks)
        scores = self.classifier.classifyStrokeList(strokeList)
        #Remove the previous annotations
        for stk in strokeList:
            annotations = stk.findAnnotations(annoType = RubineAnnotation)
            for anno in annotations:
                self.getBoard().RemoveAnnotation(anno)
        if len(scores) > 0:
            height = stroke.BoundTopLeft.Y - stroke.BoundBottomRight.Y        
            best = scores[0]['symbol']
            self.getBoard().AnnotateStrokes( strokeList,  RubineAnnotation(scores))
开发者ID:jbrowne,项目名称:UCSBsketch,代码行数:42,代码来源:RubineObserver.py


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