1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| void viewThread(pangolin::OpenGlMatrix &Twc) { pangolin::CreateWindowAndBind("Main", 1024, 768); glEnable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 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);
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() ) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClearColor(1.0f,1.0f,1.0f,1.0f); d_cam.Activate(s_cam); 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();
glPointSize(2); glBegin(GL_POINTS); glColor3f(0.0, 0.0, 0.0); 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();
pangolin::FinishFrame(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); } }
int main(int argc, char* argv[]) { pangolin::OpenGlMatrix Twc, Twr; Twc.SetIdentity(); std::thread viewThd(viewThread, Twc);
while(1) { ...<省略> updatePointsMutex.lock(); allPPatchesRender = findMatch->m_pos.m_ppatches; updatePointsMutex.unlock(); ...<省略> }
viewThd.join();
releasePMVS(); return 0; }
|