Skip to main content

A non-web Live2D library for Python.

Project description

koe live2d-py


Docker Build Version Python Version CMake C++17 CsmSDK

English README

注意:本仓库不包含 Live2D Cubism Core 及 Framework(受许可限制),源码编译时需自行从 Live2D官网 下载。

使用 Python 直接加载和操作 Live2D 模型,不通过 Web Engine 等间接手段进行渲染。

基于 Python C Extension 对 Live2D Native SDK (C++) 进行了封装。理论上,只要配置好 OpenGL 上下文,可在 Python 中将 live2d 绘制在任何基于 OpenGL 的窗口。

代码使用示例:examples

详细使用文档:Wiki

修改和开发:CONTRIBUTING

兼容UI库

理论上兼容所有能使用 OpenGL 进行绘制的UI库: Pygame / PyQt5 / PySide2 / PySide6 / GLFW / pyopengltk / FreeGlut / Qfluentwidgets ...

支持功能

  • 加载模型:Cubism 2.1Cubism 3.0 及以上版本
  • 视线跟踪
  • 点击交互
  • 动作播放回调
  • 口型同步
  • 模型各部分参数控制
  • 各部件透明度控制
  • 精确到部件的点击检测

兼容性

Cubism Live2D 版本

live2d-py 支持的live2d模型 实现
live2d.v2 Cubism 2.1 以及更早的版本 纯 Python 实现
live2d.v2cpp Cubism 2.1 以及更早的版本 C++ 移植 (高性能)
live2d.v3 Cubism 3.0 及以上版本 Python C Extension 封装

推荐使用 live2d.v2cpp 替代 live2d.v2 以获得更好的性能。API 完全兼容,只需将 import live2d.v2 as live2d 替换为 import live2d.v2cpp as live2d

Python 版本及平台

:white_check_mark:: 可用, 支持, 已通过

:question:: 尚未测试

:construction:, :x:: 编译期问题或平台兼容性问题待解决

Platform Python Version live2d.v2 live2d.v2cpp live2d.v3 PyPI
macOS arm64 >=3.11 :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
Windows x64 >=3.11 :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
Linux x64 >=3.11 :white_check_mark: :white_check_mark: :white_check_mark: :x:

注:

  • Cubism 2.X 导出的模型:文件名格式常为 XXX.mocXXX.model.jsonXXX.mtn
  • Cubism 3.0 及以上导出的模型:文件名格式常为 XXX.moc3XXX.model3.json, XXX.motion3.json

使用说明

  1. Release 中下载对应版本的 whl 文件并安装(推荐)
pip install live2d_py-0.X.X-cpXXX-cpXXX-win_amd64.whl
  1. 通过 PyPI 安装
pip install live2d-py
  1. 从源码构建,参考 安装#源码构建

示例

简易面捕

源码见 main_facial_bind.py

面捕-期末周破防

基于 live2d-py C 模块及 Qt 开发的 Live2DViewer

Live2DViewer

多模型加载

源码见 main_glfw_four_model.py

multi_model

添加背景

源码见 main_pygame_background.py

background

模型变换 & 口型同步音频 & 点击测试

源码见 main_glfw.py

完整用例

模型整体透明度示例

源码见 main_pyqt5_canvas_opacity.py

opacity

鸣谢

特别感谢以下用户为本项目提供的帮助和支持: 96bearli, Ovizro, AnyaCoder, jahtim, Honghe, RobertMeow, LUORANCHENG, TinyKiecoo, Barracuda72, GuangChen2333, makabakadot, thynetruly, mastwet, KyvYang, @Mozilla88, @CooperWang0912, @minghf85

非常感谢以下项目及其贡献者们的帮助:

CubismNativeSamples (live2d.v3)

Cubism2 Web SDK (live2d.v2)

de4jsJavaScript 反混淆工具)

JsConvert (JavascriptPython 工具)

D2Evil (moc 文件分析)

facial-landmarks-for-cubism (面捕参考)

Live2D 模型:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

live2d_py-0.7.0.4-cp314-cp314-win_amd64.whl (451.3 kB view details)

Uploaded CPython 3.14Windows x86-64

live2d_py-0.7.0.4-cp314-cp314-macosx_15_0_universal2.whl (532.6 kB view details)

Uploaded CPython 3.14macOS 15.0+ universal2 (ARM64, x86-64)

live2d_py-0.7.0.4-cp313-cp313-win_amd64.whl (440.2 kB view details)

Uploaded CPython 3.13Windows x86-64

live2d_py-0.7.0.4-cp313-cp313-macosx_15_0_universal2.whl (532.4 kB view details)

Uploaded CPython 3.13macOS 15.0+ universal2 (ARM64, x86-64)

live2d_py-0.7.0.4-cp312-cp312-win_amd64.whl (440.0 kB view details)

Uploaded CPython 3.12Windows x86-64

live2d_py-0.7.0.4-cp312-cp312-macosx_15_0_universal2.whl (532.0 kB view details)

Uploaded CPython 3.12macOS 15.0+ universal2 (ARM64, x86-64)

live2d_py-0.7.0.4-cp311-cp311-win_amd64.whl (440.0 kB view details)

Uploaded CPython 3.11Windows x86-64

live2d_py-0.7.0.4-cp311-cp311-macosx_15_0_universal2.whl (532.1 kB view details)

Uploaded CPython 3.11macOS 15.0+ universal2 (ARM64, x86-64)

live2d_py-0.7.0.4-cp310-cp310-win_amd64.whl (440.0 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file live2d_py-0.7.0.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 5c958e51771bc4e86477cdd0ba684af046e7e9c4d2938c663d8fd620844c9cd9
MD5 b9665cb16129016c777b45dc0e97b2ed
BLAKE2b-256 a0d37bec98d363ee0448230e0d685a38f9586f23dfae2ee4e8817f52383bdf9c

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp314-cp314-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp314-cp314-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 f4b9817a079496d7e525edad98bbd0ae8b0001bad22d784798ca82b7f762714e
MD5 dd17d7404aee1fe2ed148d1cc5d86c49
BLAKE2b-256 00dc6c64084356678241b21154f97dbcb4496dc8e1e98424fbb0c080e32e883c

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: live2d_py-0.7.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 440.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for live2d_py-0.7.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 01d8352ad82fc29f2055568488e506f46426a1f14997f625fdd9a12c6f42a325
MD5 29c54ded81d4874c5c82cae95175c3e7
BLAKE2b-256 a42aec25680b7b19ee8ab00d59cec8fd7bc78968510f8e94d44b16c6d3f5e54d

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp313-cp313-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp313-cp313-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 f49f131e4f273f4a3d9f8689a4eefb18782c27e9d4c9c19ab02fcd4fba848865
MD5 a15881caa2ecf131af4aa3b7d6921d3e
BLAKE2b-256 184d27e3bced00b118db1ec3f99dabef90520eed1af6c30c2bf444446cd6a998

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 53011380ffc8f04fb4fcfe28e6e5e620e15554a8c821eb607374699bec6b3f15
MD5 0c676c2482feb7b83d9d5494cc89f5e0
BLAKE2b-256 195a88833169f6482ff2b83a8ccf516dfc8b8959e96869c486ce2237a4419e8c

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp312-cp312-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp312-cp312-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 7b62e382eb9f41b47a55fefd5a3c2270ce10d0a30c56557fb242580483500637
MD5 e28ffd32f38202c518864c570759005d
BLAKE2b-256 6a4da9af87db801eca31f19ad18e8b0a2b82f7014993d800f8fdd67ed7a7de7e

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a3b17c64d2d59415bfd4aa0efa076a1e0847b56f01fefb9ecd42eacad3b49dc8
MD5 7604e5ce3af85a4e1abbf7b1242ce5ac
BLAKE2b-256 5281ae4307b4877cfdb7d90d4fc6ddb0e6479d5011dd75ac9a242205d55251ec

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp311-cp311-macosx_15_0_universal2.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp311-cp311-macosx_15_0_universal2.whl
Algorithm Hash digest
SHA256 b48807daad56a1b4f12896f86d81d44f8b9a02cc400402765ddb75835d8dc714
MD5 a59472b452b257e31c006bf6de37f247
BLAKE2b-256 0d93053b473651fe2db5dbdc0434d3628be6e9e11ce3dc1ba5dc077ecb2a4001

See more details on using hashes here.

File details

Details for the file live2d_py-0.7.0.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for live2d_py-0.7.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 84d4973e9aa84adae2c96a5df1b91cd1ee2bdb1f18455076e06f1742d63444eb
MD5 f8d0adb7abe202b5250bed8be6966da5
BLAKE2b-256 55a0329220a556804b9e91504a7890d296a9184130a2bdf73477ecc5a3e93afb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page