资源简介
基于相移法的三维重建,在linux环境下,结合opencv和opengl,实现三维重构!
代码片段和文件信息
/********************************************************
*
*功能:基于OpenGL的可视化的实现
*日期:2016-09-08
*作者:杨磊
*
*********************************************************/
#include “glapp.h“
#include
#include
#include
#include “ThreePhase.h“
using namespace std;
ThreePhase f3;
int step=4;
int psize=2;
int mscale = 200;
int zrange = 45;
int zscale = 151;
int zskew = 179;
int znoise = 7200;
int zblur = 16;
float rotY = 0.0f;
float posX = -1.0f;
float posY = 0.0f;
float posZ = -8.0f;
int inputWidth;
int inputHeight;
//
// phase wrap / unwrap
// also blurring the mask helps a lot
//
void cbnoise(int v void *)
{
int64 t0 = cv::getTickCount();
float thresh = float(v)/10000.0f;
f3.phaseWrap(thresh);
int64 t1 = cv::getTickCount();
f3.phaseUnwrap();
int64 t2 = cv::getTickCount();
if ( zblur )
cv::blur(f3.maskf3.maskcv::Size(zblurzblur));
int64 t3 = cv::getTickCount();
double freq= cv::getTickFrequency();
cerr << (t1-t0)/freq << “\t“<< (t2-t1)/freq << “\t“<< (t3-t2)/freq << “\t“<< (t3-t0)/freq << endl;
}
//
// filter outliers in z dir
//
float meanz()
{
int scale=zscale-mscale;
int skew=zskew-mscale;
if ( skew == 0)
skew = 1;
float m = 0;
float n = 0;
for ( int r=0; r {
float planephase = 0.5f + float(r - (inputHeight / 2)) / skew;
for ( int c=0; c {
if ( ! f3.mask.at(rc) )
{
float z = (f3.phase0.at(rc) - planephase) * scale;
m += z;
n += 1.0f;
}
}
}
return (m) / n;
}
void drawpoints()
{
int scale=zscale-mscale;
int skew=zskew-mscale;
if ( skew == 0)
skew = 1;
float mz = meanz();
glPointSize(float(psize));
glBegin(GL_POINTS);
for ( int r=0; r {
float planephase = 0.5 + float(r - (inputHeight / 2)) / skew;
float z0 = 0;
float range = zrange;
for ( int c=0; c {
if ( ! f3.mask.at(rc) )
{
float z = (f3.phase0.at(rc) - planephase) * scale;
if ( abs(z-mz) {
uchar col = (f3.phases[0].at(rc)+f3.phases[1].at(rc)+f3.phases[2].at(rc)) / 3;
glColor3ub(colcolcol);
glVertex3f( 0.01f*c -0.01f*r 0.01f*z );
z0 = z;
}
}
}
}
glEnd();
}
//
// colored vertices quads no real texture yet
// outliers suck!
//
void drawmesh()
{
int scale=zscale-mscale;
int skew=zskew-mscale;
if ( skew == 0)
skew = 1;
int range = zrange;
float wn=6hn=6;
float mz = meanz();
for ( int r=0; r {
for ( int c=0; c {
if ( f3.mask.at(rc) )
continue;
int px = c;
int py = r;
float planephase = 0.5f + float(py - (inputHeight / 2)) / skew;
float pz0 = (f3.phase0.at(pypx) - planephase) * scale;
float pz = pz0;
if ( abs(pz-mz)>range )
continue;
glBegin(GL_QUADS);
uchar col = f3.mix(pypx);
glColor3ub(colcolcol);
glVertex3f(0.01f*
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-09-18 08:58 ThreePhase\
目录 0 2016-09-18 08:53 ThreePhase\Debug\
文件 111104 2016-09-18 08:59 ThreePhase\Debug\ThreePhase.exe
文件 752884 2016-09-18 08:59 ThreePhase\Debug\ThreePhase.ilk
文件 1854464 2016-09-18 08:59 ThreePhase\Debug\ThreePhase.pdb
目录 0 2016-09-18 08:53 ThreePhase\Debug\data\
目录 0 2016-09-18 08:53 ThreePhase\Debug\data\a\
文件 93271 2013-09-12 15:22 ThreePhase\Debug\data\a\phase1.png
文件 93068 2013-09-12 15:22 ThreePhase\Debug\data\a\phase2.png
文件 86643 2013-09-12 15:22 ThreePhase\Debug\data\a\phase3.png
文件 4860662 2016-09-08 14:52 ThreePhase\Results.bmp
目录 0 2016-09-18 08:53 ThreePhase\ThreePhase\
目录 0 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\
文件 60894 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\CL.read.1.tlog
文件 2608 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\CL.write.1.tlog
文件 406 2016-09-08 11:13 ThreePhase\ThreePhase\Debug\ThreePhase.exe.em
文件 472 2016-09-08 11:13 ThreePhase\ThreePhase\Debug\ThreePhase.exe.em
文件 381 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\ThreePhase.exe.intermediate.manifest
文件 70 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\ThreePhase.lastbuildstate
文件 2672 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\ThreePhase.log
文件 297135 2016-09-08 15:13 ThreePhase\ThreePhase\Debug\ThreePhase.obj
文件 713 2016-09-08 12:55 ThreePhase\ThreePhase\Debug\ThreePhase.vcxprojResolveAssemblyReference.cache
文件 0 2016-09-08 11:13 ThreePhase\ThreePhase\Debug\ThreePhase.write.1.tlog
文件 210 2016-09-08 11:13 ThreePhase\ThreePhase\Debug\ThreePhase_manifest.rc
文件 1850 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\cl.command.1.tlog
文件 206281 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\glapp_p.obj
文件 2 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\li
文件 2 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\li
文件 2 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\li
文件 2 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\li
文件 2 2016-09-18 08:59 ThreePhase\ThreePhase\Debug\li
............此处省略48个文件信息
评论
共有 条评论