本文整理汇总了Python中Utils.GeomUtils.centroid方法的典型用法代码示例。如果您正苦于以下问题:Python GeomUtils.centroid方法的具体用法?Python GeomUtils.centroid怎么用?Python GeomUtils.centroid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils.GeomUtils
的用法示例。
在下文中一共展示了GeomUtils.centroid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _scoreStroke
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def _scoreStroke(stroke, template, sample_size = None):
if sample_size is None:
sample_size = len(template)
sNorm = GeomUtils.strokeNormalizeSpacing(stroke, len(template))
centr = GeomUtils.centroid(sNorm.Points)
numPoints = len(sNorm.Points)
point_vect = []
templ_vect = []
numPoints = len(template)
if len(template) == len(sNorm.Points):
for idx in range(0, numPoints, numPoints/sample_size ):
templ_vect.append(template[idx].X)
templ_vect.append(template[idx].Y)
p = sNorm.Points[idx]
point_vect.append(p.X - centr.X)
point_vect.append(p.Y - centr.Y)
angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
else:
angularDist = math.pi
return angularDist
示例2: SaveTemplate
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def SaveTemplate(self, numSamples = TEMPLATE_SAMPLE):
if len(self.StrokeList) > 0:
last_stroke = self.StrokeList[-1]
template_name = str(len(self.StrokeList))
sNorm = GeomUtils.strokeNormalizeSpacing(last_stroke, numSamples)
centroid = GeomUtils.centroid(sNorm.Points)
sNorm = sNorm.translate(-1*centroid.X, -1 * centroid.Y)
storeTemplate(sNorm, tag=template_name)
示例3: drawMyself
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def drawMyself( self ):
for a in self.annotation_list:
center = GeomUtils.centroid(a.Strokes[0].Points) #Ugly hack to get the center of the annotation!
templ_stroke = Stroke.Stroke(a.template)
templ_stroke = templ_stroke.translate(center.X, center.Y)
SketchGUI.drawText(center.X, center.Y, InText=a.name)
SketchGUI.drawStroke(templ_stroke, color="#F050F0")
示例4: scoreStroke
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def scoreStroke(stroke, template):
sNorm = GeomUtils.strokeNormalizeSpacing(stroke, TEMPLATE_SAMPLE)
centr = GeomUtils.centroid(sNorm.Points)
point_vect = []
templ_vect = []
for q in template:
templ_vect.append(q.X)
templ_vect.append(q.Y)
for p in sNorm.Points:
point_vect.append(p.X - centr.X)
point_vect.append(p.Y - centr.Y)
angularDist = GeomUtils.vectorDistance(point_vect, templ_vect)
return angularDist
示例5: SaveTemplate
# 需要导入模块: from Utils import GeomUtils [as 别名]
# 或者: from Utils.GeomUtils import centroid [as 别名]
def SaveTemplate(self, sender, e, numSamples = TEMPLATE_SAMPLE):
if len(self.StrokeList) > 0:
#last_stroke = self.StrokeList[-1]
pts = []
for stk in self.StrokeList:
pts.extend(stk.Points)
templ_stroke = Stroke.Stroke(points= pts)
template_name = TEMPLATE_TEXT.Text
if template_name.strip() == '':
template_name = 'Blob'
sNorm = GeomUtils.strokeNormalizeSpacing(templ_stroke, numSamples * len(self.StrokeList))
centroid = GeomUtils.centroid(sNorm.Points)
sNorm = sNorm.translate(-1*centroid.X, -1 * centroid.Y)
storeTemplate(sNorm, len(self.StrokeList), tag=template_name)
self.Clear()