5分钟让手绘小人动起来:AnimatedDrawings姿态估计技术全解析

5分钟让手绘小人动起来:AnimatedDrawings姿态估计技术全解析

【免费下载链接】AnimatedDrawings Code to accompany "A Method for Animating Children's Drawings of the Human Figure" 【免费下载链接】AnimatedDrawings 项目地址: https://gitcode.com/GitHub_Trending/an/AnimatedDrawings

你还在为手绘角色无法动起来而烦恼吗?本文将带你掌握AnimatedDrawings的核心技术,无需专业动画知识,只需简单几步即可让你的涂鸦角色跳起舞来。读完本文,你将学会:

  • 使用AI自动生成角色骨架和动作
  • 导出透明GIF和MP4动画
  • 自定义角色动作和场景背景

项目简介

AnimatedDrawings是一个开源项目,它能将儿童手绘的人物画自动转换为生动的动画。该项目基于论文《A Method for Animating Children's Drawings of the Human Figure》实现,通过深度学习模型检测手绘人物的姿态,再将3D动作数据迁移到手绘角色上。

项目核心功能包括:

  • 人物检测与姿态估计
  • 自动骨架生成与绑定
  • 动作捕捉数据迁移
  • 动画渲染与导出

快速开始

环境搭建

首先需要克隆项目并安装依赖:

# 创建并激活虚拟环境
conda create --name animated_drawings python=3.8.13
conda activate animated_drawings

# 克隆代码仓库
git clone https://gitcode.com/GitHub_Trending/an/AnimatedDrawings
cd AnimatedDrawings

# 安装依赖
pip install -e .

运行交互式示例

在Python环境中执行以下代码,即可看到一个会跳舞的手绘小人:

from animated_drawings import render
render.start('./examples/config/mvc/interactive_window_example.yaml')

运行后会打开一个交互式窗口,你可以使用空格键暂停/继续动画,方向键控制时间轴,按q键退出。

交互式动画示例

核心技术解析

姿态估计算法

AnimatedDrawings的核心是其手绘人物姿态估计算法。该系统使用训练好的深度学习模型自动检测手绘人物的关节位置,生成骨架结构。相关实现位于animated_drawings/model/retargeter.pyanimated_drawings/model/joint.py

算法流程如下:

  1. 检测手绘人物轮廓(使用掩码图像)
  2. 识别关键关节点(头、肩、肘、腕、髋、膝、踝等)
  3. 构建骨骼结构,建立关节间的父子关系
  4. 将3D动作数据映射到2D手绘角色

从图片到动画的完整流程

项目提供了一个一站式脚本examples/image_to_animation.py,可以直接将手绘图片转换为动画:

from image_to_annotations import image_to_annotations
from annotations_to_animation import annotations_to_animation

def image_to_animation(img_fn: str, char_anno_dir: str, motion_cfg_fn: str, retarget_cfg_fn: str):
    # 第一步:从图片生成骨骼标注
    image_to_annotations(img_fn, char_anno_dir)
    
    # 第二步:从标注生成动画
    annotations_to_animation(char_anno_dir, motion_cfg_fn, retarget_cfg_fn)

这个流程包含两个关键步骤:图片转标注和标注转动画。

实用功能指南

导出MP4视频

要将动画导出为MP4文件,使用以下配置:

from animated_drawings import render
render.start('./examples/config/mvc/export_mp4_example.yaml')

动画将保存为当前目录下的video.mp4文件。

MP4导出示例

导出透明GIF

如果需要透明背景的GIF动画,使用GIF导出配置:

from animated_drawings import render
render.start('./examples/config/mvc/export_gif_example.yaml')

自定义角色动画

项目提供了多个预定义角色和动作,位于examples/characters/examples/bvh/目录下。例如,要使用"dab"动作,可以使用examples/config/motion/dab.yaml配置文件。

以下是一个四足动物角色的示例:

from animated_drawings import render
render.start('./examples/config/mvc/four_legs_example.yaml')

四足动物示例

多角色场景

你还可以创建包含多个角色的动画场景,配置文件为examples/config/mvc/multiple_characters_example.yaml

from animated_drawings import render
render.start('./examples/config/mvc/multiple_characters_example.yaml')

多角色示例

高级应用

修复AI标注错误

当AI自动生成的关节位置不准确时,可以使用examples/fix_annotations.py工具手动调整:

python fix_annotations.py garlic_out/

这会启动一个Web界面,你可以在浏览器中拖动关节点到正确位置。

添加自定义背景

通过修改配置文件,可以为动画添加自定义背景图片。例如使用examples/config/mvc/background_example.yaml

from animated_drawings import render
render.start('./examples/config/mvc/background_example.yaml')

背景示例

创建自定义动作

你可以使用BVH格式的动作捕捉文件创建自定义动画。项目提供了多个示例动作,如:

结语

AnimatedDrawings项目为手绘角色动画提供了一个简单而强大的解决方案。无论是教育、娱乐还是创意设计,它都能帮助你快速将静态手绘转换为生动的动画。

如果你想深入了解更多功能,可以查阅examples/config/README.md了解配置文件的详细说明,或查看项目的论文了解技术细节。

现在,轮到你发挥创意,让你的手绘角色动起来了!

【免费下载链接】AnimatedDrawings Code to accompany "A Method for Animating Children's Drawings of the Human Figure" 【免费下载链接】AnimatedDrawings 项目地址: https://gitcode.com/GitHub_Trending/an/AnimatedDrawings

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值