Normal与depth互相计算

这篇博客介绍了如何利用matlab和pytorch代码计算法线向量,以及从法线向量计算深度。内容包括引用了Data-driven 3d primitives for single image understanding的matlab算法,以及基于GeoNet理论的pytorch实现。注意,pytorch版本需大于等于1.3.1以支持torch.det()函数。
部署运行你感兴趣的模型镜像

Compute normal vector from depth

代码地址ComputeNormal

matlab code

代码参考Data-driven 3d primitives for single image understanding

使用matlab库函数surfnorm

算法

input: D Depth map,K Camera intrinsic
output: N Surface normal map
def GenerateSurfaceNormal(D, K)
    P (X, Y, Z) <-- f(D, K)
    for i in D:
        S = [p_i]
        for j in i neighborings:
            S <-- P_j
		# 最小二乘fitting
        N_i <-- least_squares_fitting(S)
	# 双边滤波
    bilateralFilter(N, sigma_s=24, sigma_I=0.2)
    
    return N

运行

matlab -nodesktop -nosplash -r generate_normal_gt_demon
or
bash run.sh

pytorch code

理论参考GeoNet,自己采用pytorch实现。

Note: pytorch>=1.3.1 for torch.det()

运行

python ComputeNormal.py

Compute depth from normal

理论参考GeoNet,自己采用pytorch实现。

Note: pytorch>=1.3.1 for torch.det()

运行

python Normal2Depth.py

[init_depth, normal] -> refined depth

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值