具体流程

一、SMPL模型

SMPL模型拥有6890个XYZ坐标的3D人体点,目前第一步需要将这6890个人体点进行分析,并将不同部位的点位进行归并,具体分为以下几个部分:头部,胸部,腰部,左臂,右臂,左腿,右腿。因6890个XYZ坐标并非连续的坐标,是先描述左半边身体,然后再描述右半边身体,所以需花费较长时间分类。

上述分类区域的部署是为了方便找到具体点位的XYZ坐标范围,方便对应IUV坐标。

二、具体流程

实现具体流程

#mermaid-svg-qZho1VZ5l8YO2Yi5 .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .label text{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .node rect,#mermaid-svg-qZho1VZ5l8YO2Yi5 .node circle,#mermaid-svg-qZho1VZ5l8YO2Yi5 .node ellipse,#mermaid-svg-qZho1VZ5l8YO2Yi5 .node polygon,#mermaid-svg-qZho1VZ5l8YO2Yi5 .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .node .label{text-align:center;fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .node.clickable{cursor:pointer}#mermaid-svg-qZho1VZ5l8YO2Yi5 .arrowheadPath{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .flowchart-link{stroke:#333;fill:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edgeLabel rect{opacity:0.9}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edgeLabel span{color:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .cluster text{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-qZho1VZ5l8YO2Yi5 .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-qZho1VZ5l8YO2Yi5 text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .actor-line{stroke:grey}#mermaid-svg-qZho1VZ5l8YO2Yi5 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sequenceNumber{fill:#fff}#mermaid-svg-qZho1VZ5l8YO2Yi5 #sequencenumber{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 #crosshead path{fill:#333;stroke:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .messageText{fill:#333;stroke:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-qZho1VZ5l8YO2Yi5 .labelText,#mermaid-svg-qZho1VZ5l8YO2Yi5 .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .loopText,#mermaid-svg-qZho1VZ5l8YO2Yi5 .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-qZho1VZ5l8YO2Yi5 .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-qZho1VZ5l8YO2Yi5 .noteText,#mermaid-svg-qZho1VZ5l8YO2Yi5 .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-qZho1VZ5l8YO2Yi5 .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .section{stroke:none;opacity:0.2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .section2{fill:#fff400}#mermaid-svg-qZho1VZ5l8YO2Yi5 .section1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .section3{fill:#fff;opacity:0.2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sectionTitle0{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sectionTitle1{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sectionTitle2{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sectionTitle3{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-qZho1VZ5l8YO2Yi5 .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .grid path{stroke-width:0}#mermaid-svg-qZho1VZ5l8YO2Yi5 .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .task{stroke-width:2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText:not([font-size]){font-size:11px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .task.clickable{cursor:pointer}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskText3{fill:#fff}#mermaid-svg-qZho1VZ5l8YO2Yi5 .task0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .task1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .task2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutside0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutside2{fill:#000}#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutside1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .taskTextOutside3{fill:#000}#mermaid-svg-qZho1VZ5l8YO2Yi5 .active0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .active1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .active2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeText0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeText1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeText2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeText3{fill:#000 !important}#mermaid-svg-qZho1VZ5l8YO2Yi5 .done0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .done1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .done2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneText0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneText1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneText2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneText3{fill:#000 !important}#mermaid-svg-qZho1VZ5l8YO2Yi5 .crit0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .crit1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .crit2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCrit0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCrit1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCrit2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCrit0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCrit1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCrit2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-qZho1VZ5l8YO2Yi5 .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .milestoneText{font-style:italic}#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCritText0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCritText1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCritText2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .doneCritText3{fill:#000 !important}#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCritText0,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCritText1,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCritText2,#mermaid-svg-qZho1VZ5l8YO2Yi5 .activeCritText3{fill:#000 !important}#mermaid-svg-qZho1VZ5l8YO2Yi5 .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.classGroup text .title{font-weight:bolder}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.clickable{cursor:pointer}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-qZho1VZ5l8YO2Yi5 .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .dashed-line{stroke-dasharray:3}#mermaid-svg-qZho1VZ5l8YO2Yi5 #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 .commit-id,#mermaid-svg-qZho1VZ5l8YO2Yi5 .commit-msg,#mermaid-svg-qZho1VZ5l8YO2Yi5 .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-qZho1VZ5l8YO2Yi5 g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-qZho1VZ5l8YO2Yi5 .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-qZho1VZ5l8YO2Yi5 .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-qZho1VZ5l8YO2Yi5 .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edgeLabel text{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-qZho1VZ5l8YO2Yi5 .node circle.state-start{fill:black;stroke:black}#mermaid-svg-qZho1VZ5l8YO2Yi5 .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-qZho1VZ5l8YO2Yi5 #statediagram-barbEnd{fill:#9370db}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-state .divider{stroke:#9370db}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-qZho1VZ5l8YO2Yi5 .note-edge{stroke-dasharray:5}#mermaid-svg-qZho1VZ5l8YO2Yi5 .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-qZho1VZ5l8YO2Yi5 .error-icon{fill:#522}#mermaid-svg-qZho1VZ5l8YO2Yi5 .error-text{fill:#522;stroke:#522}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edge-thickness-normal{stroke-width:2px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-qZho1VZ5l8YO2Yi5 .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-qZho1VZ5l8YO2Yi5 .marker{fill:#333}#mermaid-svg-qZho1VZ5l8YO2Yi5 .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-qZho1VZ5l8YO2Yi5 {color: rgba(0, 0, 0, 0.75);font: ;}

推理Densepose得到IUV坐标
将IUV坐标转换成XYZ坐标
根据预先找到各个点位的XYZ坐标范围保存IUV坐标范围
于原图中匹配到IUV坐标范围的位置索引
用位置索引在原图中画出点位

若找到了各个点位的IUV坐标范围后,后期推理流程会省略将IUV坐标转换成XYZ坐标去匹配点位的XYZ坐标这个步骤,演变成下面流程:

#mermaid-svg-uQSoC8VC6LqJYOBo .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .label text{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .node rect,#mermaid-svg-uQSoC8VC6LqJYOBo .node circle,#mermaid-svg-uQSoC8VC6LqJYOBo .node ellipse,#mermaid-svg-uQSoC8VC6LqJYOBo .node polygon,#mermaid-svg-uQSoC8VC6LqJYOBo .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-uQSoC8VC6LqJYOBo .node .label{text-align:center;fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .node.clickable{cursor:pointer}#mermaid-svg-uQSoC8VC6LqJYOBo .arrowheadPath{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-uQSoC8VC6LqJYOBo .flowchart-link{stroke:#333;fill:none}#mermaid-svg-uQSoC8VC6LqJYOBo .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-uQSoC8VC6LqJYOBo .edgeLabel rect{opacity:0.9}#mermaid-svg-uQSoC8VC6LqJYOBo .edgeLabel span{color:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-uQSoC8VC6LqJYOBo .cluster text{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-uQSoC8VC6LqJYOBo .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-uQSoC8VC6LqJYOBo text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-uQSoC8VC6LqJYOBo .actor-line{stroke:grey}#mermaid-svg-uQSoC8VC6LqJYOBo .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-uQSoC8VC6LqJYOBo #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .sequenceNumber{fill:#fff}#mermaid-svg-uQSoC8VC6LqJYOBo #sequencenumber{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo #crosshead path{fill:#333;stroke:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .messageText{fill:#333;stroke:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-uQSoC8VC6LqJYOBo .labelText,#mermaid-svg-uQSoC8VC6LqJYOBo .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-uQSoC8VC6LqJYOBo .loopText,#mermaid-svg-uQSoC8VC6LqJYOBo .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-uQSoC8VC6LqJYOBo .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-uQSoC8VC6LqJYOBo .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-uQSoC8VC6LqJYOBo .noteText,#mermaid-svg-uQSoC8VC6LqJYOBo .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-uQSoC8VC6LqJYOBo .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-uQSoC8VC6LqJYOBo .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-uQSoC8VC6LqJYOBo .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-uQSoC8VC6LqJYOBo .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .section{stroke:none;opacity:0.2}#mermaid-svg-uQSoC8VC6LqJYOBo .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-uQSoC8VC6LqJYOBo .section2{fill:#fff400}#mermaid-svg-uQSoC8VC6LqJYOBo .section1,#mermaid-svg-uQSoC8VC6LqJYOBo .section3{fill:#fff;opacity:0.2}#mermaid-svg-uQSoC8VC6LqJYOBo .sectionTitle0{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .sectionTitle1{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .sectionTitle2{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .sectionTitle3{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-uQSoC8VC6LqJYOBo .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .grid path{stroke-width:0}#mermaid-svg-uQSoC8VC6LqJYOBo .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-uQSoC8VC6LqJYOBo .task{stroke-width:2}#mermaid-svg-uQSoC8VC6LqJYOBo .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .taskText:not([font-size]){font-size:11px}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-uQSoC8VC6LqJYOBo .task.clickable{cursor:pointer}#mermaid-svg-uQSoC8VC6LqJYOBo .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-uQSoC8VC6LqJYOBo .taskText0,#mermaid-svg-uQSoC8VC6LqJYOBo .taskText1,#mermaid-svg-uQSoC8VC6LqJYOBo .taskText2,#mermaid-svg-uQSoC8VC6LqJYOBo .taskText3{fill:#fff}#mermaid-svg-uQSoC8VC6LqJYOBo .task0,#mermaid-svg-uQSoC8VC6LqJYOBo .task1,#mermaid-svg-uQSoC8VC6LqJYOBo .task2,#mermaid-svg-uQSoC8VC6LqJYOBo .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutside0,#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutside2{fill:#000}#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutside1,#mermaid-svg-uQSoC8VC6LqJYOBo .taskTextOutside3{fill:#000}#mermaid-svg-uQSoC8VC6LqJYOBo .active0,#mermaid-svg-uQSoC8VC6LqJYOBo .active1,#mermaid-svg-uQSoC8VC6LqJYOBo .active2,#mermaid-svg-uQSoC8VC6LqJYOBo .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-uQSoC8VC6LqJYOBo .activeText0,#mermaid-svg-uQSoC8VC6LqJYOBo .activeText1,#mermaid-svg-uQSoC8VC6LqJYOBo .activeText2,#mermaid-svg-uQSoC8VC6LqJYOBo .activeText3{fill:#000 !important}#mermaid-svg-uQSoC8VC6LqJYOBo .done0,#mermaid-svg-uQSoC8VC6LqJYOBo .done1,#mermaid-svg-uQSoC8VC6LqJYOBo .done2,#mermaid-svg-uQSoC8VC6LqJYOBo .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-uQSoC8VC6LqJYOBo .doneText0,#mermaid-svg-uQSoC8VC6LqJYOBo .doneText1,#mermaid-svg-uQSoC8VC6LqJYOBo .doneText2,#mermaid-svg-uQSoC8VC6LqJYOBo .doneText3{fill:#000 !important}#mermaid-svg-uQSoC8VC6LqJYOBo .crit0,#mermaid-svg-uQSoC8VC6LqJYOBo .crit1,#mermaid-svg-uQSoC8VC6LqJYOBo .crit2,#mermaid-svg-uQSoC8VC6LqJYOBo .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-uQSoC8VC6LqJYOBo .activeCrit0,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCrit1,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCrit2,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-uQSoC8VC6LqJYOBo .doneCrit0,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCrit1,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCrit2,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-uQSoC8VC6LqJYOBo .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-uQSoC8VC6LqJYOBo .milestoneText{font-style:italic}#mermaid-svg-uQSoC8VC6LqJYOBo .doneCritText0,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCritText1,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCritText2,#mermaid-svg-uQSoC8VC6LqJYOBo .doneCritText3{fill:#000 !important}#mermaid-svg-uQSoC8VC6LqJYOBo .activeCritText0,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCritText1,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCritText2,#mermaid-svg-uQSoC8VC6LqJYOBo .activeCritText3{fill:#000 !important}#mermaid-svg-uQSoC8VC6LqJYOBo .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-uQSoC8VC6LqJYOBo g.classGroup text .title{font-weight:bolder}#mermaid-svg-uQSoC8VC6LqJYOBo g.clickable{cursor:pointer}#mermaid-svg-uQSoC8VC6LqJYOBo g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-uQSoC8VC6LqJYOBo g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-uQSoC8VC6LqJYOBo .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-uQSoC8VC6LqJYOBo .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-uQSoC8VC6LqJYOBo .dashed-line{stroke-dasharray:3}#mermaid-svg-uQSoC8VC6LqJYOBo #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo .commit-id,#mermaid-svg-uQSoC8VC6LqJYOBo .commit-msg,#mermaid-svg-uQSoC8VC6LqJYOBo .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-uQSoC8VC6LqJYOBo g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-uQSoC8VC6LqJYOBo g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-uQSoC8VC6LqJYOBo g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-uQSoC8VC6LqJYOBo .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-uQSoC8VC6LqJYOBo .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-uQSoC8VC6LqJYOBo .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-uQSoC8VC6LqJYOBo .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-uQSoC8VC6LqJYOBo .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-uQSoC8VC6LqJYOBo .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-uQSoC8VC6LqJYOBo .edgeLabel text{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-uQSoC8VC6LqJYOBo .node circle.state-start{fill:black;stroke:black}#mermaid-svg-uQSoC8VC6LqJYOBo .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-uQSoC8VC6LqJYOBo #statediagram-barbEnd{fill:#9370db}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-state .divider{stroke:#9370db}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-uQSoC8VC6LqJYOBo .note-edge{stroke-dasharray:5}#mermaid-svg-uQSoC8VC6LqJYOBo .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-uQSoC8VC6LqJYOBo .error-icon{fill:#522}#mermaid-svg-uQSoC8VC6LqJYOBo .error-text{fill:#522;stroke:#522}#mermaid-svg-uQSoC8VC6LqJYOBo .edge-thickness-normal{stroke-width:2px}#mermaid-svg-uQSoC8VC6LqJYOBo .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-uQSoC8VC6LqJYOBo .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-uQSoC8VC6LqJYOBo .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-uQSoC8VC6LqJYOBo .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-uQSoC8VC6LqJYOBo .marker{fill:#333}#mermaid-svg-uQSoC8VC6LqJYOBo .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;} #mermaid-svg-uQSoC8VC6LqJYOBo {color: rgba(0, 0, 0, 0.75);font: ;}

推理Densepose得到IUV坐标
匹配当前点位IUV坐标并直接得到位置索引
用位置索引在原图中画出点位

其中SMPL人体XYZ坐标点充当中间变量,转换得到人体的IUV坐标后就不需用到了。

三、目前实现左眼位置代码

总体代码可以参考densepose的notebook示例,以及一个densepose的IUV坐标转换XYZ进行贴图的notebook示例。

1、下载SMPL人体模型:

2、安装依赖:

pip install chumpy
pip install tqdm

3、具体代码

首先加载SMPL模型,并绘制具体人体模型:

# 导入包
import pickle
import numpy as np
import matplotlib.pyplot as pltfrom tqdm import tqdm
from PIL import Image
from mpl_toolkits.mplot3d import axes3d, Axes3D # Now read the smpl model.
with open('./models/basicmodel_m_lbs_10_207_0_v1.1.0.pkl', 'rb') as f:data = pickle.load(f, encoding='iso-8859-1')Vertices = data['v_template']  ##  Loaded vertices of size (6890, 3)X,Y,Z = [Vertices[:,0], Vertices[:,1],Vertices[:,2]]fig = plt.figure(figsize=[150,30])ax = fig.add_subplot(141, projection='3d')
ax.scatter(Z, X, Y, s=0.02, c='k')
smpl_view_set_axis_full_body(ax)ax = fig.add_subplot(142, projection='3d')
ax.scatter(Z,X,Y,s=0.02,c='k')
smpl_view_set_axis_full_body(ax,45)ax = fig.add_subplot(143, projection='3d')
ax.scatter(Z,X,Y,s=0.02,c='k')
smpl_view_set_axis_full_body(ax,90)ax = fig.add_subplot(144, projection='3d')
ax.scatter(Z,X,Y, s=1, c='k')
smpl_view_set_axis_full_body(ax,0)plt.show()

然后画出每几个连续点位然后区分人体区域:头部,胸部,腰部,左臂,右臂,左腿,右腿。目前左眼的部分点位区域为:2778~2800。

def plot_points(begin, end, b, e, body=False, face=True):Z_ft, X_ft, Y_ft = Z[begin:end], X[begin:end], Y[begin:end]fig = plt.figure(figsize=[40,10])if body:ax = fig.add_subplot(141, projection='3d')ax.scatter(Z_ft, X_ft, Y_ft, s=0.02, c='k')ax.scatter(Z_ft[b:e], X_ft[b:e], Y_ft[b:e], s=15, c='r')smpl_view_set_axis_full_body(ax)plt.show()if face:ax = fig.add_subplot(144, projection='3d')ax.scatter(Z_ft, X_ft, Y_ft, s=1, c='k')ax.scatter(Z_ft[b:e], X_ft[b:e], Y_ft[b:e], s=15, c='r')smpl_view_set_axis_face(ax,0)plt.show()# 画出左眼点位图
plot_points(0, -1, 2778, 2800, False, True)     # 得到左眼位置的XYZ坐标范围
Z_ft, X_ft, Y_ft = Z[0:6800], X[0:6800], Y[0:6800]
Z_part, X_part, Y_part = Z_ft[2780:2800], X_ft[2780:2800], Y_ft[2780:2800]Z_leye = []
X_leye = []
Y_leye = []
for i in range(len(Z_ft)):if Z_ft[i] >= min(Z_part) and Z_ft[i] <= max(Z_part) and X_ft[i] >= min(X_part) and X_ft[i] <= max(X_part) and Y_ft[i] >= min(Y_part) and Y_ft[i] <= max(Y_part):Z_leye.append(Z_ft[i])X_leye.append(X_ft[i])Y_leye.append(Y_ft[i])

定义densepose的IUV坐标转换为XYZ的代码:

import numpy as np
import copy
import cv2
from scipy.io  import loadmat
import scipy.spatial.distance
import os class DensePoseMethods:def __init__(self):#ALP_UV = loadmat( './UV_Processed.mat'  ) # Use your own pathself.FaceIndices = np.array( ALP_UV['All_FaceIndices']).squeeze()self.FacesDensePose = ALP_UV['All_Faces']-1self.U_norm = ALP_UV['All_U_norm'].squeeze()self.V_norm = ALP_UV['All_V_norm'].squeeze()self.All_vertices =  ALP_UV['All_vertices'][0]def barycentric_coordinates_fast(self, P0, P1, P2, P):# This is a merge of barycentric_coordinates_exists & barycentric_coordinates.# Inputs are (n, 3) shaped.u = P1 - P0   #u is (n,3)v = P2 - P0   #v is (n,3)w = P.T - P0    #w is (n,3)#vCrossW = np.cross(v, w) #result is (n,3)vCrossU = np.cross(v, u) #result is (n,3)A = np.einsum('nd,nd->n', vCrossW, vCrossU) # vector-wise dot product. Result shape is (n,)#uCrossW = np.cross(u, w)uCrossV = - vCrossUB = np.einsum('nd,nd->n', uCrossW, uCrossV)#sq_denoms = np.einsum('nd,nd->n', uCrossV, uCrossV) #result shape is  (n,)sq_rs = np.einsum('nd,nd->n', vCrossW, vCrossW)sq_ts = np.einsum('nd,nd->n', uCrossW, uCrossW)rs = np.sqrt(sq_rs / sq_denoms)  #result shape is  (n,)ts = np.sqrt(sq_ts / sq_denoms)#results = [None] * P0.shape[0]for i in range(len(results)):if not (A[i] < 0 or B[i] < 0):if ((rs[i] <= 1) and (ts[i] <= 1) and (rs[i] + ts[i] <= 1)):results[i] = (1 - (rs[i] + ts[i]) , rs[i], ts[i])return resultsdef IUV2FBC_fast( self, I_point , U_point, V_point):P = np.array([ U_point , V_point , 0 ])FaceIndicesNow  = np.where( self.FaceIndices == I_point )FacesNow = self.FacesDensePose[FaceIndicesNow]#P_0 = np.vstack( (self.U_norm[FacesNow][:,0], self.V_norm[FacesNow][:,0], np.zeros(self.U_norm[FacesNow][:,0].shape))).transpose()P_1 = np.vstack( (self.U_norm[FacesNow][:,1], self.V_norm[FacesNow][:,1], np.zeros(self.U_norm[FacesNow][:,1].shape))).transpose()P_2 = np.vstack( (self.U_norm[FacesNow][:,2], self.V_norm[FacesNow][:,2], np.zeros(self.U_norm[FacesNow][:,2].shape))).transpose()#bcs = self.barycentric_coordinates_fast(P_0, P_1, P_2, P)for i, bc in enumerate(bcs):if bc is not None:bc1,bc2,bc3 = bcreturn(FaceIndicesNow[0][i],bc1,bc2,bc3)## If the found UV is not inside any faces, select the vertex that is closest!#D1 = scipy.spatial.distance.cdist( np.array( [U_point,V_point])[np.newaxis,:] , P_0[:,0:2]).squeeze()D2 = scipy.spatial.distance.cdist( np.array( [U_point,V_point])[np.newaxis,:] , P_1[:,0:2]).squeeze()D3 = scipy.spatial.distance.cdist( np.array( [U_point,V_point])[np.newaxis,:] , P_2[:,0:2]).squeeze()#minD1 = D1.min()minD2 = D2.min()minD3 = D3.min()#if((minD1< minD2) & (minD1< minD3)):return(  FaceIndicesNow[0][np.argmin(D1)] , 1.,0.,0. )elif((minD2< minD1) & (minD2< minD3)):return(  FaceIndicesNow[0][np.argmin(D2)] , 0.,1.,0. )else:return(  FaceIndicesNow[0][np.argmin(D3)] , 0.,0.,1. )def FBC2PointOnSurface( self, FaceIndex, bc1,bc2,bc3,Vertices ):##Vert_indices = self.All_vertices[self.FacesDensePose[FaceIndex]]-1##p = Vertices[Vert_indices[0],:] * bc1 +  \Vertices[Vert_indices[1],:] * bc2 +  \Vertices[Vert_indices[2],:] * bc3 ##return(p)

读取照片face1.png的IUV保存结果,并将IUV坐标转换为XYZ坐标并将在左眼位置的IUV坐标都保存下来。

iuv_arr = np.load('./saved/iuv_gao1.npy')
print('iuv_arr.shape: ', iuv_arr.shape)
INDS = iuv_arr[0,:,:]
pick_idx = 1   # PICK PERSON INDEX!C = np.where(INDS >= pick_idx)iuv0 = iuv_arr[0,:,:]
iuv1 = iuv_arr[1,:,:]
iuv2 = iuv_arr[2,:,:]
IUV = np.concatenate((iuv0[:,:,np.newaxis], iuv1[:,:,np.newaxis], iuv2[:,:,np.newaxis]), axis=2)
print('IUV shape:', IUV.shape)print('num pts on picked person:', C[0].shape)
IUV_pick = IUV[C[0], C[1], :]  # boolean indexing
IUV_pick = IUV_pick.astype(np.float)
IUV_pick[:, 1:3] = IUV_pick[:, 1:3] / 255.0
collected_x = np.zeros(C[0].shape)
collected_y = np.zeros(C[0].shape)
collected_z = np.zeros(C[0].shape)# 开始将IUV坐标转换为XYZ坐标,并将对应位置的IUV坐标保存下来为iuv_list。
DP = DensePoseMethods()
pbar = tqdm(total=IUV_pick.shape[0])iuv_list = []
for i in range(IUV_pick.shape[0]):pbar.update(1) # Use tqdm to visualize the converting process# Convert IUV to FBC (faceIndex and barycentric coordinates.)FaceIndex,bc1,bc2,bc3 = DP.IUV2FBC_fast(IUV_pick[i, 0], IUV_pick[i, 1], IUV_pick[i, 2])# Use FBC to get 3D coordinates on the surface.p = DP.FBC2PointOnSurface( FaceIndex, bc1,bc2,bc3,Vertices )#collected_x[i] = p[0]collected_y[i] = p[1]collected_z[i] = p[2]if p[0] >= min(X_leye) and p[0] <= max(X_leye) and p[1] >= min(Y_leye) and p[1] <= max(Y_leye) and p[2] >= min(Z_leye) and p[2] <= max(Z_leye):save_iuv = [IUV_pick[i, 0], IUV_pick[i, 1], IUV_pick[i, 2]]iuv_list.append(save_iuv)pbar.close()
print('IUV to PointOnSurface done')# 得到iuv单独的范围list
print(len(iuv_list))
i_leye_list = []
u_leye_list = []
v_leye_list = []
for cur_iuv_arr in iuv_list:i_leye_list.append(cur_iuv_arr[0])u_leye_list.append(cur_iuv_arr[1])v_leye_list.append(cur_iuv_arr[2])

在原图中画出左眼区域:

img = cv2.imread('./saved/face1.png')
bbox_xywh = [4.8355975, 0., 462.35657, 667.8104]  # densepose推理得到的人体区域
x, y, w, h = int(bbox_xywh[0]), int(bbox_xywh[1]), int(bbox_xywh[2]), int(bbox_xywh[3])
crop_img = img[y:y+h, x:x+w]   # 人体区域图像
i_face1 = iuv_arr[0,:,:]
u_face1 = iuv_arr[1,:,:]
v_face1 = iuv_arr[2,:,:]
U = u_face1.astype(float) / 255.0
V = v_face1.astype(float) / 255.0# 显示cv2格式的图
def show_pic_hor(pic_list):nums = len(pic_list)plt_nums = np.ceil(np.sqrt(nums))for i in range(nums):plt.subplot(1, nums, i + 1)if pic_list[i].ndim == 3:try:cur_pic_rgb = cv2.cvtColor(pic_list[i], cv2.COLOR_BGR2RGB)except:cur_pic_rgb = pic_list[i]plt.imshow(cur_pic_rgb)elif pic_list[i].ndim == 2:plt.imshow(pic_list[i], 'gray')plt.show()# 画左眼的函数
def plot_left_eye(crop_img, iuv_list, i_face1, U, V):img_cut = crop_img.copy()k = 0for i in range(img_cut.shape[0]):for j in range(img_cut.shape[1]):if i_face1[i,j] == iuv_list[k][0] and U[i,j] == iuv_list[k][1] and V[i,j] == iuv_list[k][2]:cv2.circle(img_cut, (j,i), 1, (0,0,255), 0)k += 1if k == len(iuv_list):return img_cutreturn img_cutimg_cut = plot_left_eye(crop_img, iuv_list, i_face1, U, V)
show_pic_hor([img_cut])

参考项目:
(1)Densepose:https://github.com/facebookresearch/DensePose/blob/main/notebooks/DensePose-COCO-on-SMPL.ipynb
(2)Detectron2:https://github.com/facebookresearch/detectron2
(2)Densepose IUV-XYZ:https://github.com/linjunyu/Detectron2-Densepose-IUV2XYZ

densepose与SMPL之IUV坐标转XYZ坐标相关推荐

  1. 经纬度坐标转化为XYZ坐标的理解

    前言 经纬度坐标和XYZ笛卡尔坐标的转换常常应用在有关全景图的研究方面,在看了几篇提案和论文后才理解了坐标的转换方法 正文 通过一张图来说明 按照我们直观的理解,会认为φ角是蓝色实线和y轴的夹角,θ角 ...

  2. python画三维坐标图像_用python检索xyz坐标并绘制三维图形

    我有一组xyz坐标,我正试图用它来绘制一个三维图形.我的文本文件每行有3个值,每个值用"制表符"间距分隔.在 我的代码如下:xv = [] yv = [] zv = [] fig6 ...

  3. threejs-经纬度转换成xyz坐标的方法

    用threejs做3D应用时,很经常会接触到球状物体,比如说地球,要定义球上的一点,用经纬度是常用的办法.现在,我们要在北京这个地方标一个点,北京的坐标为--北纬39.9",东经116. 3 ...

  4. arcgis根据经纬度xyz坐标点生成等高线

    arcgis根据经纬度xyz坐标点生成等高线 1.Excel to table 2.display X Y Data 3.Create TIN 4.生成DEM数据. 5.生成等高线. 有些小伙伴会说, ...

  5. 三维模型(X,Y,Z)坐标,UV坐标

    1.什么是UV? 对于三维模型,有两个最重要的坐标系统,一是顶点的位置(X,Y,Z)坐标,另一个就是UV坐标.什么是UV?简单的说,就是贴图影射到模型表面的依据. 完整的说,其实应该是UVW(因为XY ...

  6. 火星坐标、百度坐标、WGS84坐标转换代码(JS、python版)

    火星坐标.百度坐标.WGS84坐标转换代码(JS.python版) 一.JS版本源码 github:https://github.com/wandergis/coordTransform /*** C ...

  7. 一种近似方法将场地坐标转为像素坐标

    一种近似方法将场地坐标转为像素坐标 先上代码: for (int i = 0;i < WIDTH;i++){for (int j = 0;j < HEIGHT;j++){nNewi = i ...

  8. 火星坐标、百度坐标、WGS-84坐标相互转换及墨卡托投影坐标转经纬度JavaScript版...

    转自:https://www.cnblogs.com/fwc1994/p/5884115.html 火星坐标.百度坐标.WGS-84坐标相互转换及墨卡托投影坐标转经纬度JavaScript版 火星坐标 ...

  9. 【SeeMusic】视频编辑 ( 视频 X 坐标 | 视频 Y 坐标 | 视频旋转 | 视频扭曲 )

    SeeMusic 系列文章目录 [SeeMusic]下载安装并注册 SeeMusic 软件 [SeeMusic]创建 SeeMusic 工程并编辑相关内容 ( 创建工程 | 导入 MIDI 文件 | ...

最新文章

  1. VINS-mono详细解读与实现
  2. 推荐原创Python号主:猪哥
  3. java中的可检查和不检查_检查Java测试中发生了什么
  4. CSS实现半透明div层的方法
  5. Windows系统进程介绍
  6. 华山论“件”:Kafka、RabbitMQ、RocketMQ技能大比拼
  7. jmeter单线程读取csv_jmeter中如何使用csv文件并读取数据
  8. linux fcntl函数,Linux C 学习之 - fcntl 函数
  9. 世界所有国家国际域名英文缩写总结(转)
  10. 云架构师进阶攻略(3)
  11. python海龟交易策略_python 海龟交易法则 股票回测-双均线规则(一)
  12. Python操作wifi进行数据传输
  13. php简易留言板功能,PHP实现简单留言板功能的方法
  14. 修改idea的启动参数,让你的idea健步如飞
  15. html 保存 mysql file_前端HTML5几种存储方式的总结
  16. 电商数据分析--常见的数据采集工具及方法
  17. Windows Server 2016 基本设置
  18. 【设计题】想实现一个对页面某个节点的拖曳?如何做?(使用原生JS)
  19. 产品思维训练 | 滴滴顺风车新规:女性晚8点被“宵禁”,是保护还是歧视?
  20. 量子通信基础知识简介(一)

热门文章

  1. 亚太数字经济发展联盟 助力民营企业进入数字经济新时代
  2. 数据结构各结构特点(数组、链表、栈、队列、树)
  3. maven打包报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2.RELEASE:repa
  4. 快速找到外贸客户的9种方法(建议收藏)
  5. 常用的表格正则验证 + 省份选择 JS JQ
  6. 室内设计——海市蜃楼售楼部室内设计(包含预览图jpg和.psd文件)
  7. Python程序员看见一个好看的手机壁纸网站,开撸!
  8. maven将第三方依赖包添加到pom文件
  9. 搭建一个属于自己的博客平台
  10. 朴树 vs. Lunar少女组,ET选的人你究竟爱谁?