/* * Create imapfilter's home directory. */ void create_homedir(void) { int n; char *h, *i; h = getenv("HOME"); i = getenv("IMAPFILTER_HOME"); if (i == NULL) n = strlen(h ? h : "") + strlen(h ? "/" : "") + strlen(".imapfilter"); else n = strlen(i); if (env.pathmax != -1 && n > env.pathmax) fatal(ERROR_PATHNAME, "pathname limit %ld exceeded: %d\n", env.pathmax, n); env.home = (char *)xmalloc((n + 1) * sizeof(char)); if (i == NULL) snprintf(env.home, n + 1, "%s%s%s", h ? h : "", h ? "/" : "", ".imapfilter"); else snprintf(env.home, n + 1, "%s", i); if (!exists_dir(env.home)) { if (mkdir(env.home, S_IRUSR | S_IWUSR | S_IXUSR)) error("could not create directory %s; %s\n", env.home, strerror(errno)); } }
int main(int argc, char** argv) { std::string seg_path("data/ln_joint/"); std::string gt_path("final_joint_gt/"); std::string out_path(""); //pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer()); //viewer->initCameraParameters(); //viewer->addCoordinateSystem(0.1); //viewer->setCameraPosition(0, 0, 0.1, 0, 0, 1, 0, -1, 0); int c1 = 0, c2 = -1; pcl::console::parse_argument(argc, argv, "--gt", gt_path); pcl::console::parse_argument(argc, argv, "--eg", seg_path); pcl::console::parse_argument(argc, argv, "--o", out_path); pcl::console::parse_argument(argc, argv, "--c1", c1); pcl::console::parse_argument(argc, argv, "--c2", c2); if( out_path.empty() == false && exists_dir(out_path) == false ) boost::filesystem::create_directories(out_path); float acc = 0; int acc_count = 0; for(int i = c1 ; i <= c2 ; i++ ) { std::stringstream ss; ss << i; std::string pcd_file(seg_path + "seg_" + ss.str() + ".pcd"); std::string link_pose_file(gt_path + "link_gt_" + ss.str() + ".csv"); std::string node_pose_file(gt_path + "node_gt_" + ss.str() + ".csv"); std::cerr << "Loading... " << pcd_file << std::endl; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>()); pcl::io::loadPCDFile(pcd_file, *cloud); if( cloud->empty() == true ) break; acc_count++; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// std::vector<poseT> all_poses; readCSV(link_pose_file, "link", all_poses); readCSV(node_pose_file, "node", all_poses); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //read meshes ModelT link_mesh = LoadMesh(link_mesh_name, "link"); ModelT node_mesh = LoadMesh(node_mesh_name, "node"); std::vector<ModelT> mesh_set; mesh_set.push_back(link_mesh); mesh_set.push_back(node_mesh); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //viewer->removePointCloud("cloud"); //viewer->addPointCloud(cloud, "cloud"); //viewer->spin(); float cur_acc = segAcc(mesh_set, all_poses, cloud); std::cerr << "P: " << cur_acc << std::endl; acc += cur_acc; if( out_path.empty() == false ) pcl::io::savePCDFile(out_path + "seg_" + ss.str() + ".pcd", *cloud, true); //viewer->removePointCloud("cloud"); //viewer->addPointCloud(cloud, "cloud"); //viewer->spin(); /* cv::Mat gt_label, seg_label, uv; int gt_num = MeshOn2D(mesh_set, all_poses, gt_label); int seg_num = segProj(cloud, seg_label, uv); int true_pos = overlapGT(gt_label, seg_label, uv); std::cerr << "P: " << (true_pos+0.0) / seg_num << std::endl; acc += (true_pos+0.0) / seg_num; //* showLabel(gt_label, "GT"); showLabel(seg_label, "Seg"); //*/ } std::cerr << "Seg-Acc: " << acc / acc_count << std::endl; /*************************************************************************************************************************/ return 0; }
int main(int argc, char** argv) { std::string path("/home/chi/arco/test/build/temp/"); std::string filename("temp_0_0"); pcl::console::parse_argument(argc, argv, "--f", filename); pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>()); pcl::io::loadPCDFile(path+filename+".pcd", *cloud); int w = cloud->width; int h = cloud->height; cv::Mat img = cv::Mat::zeros(h, w, CV_8UC3); for( size_t i = 0 ; i < cloud->size() ; i++ ) { int r = i / w; int c = i % w; uint32_t rgb_tmp = cloud->at(i).rgba; img.at<uchar>(r, c*3+2) = (rgb_tmp >> 16) & 0x0000ff; img.at<uchar>(r, c*3+1) = (rgb_tmp >> 8) & 0x0000ff; img.at<uchar>(r, c*3+0) = (rgb_tmp) & 0x0000ff; } cv::imwrite(filename+".png", img); return 0; std::string in_path("/home/chi/JHUIT/raw/"); std::string out_path("img_tmp/"); std::string inst_name("driller_kel_0"); std::string seq_id("1");; float elev = ELEV; int max_frames = 200; pcl::console::parse_argument(argc, argv, "--p", in_path); pcl::console::parse_argument(argc, argv, "--s", seq_id); pcl::console::parse_argument(argc, argv, "--i", inst_name); pcl::console::parse_argument(argc, argv, "--elev", elev); pcl::console::parse_argument(argc, argv, "--max", max_frames); std::cerr << "Loading-"<< inst_name << std::endl; if( exists_dir(out_path) == false ) boost::filesystem::create_directories(out_path); std::ifstream fp; fp.open((in_path+"/PlaneCoef_"+ seq_id + ".txt").c_str(), std::ios::in); if( fp.is_open() == false ) { std::cerr << "Failed to open: " << in_path+"/PlaneCoef_"+ seq_id + ".txt" << std::endl; exit(0); } pcl::ModelCoefficients::Ptr planeCoef(new pcl::ModelCoefficients()); planeCoef->values.resize(4); fp >> planeCoef->values[0] >> planeCoef->values[1] >> planeCoef->values[2] >> planeCoef->values[3]; fp.close(); std::vector< pcl::PointCloud<PointT>::Ptr > cloud_set; std::vector< KEYSET > keypt_set; std::vector< cv::Mat > keydescr_set; for( size_t j = 0 ; j < max_frames ; j++ ) { std::stringstream ss; ss << j; if( j % 3 != 0 ) continue; std::string filename(in_path + inst_name + "/" + inst_name + "_" + seq_id + "_" + ss.str() + ".pcd"); if( exists_test(filename) == false ) continue; pcl::PointCloud<PointT>::Ptr cloud(new pcl::PointCloud<PointT>()); pcl::io::loadPCDFile(filename, *cloud); int w = cloud->width; int h = cloud->height; //std::cerr << w << " " << h << " " << cloud->size() << std::endl; cv::Mat rgb = cv::Mat::zeros(h, w, CV_8UC3); cv::Mat gray = cv::Mat::zeros(h, w, CV_8UC1); for(size_t i = 0 ; i < cloud->size() ; i++ ) { int r_idx = i / w; int c_idx = i % w; uint32_t rgb_tmp = cloud->at(i).rgba; rgb.at<uchar>(r_idx, c_idx*3+2) = (rgb_tmp >> 16) & 0x0000ff; rgb.at<uchar>(r_idx, c_idx*3+1) = (rgb_tmp >> 8) & 0x0000ff; rgb.at<uchar>(r_idx, c_idx*3+0) = (rgb_tmp) & 0x0000ff; } cv::cvtColor(rgb,gray,CV_BGR2GRAY); //cv::imshow("GRAY", rgb); //cv::waitKey(); cv::SiftFeatureDetector *sift_det = new cv::SiftFeatureDetector( 0, // nFeatures 4, // nOctaveLayers 0.04, // contrastThreshold 10, //edgeThreshold 1.6 //sigma ); cv::SiftDescriptorExtractor * sift_ext = new cv::SiftDescriptorExtractor(); KEYSET keypoints; cv::Mat descriptors; sift_det->detect(gray, keypoints); sift_ext->compute(gray, keypoints, descriptors); printf("%d sift keypoints are found.\n", (int)keypoints.size()); keypt_set.push_back(keypoints); keydescr_set.push_back(descriptors); cloud = cropCloud(cloud, planeCoef, 0.114); cloud_set.push_back(cloud); //cv::imshow("GRAY", in_rgb); //cv::waitKey(); //cv::imwrite(out_path + ss.str() + ".jpg", in_rgb); //viewer->addPointCloud(cloud, "cloud"); //viewer->spin(); //if( show_keys ) /* { cv::Mat out_image; cv::drawKeypoints(gray, keypoints, out_image); cv::imshow("keypoints", out_image); cv::waitKey(); } //*/ } int total = cloud_set.size(); /* std::vector< pcl::PointCloud<PointT>::Ptr > first_half, second_half; std::vector< KEYSET > first_keypt, second_keypt; std::vector< cv::Mat > first_keydescr, second_keydescr; first_half.insert(first_half.end(), cloud_set.begin(), cloud_set.begin()+total/2); first_keypt.insert(first_keypt.end(), keypt_set.begin(), keypt_set.begin()+total/2); first_keydescr.insert(first_keydescr.end(), keydescr_set.begin(), keydescr_set.begin()+total/2); second_half.push_back(cloud_set[0]); second_keypt.push_back(keypt_set[0]); second_keydescr.push_back(keydescr_set[0]); for( int i = 1 ; i < total/2 ; i++ ) { second_half.push_back(cloud_set[total-i]); second_keypt.push_back(keypt_set[total-i]); second_keydescr.push_back(keydescr_set[total-i]); } pcl::PointCloud<PointT>::Ptr first_model = Meshing(first_half, first_keypt, first_keydescr); pcl::PointCloud<PointT>::Ptr second_model = Meshing(second_half, second_keypt, second_keydescr); pcl::PointCloud<PointT>::Ptr full_model (new pcl::PointCloud<PointT>()); full_model->insert(full_model->end(), first_model->begin(), first_model->end()); full_model->insert(full_model->end(), second_model->begin(), second_model->end()); */ pcl::PointCloud<PointT>::Ptr full_model = Meshing(cloud_set, keypt_set, keydescr_set); full_model = cropCloud(full_model, planeCoef, elev); pcl::io::savePCDFile("temp_full.pcd", *full_model); pcl::PLYWriter ply_writer; ply_writer.write("temp_full.ply", *full_model, true); /* pcl::PointCloud<PointT>::Ptr full_model(new pcl::PointCloud<PointT>()); pcl::io::loadPCDFile("temp_full.pcd", *full_model); std::vector<int> idx_ff; pcl::removeNaNFromPointCloud(*full_model, *full_model, idx_ff); pcl::PointCloud<NormalT>::Ptr full_model_normals (new pcl::PointCloud<NormalT>()); computeNormals(full_model, full_model_normals, 0.02); AdjustCloudNormal(full_model, full_model_normals); pcl::visualization::PCLVisualizer::Ptr viewer(new pcl::visualization::PCLVisualizer()); viewer->initCameraParameters(); viewer->addCoordinateSystem(0.1); viewer->setCameraPosition(0, 0, 0.1, 0, 0, 1, 0, -1, 0); //viewer->addPointCloud(full_model, "full_model"); //viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 1.0, 1.0, "full_model"); //viewer->addPointCloudNormals<PointT, NormalT> (full_model, full_model_normals, 5, 0.01, "normals"); //viewer->spin(); pcl::PointCloud<pcl::PointNormal>::Ptr joint_model (new pcl::PointCloud<pcl::PointNormal>()); pcl::copyPointCloud(*full_model, *joint_model); pcl::copyPointCloud(*full_model_normals, *joint_model); //std::cerr << full_model->size() << " " << full_model_normals->size() << " " << joint_model->size() << std::endl; //pcl::concatenateFields (*full_model, *full_model_normals, *joint_model); pcl::search::KdTree<pcl::PointNormal>::Ptr tree2(new pcl::search::KdTree<pcl::PointNormal>); tree2->setInputCloud (joint_model); pcl::GreedyProjectionTriangulation<pcl::PointNormal> gp3; pcl::PolygonMesh model_mesh; gp3.setMu(2.5); gp3.setMaximumNearestNeighbors(100); gp3.setSearchRadius(0.03); gp3.setMaximumSurfaceAngle(M_PI/4); // 45 degrees gp3.setMinimumAngle(M_PI/18); // 10 degrees gp3.setMaximumAngle(2*M_PI/3); // 120 degrees gp3.setNormalConsistency(false); // Get result gp3.setInputCloud (joint_model); gp3.setSearchMethod (tree2); gp3.reconstruct (model_mesh); //viewer->addPointCloud(full_model, "model"); viewer->addPolygonMesh(model_mesh, "full_model_mesh"); viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 1.0, 0.55, 0.05, "full_model_mesh"); viewer->spin(); */ return 0; }
/* * IMAPFilter: an IMAP mail filtering utility. */ int main(int argc, char *argv[]) { int c; char *cafile = NULL, *capath = NULL; setlocale(LC_CTYPE, ""); opts.verbose = 0; opts.interactive = 0; opts.log = NULL; opts.config = NULL; opts.oneline = NULL; opts.debug = NULL; opts.truststore = NULL; if (exists_dir("/etc/ssl/certs")) opts.truststore = "/etc/ssl/certs"; else if (exists_file("/etc/ssl/cert.pem")) opts.truststore = "/etc/ssl/cert.pem"; env.home = NULL; env.pathmax = -1; while ((c = getopt(argc, argv, "Vc:d:e:il:t:v?")) != -1) { switch (c) { case 'V': version(); /* NOTREACHED */ break; case 'c': opts.config = optarg; break; case 'd': opts.debug = optarg; break; case 'e': opts.oneline = optarg; break; case 'i': opts.interactive = 1; break; case 'l': opts.log = optarg; break; case 't': opts.truststore = optarg; break; case 'v': opts.verbose = 1; break; case '?': default: usage(); /* NOTREACHED */ break; } } get_pathmax(); open_debug(); create_homedir(); catch_signals(); open_log(); if (opts.config == NULL) opts.config = get_filepath("config.lua"); buffer_init(&ibuf, INPUT_BUF); buffer_init(&obuf, OUTPUT_BUF); buffer_init(&nbuf, NAMESPACE_BUF); buffer_init(&cbuf, CONVERSION_BUF); regexp_compile(responses); SSL_library_init(); SSL_load_error_strings(); ssl3ctx = SSL_CTX_new(SSLv3_client_method()); ssl23ctx = SSL_CTX_new(SSLv23_client_method()); tls1ctx = SSL_CTX_new(TLSv1_client_method()); #if OPENSSL_VERSION_NUMBER >= 0x01000100fL tls11ctx = SSL_CTX_new(TLSv1_1_client_method()); tls12ctx = SSL_CTX_new(TLSv1_2_client_method()); #endif if (exists_dir(opts.truststore)) capath = opts.truststore; else if (exists_file(opts.truststore)) cafile = opts.truststore; SSL_CTX_load_verify_locations(ssl3ctx, cafile, capath); SSL_CTX_load_verify_locations(ssl23ctx, cafile, capath); SSL_CTX_load_verify_locations(tls1ctx, cafile, capath); #if OPENSSL_VERSION_NUMBER >= 0x01000100fL SSL_CTX_load_verify_locations(tls11ctx, cafile, capath); SSL_CTX_load_verify_locations(tls12ctx, cafile, capath); #endif start_lua(); #if LUA_VERSION_NUM < 502 { list *l; session *s; l = sessions; while (l != NULL) { s = l->data; l = l->next; request_logout(s); } } #endif stop_lua(); SSL_CTX_free(ssl3ctx); SSL_CTX_free(ssl23ctx); SSL_CTX_free(tls1ctx); #if OPENSSL_VERSION_NUMBER >= 0x01000100fL SSL_CTX_free(tls11ctx); SSL_CTX_free(tls12ctx); #endif ERR_free_strings(); regexp_free(responses); buffer_free(&ibuf); buffer_free(&obuf); buffer_free(&nbuf); buffer_free(&cbuf); xfree(env.home); close_log(); close_debug(); exit(0); }