Пример #1
0
    def apply(self):
        cam = None
        try:
            self.progressBar.setValue(0)
            self.progressBar.show()

            file_path = self.subForm.getFilePath()
            camera_text = self.subForm.getCameraText()
            camera_data = self.subForm.getCameraData()
            width, height = self.subForm.getImageResolution()
            self.progressBar.setValue(20)

            mkr_data_list = mayareadfile.read(file_path,
                                              image_width=width,
                                              image_height=height)
            self.progressBar.setValue(70)

            if camera_text == const.NEW_CAMERA_VALUE:
                cam = lib.create_new_camera()
            else:
                cam = camera_data
            self.progressBar.setValue(90)

            mayareadfile.create_nodes(mkr_data_list, cam=cam)
        finally:
            self.progressBar.setValue(100)
            self.progressBar.hide()
            # Update the camera comboBox with the created camera, or
            # the last used camera.
            selected_cameras = [cam]
            self.subForm.updateCameraList(self.subForm.camera_comboBox,
                                          self.subForm.camera_model,
                                          selected_cameras)
        return
Пример #2
0
def get_file_info(file_path):
    """
    Get the file path information.

    :param file_path: The marker file path to get info for.
    :type file_path: str

    :return Dictionary of various information about the given
            file path.
    :rtype: dict
    """
    info = {
        'num_points': '?',
        'point_names': '?',
        'frame_range': '?-?',
        'start_frame': '?',
        'end_frame': '?',
    }
    mkr_data_list = mayareadfile.read(file_path)
    if isinstance(mkr_data_list, list) is False:
        return info

    fmt = get_file_path_format(file_path)
    info['fmt'] = fmt
    info['fmt_name'] = str(fmt.name)

    info['num_points'] = str(len(mkr_data_list))
    start_frame = int(999999)
    end_frame = int(-999999)
    point_names = []
    for mkr_data in mkr_data_list:
        name = mkr_data.get_name()
        point_names.append(name)

        # Get start / end frame.
        # We assume that there are X and Y keyframes on each frame,
        # therefore we do not test Y.
        x_keys = mkr_data.get_x()
        x_start = x_keys.get_start_frame()
        x_end = x_keys.get_end_frame()
        if x_start < start_frame:
            start_frame = x_start
        if x_end > end_frame:
            end_frame = x_end
    info['point_names'] = pprint.pformat(point_names)
    info['start_frame'] = start_frame
    info['end_frame'] = end_frame
    info['frame_range'] = '{0}-{1}'.format(start_frame, end_frame)
    return info
Пример #3
0
    def test_loadmarker_tdetxt_format(self):
        """
        Test loading markers using the '.uv' format.
        """
        mkr_data_list = []
        paths = [
            (self.get_data_path('3de_v4', 'loadmarker_corners.txt'), (1920.0, 1080.0)),
            # (self.get_data_path('3de_v4', '3de_export_cube.txt'), (1920.0, 1080.0)),
            # (self.get_data_path('3de_v4', 'FB1880_man_v05.txt'), (1920.0, 1080.0)),
        ]
        for path, res in paths:
            print('Reading... %r' % path)
            tmp_list = marker_read.read(
                path,
                image_width=res[0],
                image_height=res[1]
            )
            self.assertNotEqual(tmp_list, None)
            mkr_data_list += tmp_list

        # Create the markers
        num_nodes1 = len(maya.cmds.ls())
        marker_read.create_nodes(mkr_data_list)
        num_nodes2 = len(maya.cmds.ls())
        self.assertGreater(num_nodes2, num_nodes1)

        self.assertTrue(maya.cmds.objExists('TopLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('TopRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('BottomLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateY'), -0.5)

        self.assertTrue(maya.cmds.objExists('BottomRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateY'), -0.5)
Пример #4
0
    def test_loadmarker_uvtrack_format(self):
        """
        Test loading markers using the '.uv' format.
        """
        mkr_data_list = []
        paths = [
            self.get_data_path('uvtrack', 'test_v1.uv'),
            self.get_data_path('uvtrack', 'loadmarker_corners.uv'),
            self.get_data_path('uvtrack', 'cameraTrackRnD.uv'),
            self.get_data_path('uvtrack', 'stA.uv'),
            self.get_data_path('uvtrack', 'stA_with_emptyMarker.uv'),
            self.get_data_path('uvtrack', 'eye_fmt1_v001.uv'),
            self.get_data_path('uvtrack', 'eye_fmt2_v001.uv'),
        ]
        for path in paths:
            print('Reading... %r' % path)
            tmp_list = marker_read.read(path)
            self.assertNotEqual(tmp_list, None)
            mkr_data_list += tmp_list

        # Create the markers
        num_nodes1 = len(maya.cmds.ls())
        marker_read.create_nodes(mkr_data_list)
        num_nodes2 = len(maya.cmds.ls())
        self.assertGreater(num_nodes2, num_nodes1)

        self.assertTrue(maya.cmds.objExists('TopLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('TopRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('BottomLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateY'), -0.5)

        self.assertTrue(maya.cmds.objExists('BottomRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateY'), -0.5)
    def test_loadmarker_rz2_format(self):
        mkr_data_list = []
        paths = [
            self.get_data_path('match_mover', 'loadmarker.rz2'),
            self.get_data_path('match_mover', 'loadmarker_corners.rz2'),
            # self.get_data_path('match_mover', '2dtracks.rz2'),
            # self.get_data_path('match_mover', 'cha_171_1020_atb_v001.rz2'),
            # self.get_data_path('match_mover', 'EP_1000_head_trackers_v002.rz2'),
            # self.get_data_path('match_mover', 'kipPointsMatchmover.rz2'),
            # self.get_data_path('match_mover', 'NonSequentialMatchmoverPoints.rz2'),
        ]
        for path in paths:
            tmp_list = marker_read.read(path)
            mkr_data_list += tmp_list

        # create the markers
        num_nodes1 = len(maya.cmds.ls())
        marker_read.create_nodes(mkr_data_list)
        num_nodes2 = len(maya.cmds.ls())
        self.assertGreater(num_nodes2, num_nodes1)

        self.assertTrue(maya.cmds.objExists('TopLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('TopLeft_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('TopRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('TopRight_MKR.translateY'), 0.5)

        self.assertTrue(maya.cmds.objExists('BottomLeft_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateX'), -0.5)
        self.assertEqual(maya.cmds.getAttr('BottomLeft_MKR.translateY'), -0.5)

        self.assertTrue(maya.cmds.objExists('BottomRight_MKR'))
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateX'), 0.5)
        self.assertEqual(maya.cmds.getAttr('BottomRight_MKR.translateY'), -0.5)