本文整理汇总了Python中scene.Scene.add_landmark方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.add_landmark方法的具体用法?Python Scene.add_landmark怎么用?Python Scene.add_landmark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scene.Scene
的用法示例。
在下文中一共展示了Scene.add_landmark方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_scene
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import add_landmark [as 别名]
def load_scene(file, normalize=False):
jtoclass = {
u'Box': ObjectClass.BOX,
u'Cylinder': ObjectClass.CYLINDER,
u'Sphere': ObjectClass.SPHERE,
}
jtocolor = {
u'yellow': Color.YELLOW,
u'orange': Color.ORANGE,
u'red': Color.RED,
u'green': Color.GREEN,
u'purple': Color.PURPLE,
u'blue': Color.BLUE,
u'pink': Color.PINK,
}
json_data=open(file)
data = json.load(json_data)
json_data.close()
#pprint(data)
scene = Scene(3)
table_spec = data[u'table']
t_min = Vec2(table_spec[u'aabb'][u'min'][2], table_spec[u'aabb'][u'min'][0])
t_max = Vec2(table_spec[u'aabb'][u'max'][2], table_spec[u'aabb'][u'max'][0])
width = t_max.x - t_min.x
height = t_max.y - t_min.y
if normalize: norm_factor = width if width >= height else height
t_min = Vec2(t_min.x / norm_factor, t_min.y / norm_factor)
t_max = Vec2(t_max.x / norm_factor, t_max.y / norm_factor)
table = Landmark('table',
RectangleRepresentation(rect=BoundingBox([t_min, t_max])),
None,
ObjectClass.TABLE)
scene.add_landmark(table)
object_specs = data[u'objects']
print 'there are', len(object_specs), 'objects on the table'
for i,obj_spec in enumerate(object_specs):
o_min = Vec2(obj_spec[u'aabb'][u'min'][2], obj_spec[u'aabb'][u'min'][0])
o_max = Vec2(obj_spec[u'aabb'][u'max'][2], obj_spec[u'aabb'][u'max'][0])
width = o_max.x - o_min.x
height = o_max.y - o_min.y
o_min = Vec2(o_min.x / norm_factor, o_min.y / norm_factor)
o_max = Vec2(o_max.x / norm_factor, o_max.y / norm_factor)
obj = Landmark('object_%s' % obj_spec[u'name'],
RectangleRepresentation(rect=BoundingBox([o_min, o_max]), landmarks_to_get=[]),
None,
jtoclass[obj_spec[u'type']],
jtocolor[obj_spec[u'color-name']])
obj.representation.alt_representations = []
scene.add_landmark(obj)
camera_spec = data[u'cam']
speaker = Speaker(Vec2(camera_spec[u'loc'][2] / norm_factor, camera_spec[u'loc'][0] / norm_factor))
# speaker.visualize(scene, obj, Vec2(0,0), None, None, '')
return scene, speaker
示例2: construct_training_scene
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import add_landmark [as 别名]
def construct_training_scene(random=False):
speaker = Speaker(Vec2(0,0))
scene = Scene(3)
table_ll = (-0.4,0.4)
table_ur = (0.4,1.6)
if random:
x_range = (table_ll[0]+0.035, table_ur[0]-0.035)
y_range = (table_ll[1]+0.045, table_ur[1]-0.045)
centers = []
for _ in range(5):
condition = True
while condition:
new_point = (randrange(*x_range),randrange(*y_range))
condition = (sum( [too_close(new_point,p) for p in centers] ) > 0)
centers.append( new_point )
else:
centers = [(0.05, 0.9), (0.05, 0.7), (0, 0.55), (-0.3,0.7), (0.3,0.7)]
table = Landmark('table',
RectangleRepresentation(rect=BoundingBox([Vec2(*table_ll), Vec2(*table_ur)])),
None,
ObjectClass.TABLE)
obj1 = Landmark('green_cup',
RectangleRepresentation(rect=BoundingBox([Vec2(centers[0][0]-0.035,centers[0][1]-0.035),
Vec2(centers[0][0]+0.035,centers[0][1]+0.035)]), landmarks_to_get=[]),
None,
ObjectClass.CUP,
Color.GREEN)
obj2 = Landmark('blue_cup',
RectangleRepresentation(rect=BoundingBox([Vec2(centers[1][0]-0.035,centers[1][1]-0.035),
Vec2(centers[1][0]+0.035,centers[1][1]+0.035)]), landmarks_to_get=[]),
None,
ObjectClass.CUP,
Color.BLUE)
obj3 = Landmark('pink_cup',
RectangleRepresentation(rect=BoundingBox([Vec2(centers[2][0]-0.035,centers[2][1]-0.035),
Vec2(centers[2][0]+0.035,centers[2][1]+0.035)]), landmarks_to_get=[]),
None,
ObjectClass.CUP,
Color.PINK)
obj4 = Landmark('purple_prism',
RectangleRepresentation(rect=BoundingBox([Vec2(centers[3][0]-0.035,centers[3][1]-0.045),
Vec2(centers[3][0]+0.035,centers[3][1]+0.045)]), landmarks_to_get=[]),
None,
ObjectClass.PRISM,
Color.PURPLE)
obj5 = Landmark('orange_prism',
RectangleRepresentation(rect=BoundingBox([Vec2(centers[4][0]-0.035,centers[4][1]-0.045),
Vec2(centers[4][0]+0.035,centers[4][1]+0.045)]), landmarks_to_get=[]),
None,
ObjectClass.PRISM,
Color.ORANGE)
# t_rep = table.to_dict()
scene.add_landmark(table)
# scene.add_landmark(serialize.landmark_from_dict(t_rep))
for obj in (obj1, obj2, obj3, obj4, obj5):
# o_rep = obj.to_dict()
obj.representation.alt_representations = []
scene.add_landmark(obj)
# scene.add_landmark(serialize.landmark_from_dict(o_rep))
return scene, speaker