mcpField
D
depth-map-generation

depth-map-generation

github.com/eachlabs创意与媒体44204 次安装今天更新
代码仓库

关于 depth-map-generation

使用 each::sense 从图像估算深度并生成深度图,适用于制作视觉效果、3D 视图或 VR/AR 流程的创作者与开发者;支持灰度、归一化和度量深度输出。

主要功能

  1. 01从单张图像估算深度
  2. 02生成肖像与风景深度图
  3. 03输出灰度、归一化或度量深度
  4. 04支持视差动画和立体图像流程
  5. 05支持景深模糊与焦点选择

适用场景

  1. 01为人像添加自然背景虚化
  2. 02从静态照片制作视差动画
  3. 03为 AR/VR 场景准备深度数据
  4. 04从 2D 图像生成立体视图

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/eachlabs/skills --skill depth-map-generation

安装后在 Claude Code 中输入/depth-map-generation确认已加载。

附带文件references/SSE-EVENTS.md

详细介绍

深度图生成

使用 each::sense 从任意图像生成精准的深度图。这项技能可从 2D 图像中提取深度信息,适用于 3D 效果、视差动画、VR/AR 应用、计算摄影等。

功能

  • 单目深度估计:从单张图像中提取深度
  • 人像深度图:为人像摄影效果提供精准深度
  • 风景深度:提取全景和风景图像的场景深度
  • 产品深度:为电商生成适用于 3D 的深度图
  • 建筑深度:分析建筑和室内场景的深度
  • 3D 视差效果:为 Ken Burns 风格动画提供深度数据
  • VR/AR 深度:为沉浸式体验实时估计深度
  • 立体图像生成:将 2D 图像转换为立体 3D
  • 焦点堆栈:基于深度选择焦平面
  • 背景虚化:支持深度感知的焦外虚化和模糊效果

快速开始

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this photo"}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/photo.jpg"],
    "mode": "max"
  }'

深度图输出格式

格式描述用途
灰度8 位深度(白色 = 近,黑色 = 远)通用用途、可视化
反向灰度8 位深度(黑色 = 近,白色 = 远)兼容部分 3D 软件
归一化0-1 范围的深度值机器学习流水线
度量估算现实世界距离AR/VR、机器人

用例示例

1. 从照片生成深度图

从任意图像中提取深度的基本方法。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this image. Output as grayscale where white represents closer objects and black represents distant objects."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/scene.jpg"],
    "mode": "max"
  }'
2. 人像深度图

从人像照片中提取精准深度,用于焦外虚化效果和 3D 人像。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Create a high-precision depth map from this portrait photo. Focus on accurate edge detection around the subject, especially hair and facial features. I need this for applying realistic depth-of-field effects."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/portrait.jpg"],
    "mode": "max"
  }'
3. 风景深度图

从风景和户外场景中生成深度,并提供更大的深度范围。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this landscape photo. The scene has foreground elements, mid-ground terrain, and distant mountains. Capture the full depth range from near to far with good separation between depth layers."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/landscape.jpg"],
    "mode": "max"
  }'
4. 用于 3D 效果的产品深度

为产品图像创建深度图,以支持 3D 查看体验。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Extract a depth map from this product photo. I need accurate depth information to create a 3D interactive view for an e-commerce website. Focus on capturing the product shape and surface details."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/product-sneaker.jpg"],
    "mode": "max"
  }'
5. 建筑深度图

从建筑和室内照片中生成深度,用于可视化。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Create a depth map from this interior architecture photo. Capture the spatial relationships between walls, furniture, and architectural elements. I need this for a virtual tour with depth-based transitions."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/interior.jpg"],
    "mode": "max"
  }'
6. 创建 3D 视差效果

生成适用于创建视差动画和 Ken Burns 效果的深度图。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this photo that I will use for a 3D parallax animation. I need clear depth separation between foreground, midground, and background elements. The depth should be smooth with distinct layers for a compelling parallax effect."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/scene-for-parallax.jpg"],
    "mode": "max"
  }'
7. VR/AR 深度估计

创建适用于虚拟现实和增强现实应用的深度图。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this room photo for AR/VR use. I need metric depth estimation that accurately represents real-world distances. This will be used for placing virtual objects in an augmented reality application."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/room.jpg"],
    "mode": "max"
  }'
8. 立体图像生成

使用深度估计将 2D 图像转换为立体 3D。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this photo and use it to create a stereoscopic 3D image pair (left and right eye views). The stereo effect should be subtle enough for comfortable viewing but noticeable enough to create depth perception."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/photo-for-stereo.jpg"],
    "mode": "max"
  }'
9. 焦点堆栈深度

生成深度图,用于计算摄影焦点堆栈和全景深合成。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Create a depth map from this macro/close-up photo. I need precise depth information to identify focus planes for computational focus stacking. Each depth layer should be clearly defined so I can select which areas should be in focus."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/macro-photo.jpg"],
    "mode": "max"
  }'
10. 深度感知背景虚化

生成深度信息,以应用逼真的焦外虚化和背景模糊效果。

curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this photo for applying depth-aware background blur. The subject in the foreground should be clearly separated from the background. I need accurate edge detection so the blur transition looks natural, similar to a portrait mode effect."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/photo-for-blur.jpg"],
    "mode": "max"
  }'

多轮深度处理

使用 session_id 优化深度图或处理多张相关图像:

# Initial depth estimation
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this photo"}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/scene.jpg"],
    "session_id": "depth-project-001"
  }'

# Refine the depth map
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "The depth map looks good but can you enhance the edge detection around the main subject? The boundaries are a bit fuzzy."}],
    "model": "eachsense/beta",
    "stream": true,
    "session_id": "depth-project-001"
  }'

# Apply the depth map for an effect
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Now use this depth map to create a 3D parallax video animation with subtle camera movement"}],
    "model": "eachsense/beta",
    "stream": true,
    "session_id": "depth-project-001"
  }'

批量深度处理

处理多张图像,以获得一致的深度估计:

# Process first image
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate a depth map from this product photo. I will be sending more product images that need consistent depth estimation."}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/product1.jpg"],
    "session_id": "product-depth-batch",
    "mode": "eco"
  }'

# Process second image with same settings
curl -X POST https://eachsense-agent.core.eachlabs.run/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $EACHLABS_API_KEY" \
  -H "Accept: text/event-stream" \
  -d '{
    "messages": [{"role": "user", "content": "Generate depth map for this product using the same approach as before"}],
    "model": "eachsense/beta",
    "stream": true,
    "image_urls": ["https://example.com/product2.jpg"],
    "session_id": "product-depth-batch",
    "mode": "eco"
  }'

模式选择

模式最适用场景速度质量
max最终制作深度图、VR/AR 应用、专业合成较慢精度最高
eco快速预览、批量处理、原型制作较快质量良好

**建议:**当深度精度至关重要时(VR/AR、3D 转换、专业合成),使用 max 模式。快速迭代和批量处理时使用 eco 模式。

最佳实践

输入图像质量
  • 分辨率:输入分辨率越高,生成的深度图细节越丰富
  • 光照:均匀的光照有助于精准估计深度
  • 对比度:物体之间对比清晰,有助于区分深度
  • 对焦:清晰的图像有助于更准确地检测深度图中的边缘
深度图应用
  • 视差效果:使用 3-5 个不同的深度层,以获得最佳效果
  • 焦外虚化/模糊:确保主体边缘清晰干净,使模糊过渡自然
  • 3D 转换:提供场景尺度信息,便于估算度量深度
  • VR/AR:请求度量深度,以准确估算现实世界距离
提示词技巧
  1. 指定输出格式:灰度、归一化或度量深度
  2. 描述场景:帮助模型理解空间关系
  3. 说明使用场景:不同应用适合不同的深度特征
  4. 提出边缘质量要求:说明需要清晰还是平滑的深度过渡

错误处理

错误原因解决方案
Failed to create prediction: HTTP 422余额不足在 eachlabs.ai 充值
图像加载失败图像 URL 无效或无法访问确认图像 URL 可公开访问
超时图像过于复杂或分辨率过高将客户端超时设为至少 10 分钟
深度输出质量较低输入图像质量较差使用分辨率更高、光线更好的源图像

技术说明

  • 客户端超时:对于复杂的深度估算,将 HTTP 客户端超时设为至少 10 分钟
  • 图像格式:支持 JPEG、PNG、WebP 输入图像
  • 输出格式:深度图通常以灰度 PNG 图像的形式输出
  • 深度范围:默认使用相对深度(0-1);也可按需提供度量深度

相关技能

  • each-sense - 核心 API 文档
  • image-to-3d - 根据图像生成完整的 3D 模型
  • image-editing - 对图像应用基于深度的效果
  • video-generation - 根据深度图创建视差视频

评论

支持 Markdown