本文整理汇总了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))