void SeedGLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); int viewportWidth = _viewportHeight*(_widgetWidth-_planeWidth)*1.0/_widgetHeight; int anchorWidth = 200, anchorHeight = 200; glViewport(0,0,_widgetWidth-_planeWidth, _widgetHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, viewportWidth, 0, _viewportHeight, -2000, 2000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glPushMatrix(); glTranslatef(_translateX, _translateY, 0); glTranslatef(viewportWidth/2.0, _viewportHeight/2.0, 0); setRotationMatrix(); glColor3f(1, 1, 1); if (_volumeData) { switch (_viewpoint) { case VP_AXIAL: _volumeData->drawAxialSlice(); break; case VP_CORONAL: _volumeData->drawCoronalSlice(); break; case VP_SAGITTAL: _volumeData->drawSagittalSlice(); break; } } drawSeedRegion(); glPopMatrix(); if (_bDrawing) { drawPenTrack(); } glViewport(_widgetWidth-_planeWidth-anchorWidth, 0, anchorWidth, anchorHeight); drawAnchor(); drawImageInfo(); drawPlanes(_widgetWidth-_planeWidth, _planeWidth, _widgetHeight); }
void PlaneSegmenter::update() { if(!rgb_img.rows || !depth_img.rows) return; rgb_mutex.lock(); depth_mutex.lock(); computeNormals(); computeDirections(); planes.clear(); for(unsigned int d=0; d<directions.size();++d) { float px_avg = 0.f; float py_avg = 0.f; float pz_avg = 0.f; float nx_avg = 0.f; float ny_avg = 0.f; float nz_avg = 0.f; for(unsigned int p=0; p<directions.at(d).size(); ++p) { px_avg += directions.at(d).at(p).pos.x/directions.at(d).size(); py_avg += directions.at(d).at(p).pos.y/directions.at(d).size(); pz_avg += directions.at(d).at(p).pos.z/directions.at(d).size(); nx_avg += directions.at(d).at(p).norm.x/directions.at(d).size(); ny_avg += directions.at(d).at(p).norm.y/directions.at(d).size(); nz_avg += directions.at(d).at(p).norm.z/directions.at(d).size(); } planes.push_back(PlaneSegmenter::Point(-d,cv::Point3f(px_avg,py_avg,pz_avg), cv::Point3f(nx_avg,ny_avg,nz_avg))); } // std::cout<<"planes num: "<< planes.size() << std::endl; std::cerr<<"-"; drawPlanes(); // cv::imshow("update depth", depth_img); cv::imshow("update rgb", rgb_img); depth_mutex.unlock(); rgb_mutex.unlock(); cv::waitKey(1); }