Пример #1
0
    def test_update_child_attributes(self):
        self.engine.frame()
        self.engine.frame()

        parent = self.scene.objects[0]
        subset = self.scene.objects[0].query(self._gids[0::2])

        color1 = [1, 0, 0, 1]
        color2 = [0, 0, 1, 1]

        parent.attributes.color = color1
        parent.update()
        self.view.snapshot("parent_default.png")

        parent.attributes.color = color2
        subset.attributes.color = color2
        parent.update()
        subset.update()
        assert (parent.attributes.color == color2)
        assert (subset.attributes.color == color2)

        parent.attributes.color = color1
        parent.update()
        self.view.snapshot("parent_reset.png")
        assert (parent.attributes.color == color1)
        assert (subset.attributes.color == color1)

        try:
            image_compare.compare("parent_default.png", "parent_reset.png")
        finally:
            import os
            if 'KEEP_IMAGES' not in os.environ:
                os.remove('parent_default.png')
                os.remove('parent_reset.png')
Пример #2
0
    def test_remove_synapses(self):
        view = self._view
        engine = self._engine
        blank = image_compare._get_tmp_file_name()
        self._tmp_files.append(blank)
        view.snapshot(blank)

        display_synapses(self._gids)
        # To make sure the scene is created and synapses are displayed
        engine.frame()
        engine.waitFrame()
        synapses = image_compare._get_tmp_file_name()
        self._tmp_files.append(synapses)
        view.snapshot(synapses)

        self.assertRaises(AssertionError,
                          lambda: list(image_compare.compare(blank, synapses)))

        view.scene.remove(view.scene.objects[0])
        view.scene.update()
        engine.frame()
        engine.waitFrame()
        blank2 = image_compare._get_tmp_file_name()
        self._tmp_files.append(blank2)
        view.snapshot(blank2)

        image_compare.compare(blank, blank2)
Пример #3
0
def compare_with_original(view, name, arg = 1):
    ''' Takes a screenshot with the original snapshot
    function and compares the result to the image generated
    with the new function '''

    original = "original_" + name
    view.snapshot(original)
    view.snapshot(name, arg)
    try:
        image_compare.compare(original, name)
    finally:
        if 'KEEP_IMAGES' not in os.environ:
            os.remove(name)
            os.remove(original)
Пример #4
0
        def test_delta(delta, extra_key_frame = True) :
            keyframes = [
                (0, self.initial_position[0], self.initial_position[1]),
                (1, self.final_position[0], self.final_position[1])]
            if extra_key_frame :
                # Since the camera path interval is open on the right, an extra
                # key frame is added to make sure that the recording stops at
                # the camera position given in the previous key frame
                keyframes.append(
                    (1 + delta, self.final_position[0], self.final_position[1]))

            path = create_camera_path(keyframes)

            frames = record_and_check_frames(camera_path = path,
                                             path_delta_secs = delta)

            image_compare.compare('record_test_000000.png',
                                  'record_test_first.png')
            if extra_key_frame :
                image_compare.compare('record_test_0000%.2d.png' % (frames - 1),
                                      'record_test_last.png')

            delete_files(test_file_pattern)
Пример #5
0
    def analyze_img(self, video, compid, chid):

        #从数据库中取本频道的设定转场关键帧数据
        result = self.load_keyframe_info(compid, chid)
        if not result:
            return

        #在此处引导视频目录中的所有关键帧数据到字典中
        self.load_video_key(video)

        icomp = image_compare.compare()
        rdict = icomp.compORB(self.datapath + "/" + str(chid), self.videokey,
                              result, float(self.drate))
        self.regKeyPoint(rdict)
        #建立头像比较类
        dface = face_recognize.face_recognize()
        dface.loadKnowFaces(compid, chid)
        for key, val in self.videokey.items():
            ret = dface.recognize(val)
            if ret:
                self.regFacePoint(key)

        return self.prghead, self.prgend, self.seghead, self.segend, self.facekey, self.videokey
Пример #6
0
 def compare_with(self, index):
     try:
         tmp = image_compare.capture_temporary(self.view)
         image_compare.compare(tmp, self.tmp_images[index])
     finally:
         os.remove(tmp)