template <typename PointInT, typename PointNT, typename PointOutT> void pcl::GSS3DEstimation<PointInT, PointNT, PointOutT>::computeFeature (PointCloudOut &output) { calculateGeometricScaleSpace (); computeDerivatives (); extractEdges (); }
int main(int argc, char* argv[]) { if( argc != 3 ) { fprintf(stderr, "Usage: %s panorender.png photo.jpg\n", argv[0]); return 1; } IplImage* pano = cvLoadImage( argv[1], CV_LOAD_IMAGE_COLOR); assert(pano); IplImage* img = cvLoadImage( argv[2], CV_LOAD_IMAGE_COLOR); assert(img); CvMat* pano_edges; CvMat* img_edges; { pano_edges = extractEdges(pano, PANO); cvThreshold( pano_edges, pano_edges, 200.0, 0, CV_THRESH_TOZERO ); // the non-edge areas of the panorama should be dont-care areas. I implement // this by // x -> dilate ? x : mean; // another way to state the same thing: // !dilate -> mask // cvSet(mean) #define DILATE_R 9 #define EDGE_MINVAL 180 IplConvKernel* kernel = cvCreateStructuringElementEx( 2*DILATE_R + 1, 2*DILATE_R + 1, DILATE_R, DILATE_R, CV_SHAPE_ELLIPSE, NULL); CvMat* dilated = cvCreateMat( pano->height, pano->width, CV_8UC1 ); cvDilate(pano_edges, dilated, kernel, 1); CvScalar avg = cvAvg(pano_edges, dilated); cvCmpS(dilated, EDGE_MINVAL, dilated, CV_CMP_LT); cvSet( pano_edges, avg, dilated ); cvReleaseMat(&dilated); cvReleaseStructuringElement(&kernel); } { img_edges = extractEdges(img, PHOTO); cvSmooth(img_edges, img_edges, CV_GAUSSIAN, 13, 13, 0.0, 0.0); } CvPoint offset = alignImages( img_edges, pano_edges ); printf("offset: x,y: %d %d\n", offset.x, offset.y ); cvReleaseMat ( &pano_edges ); cvReleaseMat ( &img_edges ); cvReleaseImage( &pano ); cvReleaseImage( &img ); return 0; }
Polyhedron_3 EdgeCorrector::run() { DEBUG_START; std::map<int, int> halfedgesMap; std::vector<SimpleEdge_3> edges = getEdges(initialP, halfedgesMap); associateEdges(edges, SData); printAssociatedEdges(initialP, edges, halfedgesMap); std::vector<SimpleEdge_3> mainEdges = extractEdges(edges); std::cout << "Number of extracted edges: " << mainEdges.size() << std::endl; if (mainEdges.size() == 0) { DEBUG_END; return initialP; } printColouredExtractedPolyhedron(initialP, mainEdges); std::vector<Vector_3> u, U, points; std::vector<double> h, H; std::map<int, int> map; FixedTopology *FT = buildTopology(initialP, mainEdges, u, U, points, h, H, map); IpoptTopologicalCorrector *FTNLP = new IpoptTopologicalCorrector( u, h, U, H, points, FT); FTNLP->enableModeZfixed(); IpoptApplication *app = IpoptApplicationFactory(); /* Intialize the IpoptApplication and process the options */ if (app->Initialize() != Solve_Succeeded) { MAIN_PRINT("*** Error during initialization!"); return initialP; } app->Options()->SetStringValue("linear_solver", "ma57"); if (getenv("DERIVATIVE_TEST_FIRST")) app->Options()->SetStringValue("derivative_test", "first-order"); else if (getenv("DERIVATIVE_TEST_SECOND")) app->Options()->SetStringValue("derivative_test", "second-order"); else if (getenv("DERIVATIVE_TEST_ONLY_SECOND")) app->Options()->SetStringValue("derivative_test", "only-second-order"); if (getenv("HESSIAN_APPROX")) app->Options()->SetStringValue("hessian_approximation", "limited-memory"); /* Ask Ipopt to solve the problem */ auto status = app->OptimizeTNLP(FTNLP); if (status != Solve_Succeeded && status != Solved_To_Acceptable_Level) { MAIN_PRINT("** The problem FAILED!"); DEBUG_END; return initialP; } MAIN_PRINT("*** The problem solved!"); globalPCLDumper(PCL_DUMPER_LEVEL_DEBUG, "INSIDE_FT_NLP-initial.ply") << initialP; Polyhedron_3 correctedP = obtainPolyhedron(initialP, map, FTNLP); globalPCLDumper(PCL_DUMPER_LEVEL_DEBUG, "INSIDE_FT_NLP-from-planes.ply") << correctedP; delete FTNLP; DEBUG_END; return correctedP; }