realsense 人脸三维重建

1.dlib检测人脸

2.保存彩色信息(png)和深度信息(npy)

3.点云显示

#coding = utf-8
import pyrealsense2 as rs
import cv2
import numpy as np
import dlib
import pcl

def find_martrix_min(data_matrix):
    new_data=[]
    for i in range(len(data_matrix)):
        new_data.append(min(data_matrix[i]))
    return min(new_data)

def find_martrix_max(data_matrix):
    new_data=[]
    for i in range(len(data_matrix)):
        new_data.append(max(data_matrix[i]))
    return max(new_data)

#广度优先搜索
def floodfill(image,seed,threshold_min,threshold_max):
    Q=[]
    g = np.zeros((len(image),len(image[0])))
    Q.append([seed[0],seed[1]])
    g[seed[0],seed[1]] = 1
    while len(Q)>0:
        [x, y] = Q.pop(0)
        x1, y1 = x - 1, y
        x2, y2 = x, y - 1
        x3, y3 = x + 1, y
        x4, y4 = x, y + 1

        if x1>=0 and y1>=0 and x1threshold_min and image[x1][y1] =0 and y2>=0 and x2threshold_min  and image[x2][y2] =0 and y3>=0 and x3threshold_min and image[x3][y3] =0 and y4>=0 and x4threshold_min and image[x4][y4]  

 

你可能感兴趣的:(三位重建)