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%
python如何完整下载一个网页的html代码和引入的js css图片等其他资源?
谷歌最新发布的三款gemini4模型有啥区别?
ai生成的代码能运行在安全要求比较高的行业吗?
fable5.2生成的经典网页代码在哪能下载?
图片ai拒绝帮用户ps修改带公章类的拍照图片如何解决?
视频大模型和最强文本大模型通过代码生成视频哪个性价比更高?
seedream5.5为啥无法将图白色背景修改成透明?
seedance2如何通过2张不同角度平视图来识别场景进行人物定位?
有没有免费的浏览器中离线运行的语音识别ai模型?
微信小程序个人版不交钱认证就不让你用二维码,报错"errcode":85411?


