如何生成3D点云的凹包?68个人脸关键点网格构建求助
如何为68个3D人脸稀疏关键点生成凹包并构建正确网格?
- 尝试使用Delaunay三角剖分,仅能生成凸包,无法保留眼睛等凹部结构,效果不佳。
- 使用alphashape库未成功,不添加特定测试点时会报错:
too many indices for array: array is 1-dimensional, but 2 were indexed。
附图说明问题:
相关图片:
上图为待转换的3D点,下图为alphashape运行结果。
以下为相关代码:
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import alphashape points_3d = np.array(sixtyEightLandmarks3D) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(points_3d[:, 0], points_3d[:, 1], points_3d[:, 2]) plt.show() points_3d = [ (0., 0., 0.), (0., 0., 1.), (0., 1., 0.), (1., 0., 0.), (1., 1., 0.), (1., 0., 1.), (0., 1., 1.), (1., 1., 1.), (.25, .5, .5), (.5, .25, .5), (.5, .5, .25), (.75, .5, .5), (.5, .75, .5), (.5, .5, .75) ] points_3d = [ (7, 191, 325.05537989702617), (6, 217, 330.15148038438355), (8, 244, 334.2528982671654), (11, 270, 340.24843864447047), (19, 296, 349.17330940379736), (34, 320, 361.04985805287333), (56, 340, 373.001340480165), (80, 356, 383.03263568526376), (110, 361, 387.06330231630074), (140, 356, 383.08354180256816), (165, 341, 373.1621631409058), (187, 321, 359.4022815731698), (205, 298, 344.64039229318433), (214, 272, 334.72376670920755), (216, 244, 328.54984401152893), (218, 217, 324.34703636691364), (217, 190, 319.189598828032), (22, 166, 353.0056656769123), (33, 152, 359.0055709874152), (52, 145, 364.0), (72, 147, 368.00135869314397), (91, 153, 372.0013440835933), (125, 153, 370.0013513488836), (145, 146, 366.001366117669), (167, 144, 361.0), (186, 151, 358.00558654859003), (197, 166, 351.0056979594491), (108, 179, 376.02127599379264), (108, 197, 381.02099679676445), (109, 214, 387.03229839381623), (109, 233, 393.04579885809744), (87, 252, 383.03263568526376), (98, 255, 386.0323820614017), (109, 257, 387.03229839381623), (120, 254, 385.0324661635691), (131, 251, 383.0469945058961), (44, 183, 360.01249978299364), (55, 176, 363.00550960006103), (69, 176, 363.0123964825444), (81, 186, 364.0219773585106), (69, 188, 364.0219773585106), (54, 188, 364.0219773585106), (136, 185, 361.01246515875323), (147, 175, 362.0013812128346), (162, 175, 361.00554012369395), (174, 183, 357.0014005574768), (163, 188, 360.01249978299364), (149, 188, 362.01243072579706), (73, 289, 384.04687213932624), (86, 282, 389.0462697417879), (100, 278, 391.0319680026174), (109, 281, 391.0460330958492), (120, 277, 391.0319680026174), (134, 281, 387.03229839381623), (147, 289, 380.0210520484359), (135, 299, 388.03221515745315), (121, 305, 392.04591567825315), (110, 307, 392.04591567825315), (100, 306, 392.04591567825315), (86, 300, 391.0626548265636), (78, 290, 386.0207248322297), (100, 290, 391.0319680026174), (109, 291, 391.0319680026174), (120, 289, 391.0319680026174), (142, 289, 381.03280698648507), (120, 290, 391.0319680026174), (109, 292, 392.03188645823184), (100, 291, 392.04591567825315), (0., 1., 1.), (1., 1., 1.), (.25, .5, .5), (.5, .25, .5) ] alpha_shape = alphashape.alphashape(points_3d, lambda ind, r: 0.3 + any(np.array(points_3d)[ind][:,0] == 0.0)) fig = plt.figure() ax = plt.axes(projection='3d') ax.plot_trisurf(*zip(*alpha_shape.vertices), triangles=alpha_shape.faces) plt.show()
注:手动将人脸关键点存入points_3d变量。
内容的提问来源于stack exchange,提问作者Sammy Medawar
相关产品推荐
相关产品推荐

