Пример #1
0
    def test_delete_parent(self):
        """ When a parent is deleted, the orphan children should be re-parented to
        the root node.
        """

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child1 = Node()
        child2 = Node()
        childchild1 = Node()

        child1.parent = parent.id
        child2.parent = parent.id
        childchild1.parent = child1.id

        nodes.append([parent, child1, child2, childchild1])

        time.sleep(PROPAGATION_TIME) # wait for propagation
        self.assertEqual(len(nodes), 5) # root node + our 2 nodes

        self.assertEqual(nodes[child1.id].parent, parent.id)
        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[childchild1.id].parent, child1.id)

        nodes.remove(parent)

        time.sleep(PROPAGATION_TIME) # wait for propagation
        self.assertEqual(len(nodes), 4) # root node + child 

        self.assertEqual(nodes[child1.id].parent, world.scene.rootnode.id)
        self.assertEqual(nodes[child2.id].parent, world.scene.rootnode.id)
        self.assertEqual(nodes[childchild1.id].parent, child1.id)
Пример #2
0
    def test_multiple_children(self):

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child1 = Node()
        child2 = Node()
        child3 = Node()

        child1.parent = parent.id
        child2.parent = parent.id
        child3.parent = parent.id

        nodes.append([parent, child1, child2, child3])

        time.sleep(PROPAGATION_TIME) # wait for propagation
        self.assertEqual(len(nodes), 5) # root node + our nodes

        self.assertEqual(nodes[child1.id].parent, parent.id)
        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[child3.id].parent, parent.id)

        nodes.remove(child1)

        time.sleep(PROPAGATION_TIME) # wait for propagation
        self.assertEqual(len(nodes), 4) # root node + our nodes

        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[child3.id].parent, parent.id)
Пример #3
0
    def test_delete_parent(self):
        """ When a parent is deleted, the orphan children should be re-parented to
        the root node.
        """

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child1 = Node()
        child2 = Node()
        childchild1 = Node()

        child1.parent = parent.id
        child2.parent = parent.id
        childchild1.parent = child1.id

        nodes.append([parent, child1, child2, childchild1])

        time.sleep(PROPAGATION_TIME)  # wait for propagation
        self.assertEqual(len(nodes), 5)  # root node + our 2 nodes

        self.assertEqual(nodes[child1.id].parent, parent.id)
        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[childchild1.id].parent, child1.id)

        nodes.remove(parent)

        time.sleep(PROPAGATION_TIME)  # wait for propagation
        self.assertEqual(len(nodes), 4)  # root node + child

        self.assertEqual(nodes[child1.id].parent, world.scene.rootnode.id)
        self.assertEqual(nodes[child2.id].parent, world.scene.rootnode.id)
        self.assertEqual(nodes[childchild1.id].parent, child1.id)
Пример #4
0
    def test_multiple_children(self):

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child1 = Node()
        child2 = Node()
        child3 = Node()

        child1.parent = parent.id
        child2.parent = parent.id
        child3.parent = parent.id

        nodes.append([parent, child1, child2, child3])

        time.sleep(PROPAGATION_TIME)  # wait for propagation
        self.assertEqual(len(nodes), 5)  # root node + our nodes

        self.assertEqual(nodes[child1.id].parent, parent.id)
        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[child3.id].parent, parent.id)

        nodes.remove(child1)

        time.sleep(PROPAGATION_TIME)  # wait for propagation
        self.assertEqual(len(nodes), 4)  # root node + our nodes

        self.assertEqual(nodes[child2.id].parent, parent.id)
        self.assertEqual(nodes[child3.id].parent, parent.id)
Пример #5
0
    def test_base_parent(self):

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child = Node()

        child.parent = parent.id

        nodes.append([parent, child])

        time.sleep(PROPAGATION_TIME) # wait for propagation
        self.assertEqual(len(nodes), 3) # root node + our 2 nodes

        updated_child = nodes[child.id]
        updated_parent = nodes[parent.id]

        self.assertEqual(child.parent, updated_child.parent)
        self.assertEqual(parent.id, updated_parent.id)
        self.assertEqual(updated_child.parent, updated_parent.id)

        self.assertEqual(updated_parent.parent, world.scene.rootnode.id)
Пример #6
0
    def test_base_parent(self):

        world = self.ctx.worlds["base"]
        nodes = world.scene.nodes

        parent = Node()
        child = Node()

        child.parent = parent.id

        nodes.append([parent, child])

        time.sleep(PROPAGATION_TIME)  # wait for propagation
        self.assertEqual(len(nodes), 3)  # root node + our 2 nodes

        updated_child = nodes[child.id]
        updated_parent = nodes[parent.id]

        self.assertEqual(child.parent, updated_child.parent)
        self.assertEqual(parent.id, updated_parent.id)
        self.assertEqual(updated_child.parent, updated_parent.id)

        self.assertEqual(updated_parent.parent, world.scene.rootnode.id)
Пример #7
0
        world = ctx.worlds[args.world]
        nodes = world.scene.nodes

        camera = Node("kinect", ENTITY)

        translation_cam = transformations.translation_matrix((1, 0, 0.5))

        # According to http://www.openni.ru/wp-content/uploads/2013/02/NITE-Algorithms.pdf
        # the sensor is oriented as follow:
        # " +X points to the right of the, +Y points up, and +Z
        # points in the direction of increasing depth."
        rotation_cam = transformations.euler_matrix(math.pi / 2, 0,
                                                    math.pi / 2)

        camera.transformation = numpy.dot(translation_cam, rotation_cam)
        camera.parent = world.scene.rootnode.id
        nodes.append(camera)

        # Load the mannequin mesh into underworlds and get back the list of
        # underworlds nodes
        bodypartslist = ModelLoader(args.world).load(
            "../share/mannequin.blend", ctx=ctx, root=camera)

        human_nodes = {node.name: node for node in bodypartslist}

        try:
            while True:

                frame = userTracker.read_frame()
                #logger.info("%s humans detected" % len(frame.users))
        world = ctx.worlds[args.world]
        nodes = world.scene.nodes

        camera = Node("kinect", ENTITY)

        translation_cam=transformations.translation_matrix((1,0,0.5))

        # According to http://www.openni.ru/wp-content/uploads/2013/02/NITE-Algorithms.pdf
        # the sensor is oriented as follow:
        # " +X points to the right of the, +Y points up, and +Z
        # points in the direction of increasing depth."
        rotation_cam=transformations.euler_matrix(math.pi/2,0,math.pi/2)

        camera.transformation = numpy.dot(translation_cam, rotation_cam)
        camera.parent = world.scene.rootnode.id
        nodes.append(camera)

        # Load the mannequin mesh into underworlds and get back the list of
        # underworlds nodes
        bodypartslist = ModelLoader(args.world).load("../share/mannequin.blend",
                                                     ctx=ctx,
                                                     root=camera)

        human_nodes = {node.name:node for node in bodypartslist}

        try:
            while True:

                frame = userTracker.read_frame()
                #logger.info("%s humans detected" % len(frame.users))