PhotoWakeUp —— 创新实训(7)

    xiaoxiao2022-07-03  127

    求出的正反面的深度图如下

    发现约有5%的点对应深度图不准确

     

    https://www.jianshu.com/p/1aac118197ff(obj文件的格式)

    接下来从深度图重新构建三维模型,深度值从之前得到的深度图直接读取,构建三维mesh时,将相邻的四个点相连,构造成两个三角形,点的顺序逆时针,主要代码如下

    with open(r'b.obj','w+') as file: #几何体顶点 for q in pointdepth: file.write('v '+str(q[0])+' '+str(q[1])+' '+str(q[2])+'\n') for q in back_pointdepth: file.write('v '+str(q[0])+' '+str(q[1])+' '+str(q[2])+'\n') #面 for i in range(x-1): for ii in range(y-1): if(img[i][ii]!=0 and img[i+1][ii]!=0 and img[i+1][ii+1]!=0 and img[i][ii+1]!=0): qurt.append([dp_matrix_value[i,ii],dp_matrix_value[i+1,ii],dp_matrix_value[i+1,ii+1],dp_matrix_value[i,ii+1]]) # 124 234 for qu in qurt: file.write('f '+str(int(qu[0]))+' '+str(int(qu[1]))+' '+str(int(qu[3]))+'\n') file.write('f '+str(int(qu[1]))+' '+str(int(qu[2]))+' '+str(int(qu[3]))+'\n') #面 for i in range(x-1): for ii in range(y-1): if(back_img[i][ii]!=0 and back_img[i+1][ii]!=0 and back_img[i+1][ii+1]!=0 and back_img[i][ii+1]!=0): back_qurt.append([back_dp_matrix_value[i,ii],back_dp_matrix_value[i+1,ii],back_dp_matrix_value[i+1,ii+1],back_dp_matrix_value[i,ii+1]]) # 124 234 for qu in back_qurt: file.write('f '+str(int(qu[0]))+' '+str(int(qu[1]))+' '+str(int(qu[3]))+'\n') file.write('f '+str(int(qu[1]))+' '+str(int(qu[2]))+' '+str(int(qu[3]))+'\n')

    得到的obj打开如下所示,正面效果尚可

    然而侧面,发现边缘深度值因为缺失的原因,效果很差,需要进一步处理

    使用工具进行简单贴图后正面效果如下

    将反面也相似操作后,看效果

    最新回复(0)