0 结果展示
1 下载编译pangolin的库
https://github.com/stevenlovegrove/Pangolin.git
该库中本身含有libpng, libjpg, libzip
2 当需要调用该库时:
调用时依赖如下:(本项目并未上传所有依赖,部分依赖需要单独下载然后放到thirdparty目录里)
# include
F:\prjs\ORB_SLAM3_Fix\ORB_SLAM3\Thirdparty\Pangolin\include;F:\prjs\ORB_SLAM3_Fix\ORB_SLAM3\Thirdparty\Pangolin\build\src\include;F:\prjs\ORB_SLAM3_Fix\ORB_SLAM3\Thirdparty\Pangolin\build\external\glew\include;F:\BASE_ENV\forOpenMVS\eigen;%(AdditionalIncludeDirectories)
# lib
..\..\..\lib\Release\pangolin.lib;opengl32.lib;glu32.lib;..\..\external\glew\lib\glew.lib;..\..\external\libpng\lib\libpng16_static.lib;..\..\external\zlib\lib\zlibstatic.lib;..\..\external\libjpeg\lib\jpeg.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib
3 动态展示点云的示例:
void viewThread(pangolin::OpenGlMatrix &Twc) {
pangolin::CreateWindowAndBind("Main", 1024, 768);
glEnable(GL_DEPTH_TEST);
// Issue specific OpenGl we might need
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(1024, 768, 500, 500, 512, 389, 0.1, 1000),
pangolin::ModelViewLookAt(50, 50, 50, 0, 0, 0, pangolin::AxisY)
);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
// Add named OpenGL viewport to window and provide 3D Handler
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, pangolin::Attach::Pix(175), 1.0, -1024.0f / 768.0f)
.SetHandler(new pangolin::Handler3D(s_cam));
size_t frame = 0;
while( !pangolin::ShouldQuit() ) {
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(1.0f,1.0f,1.0f,1.0f);
//! Activate Displays and set State Matrices
d_cam.Activate(s_cam);
// draw camera
const float w = 2;
const float h = w*0.75;
const float z = w*0.6;
glPushMatrix();
glMultMatrixd(Twc.m);
glLineWidth(1);
glColor3f(0.0f,1.0f,0.0f);
glBegin(GL_LINES);
glVertex3f(0,0,0);
glVertex3f(w,h,z);
glVertex3f(0,0,0);
glVertex3f(w,-h,z);
glVertex3f(0,0,0);
glVertex3f(-w,-h,z);
glVertex3f(0,0,0);
glVertex3f(-w,h,z);
glVertex3f(w,h,z);
glVertex3f(w,-h,z);
glVertex3f(-w,h,z);
glVertex3f(-w,-h,z);
glVertex3f(-w,h,z);
glVertex3f(w,h,z);
glVertex3f(-w,-h,z);
glVertex3f(w,-h,z);
glEnd();
glPopMatrix();
// draw points
glPointSize(2);
glBegin(GL_POINTS);
glColor3f(0.0, 0.0, 0.0);
// get all points to m_pos.m_ppatches
updatePointsMutex.lock();
for (size_t p = 0; p < (size_t)allPPatchesRender.size(); ++p)
{
auto patch = *allPPatchesRender[p];
glVertex3f(
patch.m_coord[0],
patch.m_coord[1],
patch.m_coord[2]
);
}
updatePointsMutex.unlock();
glEnd();
// Swap frames and Process Events
pangolin::FinishFrame();
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // ms
// std::cout << "frame��" << ++frame << std::endl;
// std::cout << "point nums are: " << findMatch->m_pos.m_ppatches.size() << std::endl;
}
}
int main(int argc, char* argv[])
{
pangolin::OpenGlMatrix Twc, Twr;
Twc.SetIdentity();
std::thread viewThd(viewThread, Twc);
while(1) {
...<省略>
// update render points
updatePointsMutex.lock();
allPPatchesRender = findMatch->m_pos.m_ppatches; // to get the newest points
updatePointsMutex.unlock();
...<省略>
}
viewThd.join();
//writePointCloundPly(prefix);
releasePMVS();
return 0;
}