예제 #1
0
 def _draw_version(self, layout):
     arr = [
         "Version {}, built {}".format(pkt.module().__version__,
                                       pkt.module().build_time),
         'The core library has been installed successfully'
     ]
     draw_warning_labels(layout, arr, alert=False, icon='INFO')
예제 #2
0
 def init_facebuilder(self, ver=Config.unknown_mod_ver):
     latest_version = pkt.module().FaceBuilder.latest_face_version()
     if ver == Config.unknown_mod_ver or ver > latest_version:
         self.builder = pkt.module().FaceBuilder(latest_version)
         self.version = latest_version
     else:
         self.builder = pkt.module().FaceBuilder(ver)
         self.version = ver
     self.builder_type = BuilderType.FaceBuilder
예제 #3
0
def mesh_update_accepted(headnum):
    logger = logging.getLogger(__name__)
    logger.debug('callbacks.update_mesh_geometry')

    settings = get_main_settings()
    head = settings.get_head(headnum)

    if not head or not head.model_changed():
        logger.debug('WRONG_HEAD OR MODEL NOT CHANGED')
        return

    head.apply_model_changes()

    if not head.has_no_blendshapes():
        names = [kb.name for kb in head.headobj.data.shape_keys.key_blocks[1:]]
        action = disconnect_blendshapes_action(head.headobj)
        logger.debug('blendshapes: {}'.format(names))
        _update_mesh_now(headnum)

        try:
            counter = restore_facs_blendshapes(head.headobj,
                                               head.model_scale, names)
            logger.debug('blendshapes_restored: {}'.format(counter))
        except pkt.module().UnlicensedException:
            logger.error('UnlicensedException restore_facs_blendshapes')
            warn = get_operator(Config.fb_warning_idname)
            warn('INVOKE_DEFAULT', msg=ErrorType.NoLicense)
        except Exception:
            logger.error('UNKNOWN EXCEPTION restore_facs_blendshapes')

        if action:
            head.headobj.data.shape_keys.animation_data_create()
            head.headobj.data.shape_keys.animation_data.action = action
    else:
        _update_mesh_now(headnum)
def test_download_latest_nightly(use_progress_callback):
    try:
        if use_progress_callback:

            def testing_progress_callback(progress):
                assert (testing_progress_callback.last_progress <= progress <=
                        1)
                testing_progress_callback.last_progress = progress

            testing_progress_callback.last_progress = 0
        else:
            testing_progress_callback = None

        pkt.install_from_download(nightly=True,
                                  progress_callback=testing_progress_callback)

        if use_progress_callback:
            assert (testing_progress_callback.last_progress == 1.0)
    except Exception:
        # can fail with no network
        return
    assert (pkt.is_installed())
    pykeentools = pkt.module()
    assert (isinstance(pykeentools.__version__, str))
    pkt.uninstall()
예제 #5
0
def _get_facs_executor(obj, scale):
    logger = logging.getLogger(__name__)
    verts = _get_obj_verts(obj)

    try:
        fe = pkt.module().FacsExecutor(verts, scale)
    except pkt.module().FacsLoadingException:
        logger.error('CANNOT_LOAD_FACS: FacsLoadingException')
        return None
    except Exception as error:
        logger.error('CANNOT_LOAD_FACS: Unknown Exception')
        logger.error('info: {} -- {}'.format(type(error), error))
        return None
    if not fe.facs_enabled():
        logger.error('CANNOT_LOAD_FACS: FACS are not enabled')
        return None
    return fe
예제 #6
0
    def execute(self, context):
        lm = pkt.module().FaceBuilder.license_manager()
        res = lm.install_license_offline(self.lic_path)

        if res is not None:
            self.report({'ERROR'}, replace_newlines_with_spaces(res))
        else:
            self.report({'INFO'}, 'License installed')
        return {'FINISHED'}
예제 #7
0
 def execute(self, context):
     lm = pkt.module().FaceBuilder.license_manager()
     res = lm.install_floating_license(self.license_server,
                                       self.license_server_port)
     if res is not None:
         self.report({'ERROR'}, replace_newlines_with_spaces(res))
     else:
         self.report({'INFO'}, 'Floating server settings saved')
     return {'FINISHED'}
예제 #8
0
def _create_texture_builder_from_settings(settings):
    tb = pkt.module().TextureBuilder()
    tb.set_output_texture_size((settings.tex_width, settings.tex_height))
    tb.set_face_angles_affection(settings.tex_face_angles_affection)
    tb.set_uv_expand_percents(settings.tex_uv_expand_percents)
    tb.set_back_face_culling(settings.tex_back_face_culling)
    tb.set_equalize_brightness(settings.tex_equalize_brightness)
    tb.set_equalize_colour(settings.tex_equalize_colour)
    return tb
예제 #9
0
    def on_mouse_move(self, context, mouse_x, mouse_y):
        logger = logging.getLogger(__name__)
        settings = get_main_settings()
        headnum = self.get_headnum()
        camnum = self.get_camnum()
        head = settings.get_head(headnum)
        headobj = head.headobj
        cam = head.get_camera(camnum)
        camobj = cam.camobj
        kid = settings.get_keyframe(headnum, camnum)

        self._pin_drag(kid, context, mouse_x, mouse_y)

        fb = FBLoader.get_builder()
        FBLoader.rigidity_setup()
        fb.set_focal_length_estimation(head.auto_focal_estimation)

        try:
            fb.solve_for_current_pins(kid)
        except pkt.module().UnlicensedException:
            logger.error("MOVE PIN LICENSE EXCEPTION")
            settings.force_out_pinmode = True
            settings.license_error = True
            FBLoader.out_pinmode(headnum, camnum)
            return {'FINISHED'}

        FBLoader.auto_focal_estimation_post(head, camobj)

        # --------------
        # Pin lag solve
        # --------------
        head = settings.get_head(headnum)
        # Store in tmp previous state
        head.tmp_serial_str = head.serial_str
        cam.tmp_model_mat = cam.model_mat
        # Save current state
        head.set_serial_str(fb.serialize())
        cam.set_model_mat(fb.model_mat(kid))
        # --------------

        FBLoader.rigidity_post()
        FBLoader.place_cameraobj(kid, camobj, headobj)
        coords.update_head_mesh(fb, headobj)
        FBLoader.viewport().wireframer().init_geom_data(headobj)
        FBLoader.viewport().wireframer().create_batches()
        FBLoader.viewport().create_batch_2d(context)
        # Try to redraw
        if not bpy.app.background:
            context.area.tag_redraw()

        # Load 3D pins
        FBLoader.viewport().update_surface_points(fb, headobj, kid)

        return self.on_default_modal()
예제 #10
0
    def execute(self, context):
        logger = logging.getLogger(__name__)
        settings = get_main_settings()
        heads_deleted, cams_deleted = settings.fix_heads()
        try:
            obj = self.new_head()
        except ModuleNotFoundError:
            logger.error('ADD_HEAD_ERROR: ModuleNotFoundError')
            warn = get_operator(Config.fb_warning_idname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktProblem)
            return {'CANCELLED'}
        except pkt.module().ModelLoadingException:
            logger.error('ADD_HEAD_ERROR: ModelLoadingException')
            warn = get_operator(Config.fb_warning_idname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktModelProblem)
            return {'CANCELLED'}
        except TypeError:
            logger.error('ADD_HEAD_ERROR: TypeError')
            warn = get_operator(Config.fb_warning_idname)
            warn('INVOKE_DEFAULT', msg=ErrorType.CannotCreateObject)
            return {'CANCELLED'}
        except Exception:
            logger.error('ADD_HEAD_ERROR: Exception')
            warn = get_operator(Config.fb_warning_idname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktProblem)
            return {'CANCELLED'}

        attrs.add_to_fb_collection(obj)  # link to FB objects collection
        FBLoader.set_keentools_attributes(obj)

        bpy.ops.object.select_all(action='DESELECT')
        obj.select_set(state=True)
        bpy.context.view_layer.objects.active = obj

        # bpy.ops.object.shade_smooth()
        h = get_main_settings().heads.add()
        h.headobj = obj
        h.reset_sensor_size()

        settings.current_headnum = settings.get_last_headnum()
        FBLoader.save_fb_on_headobj(settings.current_headnum)

        try:
            a = context.area
            # Try to show UI Panel
            a.spaces[0].show_region_ui = True
        except Exception:
            pass

        logger.debug('HEAD HAS BEEN SUCCESSFULLY CREATED')
        return {'FINISHED'}
예제 #11
0
def mock_response():
    response = lambda: None
    response.description_url = 'https://keentools.io/downloads'
    response.download_url = 'https://keentools.io/downloads'
    response.message = "<h3>What's New in KeenTools 1.5.7</h3>\n" \
                       "<ul>\n  " \
                       "<li>fixed performance issues in Nuke 12;</li>\n  " \
                       "<li>pintooling performance improvements;</li>\n  " \
                       "<li>fixed large frame numbers bug;</li>\n  " \
                       "<li>fixed invisible model in macOS Catalina;</li>\n " \
                       "<li>minor fixes and improvements</li>\n" \
                       "</ul>\n<br />\n"
    response.plugin_name = 'FaceBuilder'
    response.version = pkt.module().Version(1, 5, 6)
    return response
예제 #12
0
    def frame_data_loader(kf_idx):
        cam = head.cameras[camnums[kf_idx]]

        w, h = cam.cam_image.size[:2]
        img = np.rot90(
            np.asarray(cam.cam_image.pixels[:]).reshape((h, w, 4)),
            cam.orientation)

        frame_data = pkt.module().texture_builder.FrameData()
        frame_data.geo = fb.applied_args_model_at(cam.get_keyframe())
        frame_data.image = img
        frame_data.model = cam.get_model_mat()
        frame_data.view = np.eye(4)
        frame_data.projection = cam.get_projection_matrix()

        return frame_data
예제 #13
0
    def execute(self, context):
        logger = logging.getLogger(__name__)
        settings = get_main_settings()
        heads_deleted, cams_deleted = settings.fix_heads()
        try:
            obj = self.new_head()
        except ModuleNotFoundError:
            warn = getattr(get_operators(), Config.fb_warning_callname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktProblem)
            return {'CANCELLED'}
        except pkt.module().ModelLoadingException:
            warn = getattr(get_operators(), Config.fb_warning_callname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktModelProblem)
            return {'CANCELLED'}
        except Exception:
            warn = getattr(get_operators(), Config.fb_warning_callname)
            warn('INVOKE_DEFAULT', msg=ErrorType.PktProblem)
            return {'CANCELLED'}

        attrs.add_to_fb_collection(obj)  # link to FB objects collection
        FBLoader.set_keentools_version(obj)  # Mark Keentools attribute

        bpy.ops.object.select_all(action='DESELECT')
        obj.select_set(state=True)
        bpy.context.view_layer.objects.active = obj

        # bpy.ops.object.shade_smooth()
        h = get_main_settings().heads.add()
        h.headobj = obj
        h.mod_ver = FBLoader.get_builder_version()
        h.reset_sensor_size()
        h.save_cam_settings()

        settings.current_headnum = settings.get_last_headnum()

        try:
            a = context.area
            # Try to show UI Panel
            a.spaces[0].show_region_ui = True
        except Exception:
            pass

        pkt.reset_cached_is_installed()
        logger.debug('HEAD HAS BEEN SUCCESSFULLY CREATED')
        return {'FINISHED'}
예제 #14
0
class FaceBuilderCameraInput(pkt.module().FaceBuilderCameraInputI):
    @classmethod
    def _camera_at(cls, keyframe):
        settings = get_main_settings()
        head = settings.get_current_head()
        assert head is not None
        return head.get_camera_by_keyframe(keyframe)

    def projection(self, keyframe):
        camera = self._camera_at(keyframe)
        assert camera is not None
        return camera.get_projection_matrix()

    def view(self, keyframe):
        return np.eye(4)

    def image_size(self, keyframe):
        camera = self._camera_at(keyframe)
        assert camera is not None
        return camera.get_oriented_image_size()
예제 #15
0
def bake_tex(headnum, tex_name):
    logger = logging.getLogger(__name__)
    settings = get_main_settings()
    head = settings.get_head(headnum)

    if not head.has_cameras():
        logger.debug("NO CAMERAS ON HEAD")
        return False

    camnums = [cam_idx for cam_idx, cam in enumerate(head.cameras)
               if cam.use_in_tex_baking and \
                  _cam_image_data_exists(cam) and \
                  cam.has_pins()]

    frames_count = len(camnums)
    if frames_count == 0:
        logger.debug("NO FRAMES FOR TEXTURE BUILDING")
        return False

    fb = _get_fb_for_bake_tex(headnum, head)
    frame_data_loader = _create_frame_data_loader(settings, head, camnums, fb)

    bpy.context.window_manager.progress_begin(0, 1)

    class ProgressCallBack(pkt.module().ProgressCallback):
        def set_progress_and_check_abort(self, progress):
            bpy.context.window_manager.progress_update(progress)
            return False

    progress_callBack = ProgressCallBack()
    built_texture = pkt.module().texture_builder.build_texture(
        frames_count, frame_data_loader, progress_callBack,
        settings.tex_height, settings.tex_width,
        settings.tex_face_angles_affection, settings.tex_uv_expand_percents,
        settings.tex_back_face_culling, settings.tex_equalize_brightness,
        settings.tex_equalize_colour, settings.tex_fill_gaps)
    bpy.context.window_manager.progress_end()

    _create_bpy_texture_from_img(built_texture, tex_name)
    return True
예제 #16
0
    def _delete_found_pin(self, nearest, context):
        logger = logging.getLogger(__name__)
        settings = get_main_settings()
        headnum = settings.current_headnum
        camnum = settings.current_camnum
        head = settings.get_head(headnum)
        kid = settings.get_keyframe(headnum, camnum)
        cam = head.get_camera(camnum)
        camobj = cam.camobj

        fb = FBLoader.get_builder()
        fb.remove_pin(kid, nearest)
        del FBLoader.viewport().spins[nearest]
        logging.debug("PIN REMOVED {}".format(nearest))

        FBLoader.rigidity_setup()
        fb.set_focal_length_estimation(head.auto_focal_estimation)

        try:
            fb.solve_for_current_pins(kid)
        except pkt.module().UnlicensedException:
            settings.force_out_pinmode = True
            settings.license_error = True
            FBLoader.out_pinmode(headnum, camnum)
            logger.error("PINMODE LICENSE EXCEPTION")
            return {'FINISHED'}

        FBLoader.auto_focal_estimation_post(head, camobj)

        FBLoader.update_pins_count(headnum, camnum)
        coords.update_head_mesh(fb, head.headobj)
        FBLoader.update_all_camera_positions(headnum)
        FBLoader.viewport().update_surface_points(fb, head.headobj, kid)
        FBLoader.shader_update(head.headobj)
        # Save result
        FBLoader.fb_save(headnum, camnum)
        manipulate.push_head_state_in_undo_history(head, 'Pin remove')

        FBLoader.viewport().create_batch_2d(context)
        return {"RUNNING_MODAL"}
예제 #17
0
 def _draw_version(self, layout):
     box = layout.box()
     box.label(text="Version {}, built {}".format(
         pkt.module().__version__,
         pkt.module().build_time))
예제 #18
0
    def _draw_license_info(self, layout):
        layout.label(text='License info:')
        box = layout.box()

        lm = pkt.module().FaceBuilder.license_manager()

        _multi_line_text_to_output_labels(box, lm.license_status_text(force_check=False))

        box.row().prop(self, "lic_type", expand=True)

        if self.lic_type == 'ONLINE':
            box = layout.box()
            row = box.split(factor=0.85)
            row.prop(self, "license_id")
            install_online_op = row.operator(preferences_operators.PREF_OT_InstallLicenseOnline.bl_idname)
            install_online_op.license_id = self.license_id

        elif self.lic_type == 'OFFLINE':
            self.hardware_id = lm.hardware_id()

            row = layout.split(factor=0.65)
            row.label(text="Get an activated license file at our site:")
            row.operator(
                preferences_operators.PREF_OT_OpenManualInstallPage.bl_idname,
                icon='URL')

            box = layout.box()
            row = box.split(factor=0.85)
            row.prop(self, "hardware_id")
            row.operator(preferences_operators.PREF_OT_CopyHardwareId.bl_idname)

            row = box.split(factor=0.85)
            row.prop(self, "lic_path")
            install_offline_op = row.operator(preferences_operators.PREF_OT_InstallLicenseOffline.bl_idname)
            install_offline_op.lic_path = self.lic_path

        elif self.lic_type == 'FLOATING':
            env = pkt.module().LicenseManager.env_server_info()
            if env is not None:
                self.license_server = env[0]
                self.license_server_port = env[1]
                self.license_server_lock = True
            else:
                self.license_server_lock = False

            box = layout.box()
            row = box.split(factor=0.35)
            row.label(text="License Server host/IP")
            if self.license_server_lock and self.license_server_auto:
                row.label(text=self.license_server)
            else:
                row.prop(self, "license_server", text="")

            row = box.split(factor=0.35)
            row.label(text="License Server port")
            if self.license_server_lock and self.license_server_auto:
                row.label(text=str(self.license_server_port))
            else:
                row.prop(self, "license_server_port", text="")

            if self.license_server_lock:
                box.prop(self, "license_server_auto",
                         text="Auto server/port settings")

            floating_install_op = row.operator(preferences_operators.PREF_OT_FloatingConnect.bl_idname)
            floating_install_op.license_server = self.license_server
            floating_install_op.license_server_port = self.license_server_port
예제 #19
0
 def execute(self, context):
     hardware_id = pkt.module().FaceBuilder.license_manager().hardware_id()
     context.window_manager.clipboard = hardware_id
     self.report({'INFO'}, 'Hardware ID is in clipboard!')
     return {'FINISHED'}
예제 #20
0
    def solve(cls, headnum, camnum):
        def _exception_handling(headnum, msg, license_err=True):
            logger = logging.getLogger(__name__)
            logger.error(msg)
            if settings.pinmode:
                settings.force_out_pinmode = True
                settings.license_error = license_err
                cls.out_pinmode(headnum)

        def _unfix_all(fb, head):
            for cam in head.cameras:
                fb.set_focal_length_fixed_at(cam.get_keyframe(), False)

        def _fix_all_except_this(fb, head, exclude_kid):
            for cam in head.cameras:
                fb.set_focal_length_fixed_at(cam.get_keyframe(),
                                             cam.get_keyframe() != exclude_kid)

        def _unfix_not_in_groups(fb, head):
            for cam in head.cameras:
                fb.set_focal_length_fixed_at(
                    cam.get_keyframe(),
                    cam.is_in_group()
                    or not cam.auto_focal_estimation)

        def _auto_focal_estimation_mode_and_fixes():
            mode = 'FB_ESTIMATE_VARYING_FOCAL_LENGTH'
            if head.smart_mode():
                if camera.auto_focal_estimation:
                    if camera.is_in_group():
                        for cam in head.cameras:
                            fb.set_focal_length_fixed_at(
                                cam.get_keyframe(),
                                cam.image_group != camera.image_group
                                or not cam.auto_focal_estimation)
                        mode = 'FB_ESTIMATE_STATIC_FOCAL_LENGTH'
                    else:  # image_group in (-1, 0)
                        for cam in head.cameras:
                            fb.set_focal_length_fixed_at(
                                cam.get_keyframe(),
                                cam.image_group > 0
                                or not cam.auto_focal_estimation)
                        mode = 'FB_ESTIMATE_VARYING_FOCAL_LENGTH'
                else:
                    _unfix_not_in_groups(fb, head)
                    mode = 'FB_ESTIMATE_VARYING_FOCAL_LENGTH'
            else:  # Override all
                if head.manual_estimation_mode == 'all_different':
                    _unfix_all(fb, head)
                    mode = 'FB_ESTIMATE_VARYING_FOCAL_LENGTH'
                elif head.manual_estimation_mode == 'current_estimation':
                    _fix_all_except_this(fb, head, kid)
                    mode = 'FB_ESTIMATE_VARYING_FOCAL_LENGTH'
                elif head.manual_estimation_mode == 'same_focus':
                    _unfix_all(fb, head)
                    mode = 'FB_ESTIMATE_STATIC_FOCAL_LENGTH'
                elif head.manual_estimation_mode == 'force_focal':
                    for cam in head.cameras:
                        fb.update_projection_mat(cam.get_keyframe(),
                            cam.get_custom_projection_matrix(head.focal))
                        fb.update_image_size(cam.get_keyframe(),
                                             cam.get_oriented_image_size())
                    mode = 'FB_FIXED_FOCAL_LENGTH_ALL_FRAMES'
                else:
                    assert(False), 'Unknown mode: {}'.format(
                        head.manual_estimation_mode)
            return mode

        def _update_camera_focal_post():
            focal = cls.get_keyframe_focal(kid)
            camera.camobj.data.lens = focal
            camera.focal = focal

        settings = get_main_settings()
        head = settings.get_head(headnum)
        camera = head.get_camera(camnum)
        kid = camera.get_keyframe()
        fb = cls.get_builder()

        cls.rigidity_setup()
        fb.set_use_emotions(head.should_use_emotions())

        mode = _auto_focal_estimation_mode_and_fixes()
        fb.set_focal_length_estimation_mode(mode)

        try:
            fb.solve_for_current_pins(kid)
        except pkt.module().UnlicensedException:
            _exception_handling(headnum, 'SOLVE LICENSE EXCEPTION')
            return False
        except pkt.module().InvalidArgumentException:
            _exception_handling(headnum, 'SOLVE NO KEYFRAME EXCEPTION',
                                license_err=False)
            return False
        except Exception as err:
            _exception_handling(headnum,
                                'SOLVE UNKNOWN EXCEPTION: {}'.format(str(err)),
                                license_err=False)
            return False

        _update_camera_focal_post()
        return True
예제 #21
0
def load_csv_animation_to_blendshapes(obj, filepath):
    logger = logging.getLogger(__name__)
    try:
        fan = pkt.module().FacsAnimation()
        read_facs, ignored_columns = fan.load_from_csv_file(filepath)
        facs_names = pkt.module().FacsExecutor.facs_names
    except pkt.module().FacsLoadingException as err:
        logger.error('CANNOT_LOAD_CSV_ANIMATION: {}'.format(err))
        return {
            'status': False,
            'message': str(err),
            'ignored': [],
            'read_facs': []
        }
    except Exception as err:
        logger.error('CANNOT_LOAD_CSV_ANIMATION!: {} {}'.format(
            type(err), err))
        return {
            'status': False,
            'message': str(err),
            'ignored': [],
            'read_facs': []
        }

    action_name = os.path.splitext(os.path.basename(filepath))[0]
    blendshapes_action = _get_safe_blendshapes_action(obj, action_name)

    scene = bpy.context.scene
    fps = scene.render.fps
    start = scene.frame_current
    if not fan.timecodes_enabled():
        fps = 1
    keyframes = [start + x * fps for x in fan.keyframes()]
    if len(keyframes) > 0:
        start_keyframe = keyframes[0]
        end_keyframe = keyframes[-1]
    else:
        start_keyframe = 0
        end_keyframe = -1

    for name in facs_names:
        blendshape_fcurve = _get_safe_action_fcurve(
            blendshapes_action, 'key_blocks["{}"].value'.format(name), index=0)
        _cleanup_keys_in_interval(blendshape_fcurve, start_keyframe,
                                  end_keyframe)
        if name in read_facs:
            anim_data = [x for x in zip(keyframes, fan.at_name(name))]
            _put_anim_data_in_fcurve(blendshape_fcurve, anim_data)
            _snap_keys_in_interval(blendshape_fcurve, start_keyframe,
                                   end_keyframe)
        else:
            _add_zero_keys_at_start_and_end(blendshape_fcurve, start_keyframe,
                                            end_keyframe)
    obj.data.update()
    if len(keyframes) > 0:
        _extend_scene_timeline(keyframes[-1])

    logger.info('FACS CSV-Animation file: {}'.format(filepath))
    logger.info('Timecodes enabled: {}'.format(fan.timecodes_enabled()))
    if len(ignored_columns) > 0:
        logger.info('Ignored columns: {}'.format(ignored_columns))
    if len(read_facs) > 0:
        logger.info('Read facs: {}'.format(read_facs))
    return {
        'status': True,
        'message': 'ok',
        'ignored': ignored_columns,
        'read_facs': read_facs
    }
예제 #22
0
 class ProgressCallBack(pkt.module().ProgressCallback):
     def set_progress_and_check_abort(self, progress):
         bpy.context.window_manager.progress_update(progress)
         return False
예제 #23
0
 def init_bodybuilder(self, ver=Config.unknown_mod_ver):
     self.builder = pkt.module().BodyBuilder()
     self.builder_type = BuilderType.BodyBuilder
     self.version = ver
def test_non_loaded_uninstalled_load():
    if pkt.loaded():
        return
    pkt.uninstall()
    with pytest.raises(ImportError):
        pkt.module()
예제 #25
0
 def get_update_checker(cls):
     pykeentools = pkt.module()
     platform = 'Blender'
     ver = pykeentools.Version(*bpy.app.version)
     uc = pykeentools.UpdatesChecker.instance(platform, ver)
     return uc
예제 #26
0
 def execute(self, context):
     hardware_id = pkt.module().FaceBuilder.license_manager().hardware_id()
     bpy.ops.wm.url_open(url=Config.manual_install_url + '#' + hardware_id)
     return {'FINISHED'}
예제 #27
0
def _check_facs_available(count):
    return pkt.module().FacsExecutor.facs_available(count)
예제 #28
0
    def update_camera_params(cls, head):
        """ Update when some camera parameters changes """
        logger = logging.getLogger(__name__)
        logger.debug("UPDATE CAMERA PARAMETERS")

        settings = get_main_settings()
        scene = bpy.context.scene

        # Check scene consistency
        heads_deleted, cams_deleted = settings.fix_heads()

        headnum = -1
        for i, h in enumerate(settings.heads):
            if head == h:
                headnum = i

        if headnum < 0:
            return

        rx = scene.render.resolution_x
        ry = scene.render.resolution_y

        # NoneBuilder for auto-select builder class
        fb = cls.new_builder(BuilderType.NoneBuilder, head.mod_ver)
        cls.load_only(headnum)

        max_index = -1
        max_pins = -1
        for i, c in enumerate(head.cameras):
            kid = c.get_keyframe()
            cls.set_camera_projection(
                head.focal, head.sensor_width, rx, ry)
            # We are looking for keyframe that has maximum pins
            if c.has_pins():
                if max_pins < c.pins_count:
                    max_index = kid
                    max_pins = c.pins_count
            c.camobj.data.lens = head.focal
            c.camobj.data.sensor_width = head.sensor_width
            c.camobj.data.sensor_height = head.sensor_height

        # Setup Rigidity only for FaceBuilder
        FBLoader.rigidity_setup()
        # Activate Focal Estimation
        fb.set_focal_length_estimation(head.auto_focal_estimation)

        if max_index >= 0:
            try:
                # Solver
                fb.solve_for_current_pins(max_index)
                logger.debug("SOLVED {}".format(max_index))

            except pkt.module().UnlicensedException:
                logger.error("LICENSE PROBLEM")
                settings.force_out_pinmode = True
                settings.license_error = True
            except Exception:
                logger.error("SOLVER PROBLEM")
                settings.force_out_pinmode = True

        # Head Mesh update
        coords.update_head_mesh(fb, head.headobj)
        if settings.pinmode:
            cls.fb_redraw(headnum, settings.current_camnum)
        cls.update_all_camera_positions(headnum)
        cls.save_only(headnum)
예제 #29
0
 def get_latest_version(self):
     if self.builder_type in {BuilderType.NoneBuilder,
                              BuilderType.FaceBuilder}:
         return pkt.module().FaceBuilder.latest_face_version()
     else:
         return Config.unknown_mod_ver