def createLabels(X, y, labels, cameraObj=None):
labelIndices = set(y)
objects = []
# Draw labels
for labelIdx in labelIndices:
center = np.sum([x for x, idx in zip(X, y) \
if idx == labelIdx], axis=0)
counts = (y == labelIdx).sum()
center = Vector(center) / counts
label = labels[labelIdx]
fontCurve = bpy.data.curves.new(type="FONT", name=label)
fontCurve.body = label
fontCurve.align_x = 'CENTER'
fontCurve.align_y = 'BOTTOM'
fontCurve.size = 0.6
obj = bpy.data.objects.new("Label {}".format(label), fontCurve)
obj.location = center + Vector((0, 0, 0.8))
obj.rotation_mode = 'AXIS_ANGLE'
obj.rotation_axis_angle = (pi/2, 1, 0, 0)
bpy.context.scene.objects.link(obj)
if cameraObj is not None:
constraint = obj.constraints.new('LOCKED_TRACK')
constraint.target = cameraObj
constraint.track_axis = 'TRACK_Z'
constraint.lock_axis = 'LOCK_Y'
objects.append(obj)
bpy.context.scene.update()
return objects
fisher_iris_visualization.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录