python如何提取视频中人物的深度信息?
网友回复
可使用 Depth Anything V2
import cv2
import numpy as np
import torch
import mediapipe as mp
from PIL import Image
from transformers import pipeline
def load_depth_model():
device = 0 if torch.cuda.is_available() else -1
depth_pipe = pipeline(
task="depth-estimation",
model="depth-anything/Depth-Anything-V2-Small-hf",
device=device
)
return depth_pipe
def load_person_segmenter():
mp_selfie = mp.solutions.selfie_segmentation
return mp_selfie.SelfieSegmentation(model_selection=1)
def get_person_mask(frame_rgb, segmenter):
result = segmenter.process(frame_rgb)
mask = result.segmentation_mask > 0.5
return mask
def main(video_path, output_path="person_depth_da.mp4"):
cap = cv2.VideoCapture(video_path)
...点击查看剩余70%
最新的国内外ai大模型能力排行榜有吗?
国产图片大模型seedream-5及qwen-image-3都无法生成360度全景图片?
听说OpenAI的Astra太强了可能会失控?
qwen3.8-max比较适合那些场景?
python有没有免费的股市行情数据api可用?
UUIDv7、nanoid、Snowflake、ULID与sparkid这些id生成器区别?
get请求报错NS_BINDING_ABORTED是什么原因?
happyhorse与seedance及minmax h3到底哪个更好?
scriptc为啥能生成一个不带nodejs的原生二进制可执行程序?
为啥huggingface那么多ai图片和视频模型都能一键脱衣没人管呢?


