/* <userpath1> <userpath2> <matrix> inustroke <bool> */ static int zinustroke(i_ctx_t *i_ctx_p) { /* This is different because of the optional matrix operand. */ os_ptr op = osp; int code = gs_gsave(igs); int spop, npop; gs_matrix mat; gx_device hdev; if (code < 0) return code; if ((spop = upath_stroke(i_ctx_p, &mat, false)) < 0) { gs_grestore(igs); return spop; } if ((npop = in_path(op - spop, i_ctx_p, &hdev)) < 0) { gs_grestore(igs); return npop; } if (npop > 1) /* matrix was supplied */ code = gs_concat(igs, &mat); if (code >= 0) code = gs_stroke(igs); return in_upath_result(i_ctx_p, npop + spop, code); }
static void handle_request(int opcode, int master_sd, char *addr, char *buffer, struct sockaddr_in *client) { char *filename; uint16_t blksize; filename = buffer; if (!in_path(filename)) { send_error(client, TFTP_ERR_ACCES_VIOLATION, (char *)"Requested file outside of working dir.", master_sd); return; } buffer += strnlen(buffer, 508) + 1; if (strncmp(buffer, "octet", 5) != 0) { send_error(client, TFTP_ERR_UNDEFINED, (char *)"Transfer mode not supported.", master_sd); return; } buffer += 6; blksize = get_blksize(buffer, filename); if (opcode == TFTP_RRQ) send_file(filename, client, addr, master_sd, blksize); else receive_file(filename, client, addr, master_sd, blksize); }
int Preprocessor::resize(){ string src = para.res_src; string dst = para.res_dst; string in_pre = para.res_in_pre; string in_post = para.res_in_post; string out_pre = para.res_out_pre; string out_post = para.res_out_post; unsigned int serial_beg = para.serial_beg; unsigned int serial_end = para.serial_end, serial_bits = para.serial_bits, thread_num = para.thread_num; double res_fx = para.res_fx; double res_fy = para.res_fy; string sys_del = para.sys_del; #pragma omp parallel for num_threads(thread_num) for(int serial_num = serial_beg; serial_num <= int(serial_end); ++ serial_num){ string serial_str(""), in_path(""), out_path(""); stringstream str_buffer; cv::Mat in_image, out_image; str_buffer<<setw(serial_bits)<<setfill('0')<<serial_num; str_buffer>>serial_str; str_buffer.clear(); cout<<serial_str<<endl; in_path = src + sys_del + in_pre + serial_str + in_post; //cout<<in_path<<endl; out_path = dst + sys_del + out_pre + serial_str + out_post; //cout<<in_path<<endl; in_image = cv::imread(in_path, CV_LOAD_IMAGE_UNCHANGED); cv::resize(in_image, out_image, cv::Size(), res_fx, res_fy, cv::INTER_LINEAR); cv::imwrite(out_path, out_image); } return 0; }
shared_ptr<temp_dir> testcase::_prepare_dir(judge::pool &pool, const compiler::result &cr) { shared_ptr<temp_dir> dir = pool.create_temp_dir("test_"); path_a in_path(cr.dir->path()); in_path.push(cr.compiler->target_filename().c_str()); path_a out_path(dir->path()); out_path.push(cr.compiler->target_filename().c_str()); file_copy(in_path, out_path); return dir; }
/* Do the work of the non-user-path insideness operators. */ static int in_test(i_ctx_t *i_ctx_p, int (*paintproc)(gs_state *)) { os_ptr op = osp; gx_device hdev; int npop = in_path(op, i_ctx_p, &hdev); int code; if (npop < 0) return npop; code = (*paintproc)(igs); return in_path_result(i_ctx_p, npop, code); }
void get_paths(t_node node) { int i,j; //printf ("*"); if (is_promising(node)) { //printf ("<is promising> " ); if (is_tour(node)) { count_tours++; //printf ("<is a tour> " ); node->level = node->level+1; // dr. delcher, i completed the path. node->path[node->level] = node->path[1]; get_best_path(node); // keep track of the best path // for (i = 1 ; i <= node->level; i++) { printf ("%d ",node->path[i]); } printf (" \n"); } else // for each child of n { for (i = 2; i <= d ; i ++ ) { if (!in_path(i,node)) { t_node child; child=give_birth(node); child->bound = get_bound(node) ; // child->level = node->level+1 ; child=give_path(node,child); child->path[child->level] = i; // add this node to the path for (j=1;j<=( child->level );j++) { //printf ("%d ",child->path[j]); } // //printf ("\n"); //printf ("\n"); //printf ("**"); if (is_promising(child)) { // printf ("IN "); get_paths(child); // printf ("OUT "); } } } } } }
void search(struct data_t data, int row, int col, char *word, struct rc_t *path) { if (!*word) { for (struct rc_t *p = path; p != NULL; p = p->next) { data.grid[p->row][p->col] |= 0x80; } } else if (0 <= row && row < data.gridlen && 0 <= col && col < strlen(data.grid[row]) && !in_path(path, row, col) && (*word == (data.grid[row][col] & 0x7f) || *word == '?')) { for (int r = -1; r <= 1; ++r) { for (int c = -1; c <= 1; ++c) { struct rc_t new_path = { row, col, path }; search(data, row+r, col+c, word+1, &new_path); } } } }
/* with a user path. */ static int in_upath(i_ctx_t *i_ctx_p, gx_device * phdev) { os_ptr op = osp; int code = gs_gsave(igs); int npop; if (code < 0) return code; if ((code = upath_append(op, i_ctx_p, false)) < 0 || (code = npop = in_path(op - 1, i_ctx_p, phdev)) < 0 ) { gs_grestore(igs); return code; } return npop + 1; }
bool fillArchiveNameVector(std::vector<std::string>& pArchiveNames) { if (!hasInputPathParam) getGamePath(); printf("\nGame path: %s\n", input_path); char path[512]; string in_path(input_path); std::vector<std::string> locales, searchLocales; searchLocales.push_back("enGB"); searchLocales.push_back("enUS"); searchLocales.push_back("deDE"); searchLocales.push_back("esES"); searchLocales.push_back("frFR"); searchLocales.push_back("koKR"); searchLocales.push_back("zhCN"); searchLocales.push_back("zhTW"); searchLocales.push_back("enCN"); searchLocales.push_back("enTW"); searchLocales.push_back("esMX"); searchLocales.push_back("ruRU"); for (std::vector<std::string>::iterator i = searchLocales.begin(); i != searchLocales.end(); ++i) { std::string localePath = in_path + *i; // check if locale exists: struct stat status; if (stat(localePath.c_str(), &status)) continue; if ((status.st_mode & S_IFDIR) == 0) continue; printf("Found locale '%s'\n", i->c_str()); locales.push_back(*i); } printf("\n"); // open locale expansion and common files printf("Adding data files from locale directories.\n"); for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i) { pArchiveNames.push_back(in_path + *i + "/locale-" + *i + ".MPQ"); pArchiveNames.push_back(in_path + *i + "/expansion-locale-" + *i + ".MPQ"); } // open expansion and common files pArchiveNames.push_back(input_path + string("common.MPQ")); pArchiveNames.push_back(input_path + string("expansion.MPQ")); // now, scan for the patch levels in the core dir printf("Scanning patch levels from data directory.\n"); sprintf(path, "%spatch", input_path); if (!scan_patches(path, pArchiveNames)) return(false); // now, scan for the patch levels in locale dirs printf("Scanning patch levels from locale directories.\n"); bool foundOne = false; for (std::vector<std::string>::iterator i = locales.begin(); i != locales.end(); ++i) { printf("Locale: %s\n", i->c_str()); sprintf(path, "%s%s/patch-%s", input_path, i->c_str(), i->c_str()); if (scan_patches(path, pArchiveNames)) foundOne = true; } printf("\n"); if (!foundOne) { printf("no locale found\n"); return false; } return true; }
int in_path(struct rc_t *path, int row, int col) { return path==NULL ? 0 : path->row == row && path->col == col ? 1 : in_path(path->next, row, col); }
//* // Get Covariance Matrix of L0 feature int main(int argc, char** argv) { std::string in_path("UW_new_dict"); //std::string in_path("BB_new_dict"); int KK = 128; int T = 10; pcl::console::parse_argument(argc, argv, "--K", KK); pcl::console::parse_argument(argc, argv, "--t", T); std::ostringstream ss; ss << KK; { cv::Mat depth_xyz_center, depth_xyz_range; readMat(in_path+"/depth_xyz_center.cvmat", depth_xyz_center); readMat(in_path+"/depth_xyz_range.cvmat", depth_xyz_range); std::cerr << depth_xyz_center.rows << std::endl; depth_xyz_range = depth_xyz_range.mul(depth_xyz_range); WKmeans depth_clusterer; depth_clusterer.AddData(depth_xyz_center, depth_xyz_range); cv::Mat refined_depth_xyz_center; depth_clusterer.W_Cluster(refined_depth_xyz_center, KK, T); saveMat(in_path+"/refined_depth_xyz_center_"+ss.str()+".cvmat", refined_depth_xyz_center); } { cv::Mat depth_lab_center, depth_lab_range; readMat(in_path+"/depth_lab_center.cvmat", depth_lab_center); readMat(in_path+"/depth_lab_range.cvmat", depth_lab_range); std::cerr << depth_lab_center.rows << std::endl; depth_lab_range = depth_lab_range.mul(depth_lab_range); WKmeans depth_clusterer; depth_clusterer.AddData(depth_lab_center, depth_lab_range); cv::Mat refined_depth_lab_center; depth_clusterer.W_Cluster(refined_depth_lab_center, KK, T); saveMat(in_path+"/refined_depth_lab_center_"+ss.str()+".cvmat", refined_depth_lab_center); } { cv::Mat color_xyz_center, color_xyz_range; readMat(in_path+"/color_xyz_center.cvmat", color_xyz_center); readMat(in_path+"/color_xyz_range.cvmat", color_xyz_range); std::cerr << color_xyz_center.rows << std::endl; color_xyz_range = color_xyz_range.mul(color_xyz_range); WKmeans color_clusterer; color_clusterer.AddData(color_xyz_center, color_xyz_range); cv::Mat refined_color_xyz_center; color_clusterer.W_Cluster(refined_color_xyz_center, KK, T); saveMat(in_path+"/refined_color_xyz_center_"+ss.str()+".cvmat", refined_color_xyz_center); } { cv::Mat color_lab_center, color_lab_range; readMat(in_path+"/color_lab_center.cvmat", color_lab_center); readMat(in_path+"/color_lab_range.cvmat", color_lab_range); std::cerr << color_lab_center.rows << std::endl; color_lab_range = color_lab_range.mul(color_lab_range); WKmeans color_clusterer; color_clusterer.AddData(color_lab_center, color_lab_range); cv::Mat refined_color_lab_center; color_clusterer.W_Cluster(refined_color_lab_center, KK, T); saveMat(in_path+"/refined_color_lab_center_"+ss.str()+".cvmat", refined_color_lab_center); } return 1; }
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; }