int main(int argc, char *argv[]) { int i; glutInit(&argc, argv); if (argc > 1) { load_img(argv[1]); } else { load_img(defaultFile); } glutInitWindowSize(w, h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGB | GLUT_ACCUM); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(key); glutReshapeFunc(reshape); glutCreateMenu(menu); for (i = 0; i < sizeof(filters) / sizeof(filters[0]); i++) { glutAddMenuEntry(filters[i].name, i); } glutAttachMenu(GLUT_RIGHT_BUTTON); init(); glutMainLoop(); return 0; }
main(int argc, char *argv[]) { glutInit(&argc, argv); if (argc > 1) { load_img(argv[1]); } else { load_img(defaultFile); } in0 = black; in1 = img; operation = BRIGHTNESS; glutInitWindowSize(w, h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGB | GLUT_ACCUM | GLUT_DOUBLE); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(key); glutMotionFunc(motion); glutMouseFunc(button); glutReshapeFunc(reshape); glutCreateMenu(menu); glutAddMenuEntry("Change brightness", 0); glutAddMenuEntry("Change contrast", 1); glutAddMenuEntry("Change saturation", 2); glutAttachMenu(GLUT_RIGHT_BUTTON); init(); glutMainLoop(); return 0; }
int main(int argc, char *argv[]) { load_img("../../data/mandrill.rgb"); glutInit(&argc, argv); glutInitWindowSize(w, h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(key); glutMouseFunc(mouse); glutMotionFunc(motion); glutReshapeFunc(reshape); /* A hack to see if the color matrix is supported */ while (glGetError() != GL_NO_ERROR); glMatrixMode(GL_COLOR); if (glGetError() != GL_NO_ERROR) { printf("This demo requires OpenGL 1.2 or the color matrix extension.\n"); exit(0); } glMatrixMode(GL_MODELVIEW); init(); glutMainLoop(); return 0; }
struct Picture load_picture(struct Picture p, char Filename[100]) { p.ID = PictureID++; strncpy(p.filename, Filename, 100); p.picture = load_img(Filename); return p; }
main(int argc, char *argv[]) { const char *fileName0 = defaultFile0, *fileName1 = defaultFile1, *brushName = defaultBrushFile; glutInit(&argc, argv); if (argc > 1) { fileName0 = argv[1]; } if (argc > 2) { fileName1 = argv[2]; } if (argc > 3) { brushName = argv[3]; } if (argc > 4) { show_usage(); exit(1); } printf("Image file 1 is %s\n", fileName0); printf("Image file 2 is %s\n", fileName1); printf("Brush file is %s\n", brushName); img0 = load_img(fileName0, &w0, &h0); img1 = load_img(fileName1, &w1, &h1); brush = load_img(brushName, &wbrush, &hbrush); brush = convert_to_luminance(brush, wbrush, hbrush); #define MAX(a, b) ((a) > (b) ? (a) : (b)) w = MAX(w0, w1); h = MAX(h0, h1); glutInitWindowSize(w, h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(key); glutReshapeFunc(reshape); glutMouseFunc(button); glutMotionFunc(motion); init(); glutMainLoop(); return 0; }
void ogl::texture::init() { if (ogl::context) { std::map<int, vec4> scale; std::string path = "texture/" + name; glGenTextures(1, &object); load_opt(path, scale); load_img(path, scale); load_prm(path); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , dir_weight_("0") , step_(0) , stop_learning_(false) { ui->setupUi(this); connect(ui->learn, SIGNAL(clicked()), SLOT(learning())); connect(ui->load, SIGNAL(clicked()), SLOT(load_img())); connect(ui->open, SIGNAL(clicked()), SLOT(open())); connect(ui->close, SIGNAL(clicked()), SLOT(close())); connect(ui->save, SIGNAL(clicked()), SLOT(save())); ui->textEdit->setReadOnly(true); ui->load->setDisabled(true); connect(this, SIGNAL(ready_result(QString)),SLOT(print_result(QString))); }
static void update_game_info(DRIVER *dr) { static char *shotsdir=DATA_DIRECTORY"/shots"; static char lgname[32]; if (dr) { SDL_FreeSurface(screenshots); screenshots=load_img(shotsdir,dr->name); if (!screenshots) gui_gpix_set_pixmap((GPIX*)game_pix,unavail_shots); else gui_gpix_set_pixmap((GPIX*)game_pix,screenshots); snprintf(lgname,30,"%s",dr->longname); gui_label_change((LABEL*)info_label,lgname); info_label->map(info_label); } else { SDL_FreeSurface(screenshots);screenshots=NULL; gui_gpix_set_pixmap((GPIX*)game_pix,NULL); info_label->unmap(info_label); } }
void Gui::init_picture() const { SDL_Rect pos; int i; int x; int y; std::string const map = m_nibbler.getMap(); std::vector<SDL_Surface*> screens; i = 0; while (i < map.size()) { get_pos(&x, &y, map[i], i); if (x != -42) { pos.y = y; pos.x = x; load_img(map[i], pos, screens); } i++; } }
/* ============================================================ * = Main * ============================================================*/ int main(int argc, char **argv) { puts(">>>>>>>>>>>>>> Moravec Point Feature Detector"); // Define Kernel Size and Moravec Threshold int moravec_kernel_size; int moravec_threshold; // Define raw-image holder img_t raw_src; /* ------------------------------------------------------------ * Load Image and Init Kernel Size and Threshold * ------------------------------------------------------------*/ char *path = "data/u0367panLeft.raw"; int row = 887; int col = 805; int ker_size = 3; int thresh = 30; // Not work now... /* parse_params(argc, argv, &path, &row, &col, &ker_size, &thresh);*/ // So we do it explicitely if (argc == 1) { puts(">> Use Built-in Params."); } else if (argc == 6) { puts(">> Load Params from Console. Single Thresh"); path = argv[1]; row = atoi(argv[2]); col = atoi(argv[3]); ker_size = atoi(argv[4]); thresh = atoi(argv[5]); } else if (argc > 7) { puts(">> Load Params from Console. Multi Thresh"); path = argv[1]; row = atoi(argv[2]); col = atoi(argv[3]); ker_size = atoi(argv[4]); if (atoi(argv[5]) != 0) { // argv[5] is treated as a flag puts("Multi Thresh Usage."); printf(">> %s <raw_img_path> <row> <col> <kernel_size> 0 <threshold1> <threshold2> ...\n", argv[0]); exit (-1); } thresh = atoi(argv[6]); // this case, argv[6] as the threshold } else { // Else? Else Print out Usage and then exit! help(argc, argv); exit (-1); } printout_params(argv[0], path, row, col, ker_size, thresh); puts(">>>>>>>>>>>>>> Load Image & Set Kernel Size, Threshold"); load_img(&raw_src, path, row, col); set_moravec_kernel_size(&moravec_kernel_size, ker_size); set_moravec_threshold(&moravec_threshold, thresh); // check puts(">>>>>>>>>>>>>> Check Params"); printf("## Check:\n##>> r:%d, c:%d; k: %d, t: %d\n", row, col, moravec_kernel_size, moravec_threshold); /* ------------------------------------------------------------ * Define Variables and then Processing * ------------------------------------------------------------*/ // Differences img_t raw_diff_l_r, raw_diff_t_b, raw_diff_tl_br, raw_diff_tr_bl; // Square Sums of Differences img_t raw_sqsum_l_r, raw_sqsum_t_b, raw_sqsum_tl_br, raw_sqsum_tr_bl; // Min of Squares img_t output_sqsum_min; // output: as a mask img_t output_01_mask; puts(">>>>>>>>>>>>>> Differences"); // DIFF diff_left_right(raw_src, &raw_diff_l_r); diff_top_bottom(raw_src, &raw_diff_t_b); diff_topleft_bottomright(raw_src, &raw_diff_tl_br); diff_topright_bottomleft(raw_src, &raw_diff_tr_bl); puts(">>>>>>>>>>>>>> SqSum"); // SQSUM sqsum_left_right(raw_diff_l_r, &raw_sqsum_l_r, moravec_kernel_size); sqsum_top_bottom(raw_diff_t_b, &raw_sqsum_t_b, moravec_kernel_size); sqsum_topleft_bottomright(raw_diff_tl_br, &raw_sqsum_tl_br, moravec_kernel_size); sqsum_topright_bottomleft(raw_diff_tr_bl, &raw_sqsum_tr_bl, moravec_kernel_size); puts(">>>>>>>>>>>>>> Min of Four"); // MIN four2one(&output_sqsum_min, raw_sqsum_l_r, raw_sqsum_t_b, raw_sqsum_tl_br, raw_sqsum_tr_bl); puts(">>>>>>>>>>>>>> Apply Threshold"); apply_threshold(output_sqsum_min, &output_01_mask, moravec_threshold); char outpath[60]; sprintf(outpath, "thrld_%d.%s", moravec_threshold, "raw"); printf(">> Save to file: %s", outpath); save_img(&output_01_mask, outpath); // if there are other thresholds if (atoi(argv[5]) == 0) { for (int t = 7; t < argc; ++t) { set_moravec_threshold(&moravec_threshold, atoi(argv[t])); apply_threshold(output_sqsum_min, &output_01_mask, moravec_threshold); sprintf(outpath, "thrld_%d.%s", moravec_threshold, "raw"); printf(">> Save to file: %s", outpath); save_img(&output_01_mask, outpath); } } return 0; }
main(int argc, char *argv[]) { char *fileName0 = defaultFile0, *fileName1 = defaultFile1, *fileName2 = defaultFile2; glutInit(&argc, argv); if (argc > 1) { fileName0 = fileName1 = argv[1]; } if (argc > 2) { fileName2 = argv[2]; } if (argc > 3) { fileName1 = fileName2; fileName2 = argv[3]; } if (argc > 4) { if (argc == 6 || argc == 7) { key[0] = atof(argv[argc-3]); key[1] = atof(argv[argc-2]); key[2] = atof(argv[argc-1]); } else { show_usage(); exit(1); } } printf("Matte file is %s\n", fileName0); printf("Image file 1 is %s\n", fileName1); printf("Image file 2 is %s\n", fileName2); printf("Key is (%f %f %f)\n", key[0], key[1], key[2]); printf("Transparent boundary is %f\n", lowerfudge); printf("Opaque boundary is %f\n", upperfudge); img0 = load_img(fileName0, &w0, &h0); img1 = load_img(fileName1, &w1, &h1); img2 = load_img(fileName2, &w2, &h2); #define MAX(a, b) ((a) > (b) ? (a) : (b)) w = MAX(MAX(w0, w1), w2); h = MAX(MAX(h0, h1), h2); glutInitWindowSize(2*w, 2*h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGBA | GLUT_ACCUM | GLUT_ALPHA); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(keyPress); glutReshapeFunc(reshape); glutMouseFunc(button); { int lowerFudgeMenu, upperFudgeMenu; lowerFudgeMenu = glutCreateMenu(change_lower_fudge); glutAddMenuEntry("0", 0); glutAddMenuEntry(".1", 20); glutAddMenuEntry(".25", 20); glutAddMenuEntry(".5", 50); glutAddMenuEntry(".75", 75); upperFudgeMenu = glutCreateMenu(change_upper_fudge); glutAddMenuEntry(".25", 20); glutAddMenuEntry(".5", 50); glutAddMenuEntry(".75", 75); glutAddMenuEntry(".9", 90); glutAddMenuEntry("1", 100); glutCreateMenu(0); glutAddSubMenu("Transparent boundary", lowerFudgeMenu); glutAddSubMenu("Opaque boundary", upperFudgeMenu); glutAttachMenu(GLUT_RIGHT_BUTTON); } init(); reshape(w, h); glutMainLoop(); return 0; }
void init_gngeo_gui(void) { // WIDGET *w,*button,*button2,*label; WIDGET *button,*pix; #ifdef __QNXNTO__ char* datadir = "app/native/media"; #else char* datadir = DATA_DIRECTORY; #endif unavail_shots=load_img(datadir,"noshots"); gui_init(304,224,datadir); gui_set_update(update_gngeo_gui); gui_set_resize(screen_resize); gui_set_destroy(gngeo_quit); /* first thing to create, because it contain the key focus list */ desktop=(WIDGET*)gui_frame_create(NULL,0,0,304,224,FRAME_SHADOW_OUT,NULL); //printf("CREATE game\n"); wid_game=init_game_gui(); //printf("CREATE setting\n"); wid_setting=init_setting_gui(); //printf("CREATE control\n"); wid_control=init_control_gui(); /* Main button */ button=(WIDGET*)gui_button_label_create(NULL,2,2,45,15,"Game"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_game; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); button=(WIDGET*)gui_button_label_create(NULL,49,2,45,15,"Setting"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_setting; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); button=(WIDGET*)gui_button_label_create(NULL,96,2,45,15,"Control"); gui_widget_add_keyfocus(desktop,button); button->pdata1=wid_control; GUI_BUTTON(button)->activate=change_panel; gui_container_add(GUI_CONTAINER(desktop),button); /* toggle fullscreen button */ button=(WIDGET*)gui_button_create(NULL,270,3,14,14); gui_widget_add_keyfocus(desktop,button); GUI_BUTTON(button)->activate=toggle_fullscreen; gui_container_add(GUI_CONTAINER(desktop),button); pix_full=load_img_rle(datadir,"fullscreen"); pix_win=load_img_rle(datadir,"window"); gpix_full=(WIDGET*)gui_gpix_create(NULL,1,1,12,12); if (!fullscreen) gui_gpix_set_pixmap((GPIX*)gpix_full,pix_full); else gui_gpix_set_pixmap((GPIX*)gpix_full,pix_win); gui_container_add(GUI_CONTAINER(button),gpix_full); /* quit button */ button=(WIDGET*)gui_button_create(NULL,286,3,14,14); gui_widget_add_keyfocus(desktop,button); GUI_BUTTON(button)->activate=quit_click; gui_container_add(GUI_CONTAINER(desktop),button); pix=(WIDGET*)gui_gpix_create(NULL,1,1,12,12); gui_gpix_set_pixmap((GPIX*)pix,load_img_rle(datadir,"close")); gui_container_add(GUI_CONTAINER(button),pix); desktop->map(desktop); //printf("ADD game\n"); gui_container_add(GUI_CONTAINER(desktop),wid_game); //printf("ADD setting\n"); gui_container_add(GUI_CONTAINER(desktop),wid_setting); //printf("ADD control\n"); gui_container_add(GUI_CONTAINER(desktop),wid_control); wid_game->map(wid_game); wid_setting->unmap(wid_setting); wid_control->unmap(wid_control); wid_current=wid_game; /* do not show progress bar for the moment */ ld_pbar->unmap(ld_pbar); ld_label->unmap(ld_label); //desktop=(WIDGET*)gui_frame_create(NULL,0,0,304,224,SHADOW_ETCHED_IN,"Game:"); }
bool IpolACEUpdater::run( MP mp ) { MP lst_img = mp[ "_children[ 0 ]._children" ]; // La liste des images const int nb_img = lst_img.size(); // Le nombre d'images for(int i = 0; i < nb_img; ++i) { MP img = lst_img[i]; // La i-eme image QString name = img["_name"]; if(img.type() == "ImgItem"){ /// Load ImgItem into a QImage QString name = img[ "_name" ]; QImage tmp_input; load_img(img,tmp_input); /// Save it into a processable file QString tmp_input_name = name + ".tmp.png"; tmp_input.save(tmp_input_name,"PNG"); QString tmp_output_name = "ACE_" + name + ".tmp.png"; std::stringstream commandes; commandes << "../IpolACEPlugin/ServerPlugin/src_ace/ace"; commandes << " -a " << (double) mp["alpha.val"]; int num_weight = mp["weight.num"]; switch(num_weight) { case 0: commandes << " -w 1/r"; break; case 1: commandes << " -w 1"; break; case 2: commandes << " -w G:" << (double) mp["weight.lst"][num_weight]["_sigma.val"]; break; default: add_message( mp, ET_Error, "Invalid weight type" ); return false; } int num_method = mp["method.num"]; MP method = mp["method.lst"][num_method]; switch(num_method) { case 0: commandes << " -m interp:" << (int) method["_level.val"]; break; case 1: { int num_poly = method["_degree.num"]; commandes << " -m poly:" << ((QString) method["_degree.lst"][num_poly]).toStdString(); break; } default: add_message( mp, ET_Error, "Invalid method type" ); return false; } commandes << " \"" << tmp_input_name.toStdString() << "\""; commandes << " \"" << tmp_output_name.toStdString() << "\""; std::string cmd = commandes.str(); int output = std::system(cmd.c_str()); qDebug() << cmd.c_str(); qDebug() << "Returned " << output; if(not output) { /// Retrieve image data into a ImgItem QImage tmp_output(tmp_output_name); MP new_img = MP::new_obj("ImgItem"); new_treeitem(new_img , "ACE_" + name); new_img["img"] = MP::new_obj("Img"); save_img(new_img["img"], tmp_output); /// Add result image to output set mp["_output[0]._children"] << new_img; } else { add_message( mp, ET_Error, "Error while running the application" ); } /// clean temporary files QFile::remove(tmp_input_name); QFile::remove(tmp_output_name); } else { add_message( mp, ET_Error, "Unable to find image file in tree" ); } } add_message( mp, ET_Info, "Ipol LSD -> OK" ); qDebug() << "Ipol LSD just finish"; }
virtual void on_draw() { if(m_gamma.value() != m_old_gamma) { m_gamma_lut.gamma(m_gamma.value()); load_img(0, "spheres"); pixfmt pixf(rbuf_img(0)); pixf.apply_gamma_dir(m_gamma_lut); m_old_gamma = m_gamma.value(); } pixfmt pixf(rbuf_window()); pixfmt_pre pixf_pre(rbuf_window()); renderer_base rb(pixf); renderer_base_pre rb_pre(pixf_pre); renderer_solid r(rb); rb.clear(agg::rgba(1, 1, 1)); if(m_trans_type.cur_item() < 2) { // For the affine parallelogram transformations we // calculate the 4-th (implicit) point of the parallelogram m_quad.xn(3) = m_quad.xn(0) + (m_quad.xn(2) - m_quad.xn(1)); m_quad.yn(3) = m_quad.yn(0) + (m_quad.yn(2) - m_quad.yn(1)); } //-------------------------- // Render the "quad" tool and controls g_rasterizer.add_path(m_quad); r.color(agg::rgba(0, 0.3, 0.5, 0.1)); agg::render_scanlines(g_rasterizer, g_scanline, r); // Prepare the polygon to rasterize. Here we need to fill // the destination (transformed) polygon. g_rasterizer.clip_box(0, 0, width(), height()); g_rasterizer.reset(); int b = 0; g_rasterizer.move_to_d(m_quad.xn(0)-b, m_quad.yn(0)-b); g_rasterizer.line_to_d(m_quad.xn(1)+b, m_quad.yn(1)-b); g_rasterizer.line_to_d(m_quad.xn(2)+b, m_quad.yn(2)+b); g_rasterizer.line_to_d(m_quad.xn(3)-b, m_quad.yn(3)+b); typedef agg::span_allocator<color_type> span_alloc_type; span_alloc_type sa; agg::image_filter_bilinear filter_kernel; agg::image_filter_lut filter(filter_kernel, true); pixfmt pixf_img(rbuf_img(0)); typedef agg::image_accessor_clone<pixfmt> source_type; source_type source(pixf_img); start_timer(); switch(m_trans_type.cur_item()) { case 0: { agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type; interpolator_type interpolator(tr); typedef image_filter_2x2_type<source_type, interpolator_type> span_gen_type; span_gen_type sg(source, interpolator, filter); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); break; } case 1: { agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type; typedef image_resample_affine_type<source_type> span_gen_type; interpolator_type interpolator(tr); span_gen_type sg(source, interpolator, filter); sg.blur(m_blur.value()); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); break; } case 2: { agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); if(tr.is_valid()) { typedef agg::span_interpolator_linear_subdiv<agg::trans_perspective> interpolator_type; interpolator_type interpolator(tr); typedef image_filter_2x2_type<source_type, interpolator_type> span_gen_type; span_gen_type sg(source, interpolator, filter); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); } break; } case 3: { agg::trans_perspective tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); if(tr.is_valid()) { typedef agg::span_interpolator_trans<agg::trans_perspective> interpolator_type; interpolator_type interpolator(tr); typedef image_filter_2x2_type<source_type, interpolator_type> span_gen_type; span_gen_type sg(source, interpolator, filter); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); } break; } case 4: { typedef agg::span_interpolator_persp_lerp<> interpolator_type; typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type; interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); subdiv_adaptor_type subdiv_adaptor(interpolator); if(interpolator.is_valid()) { typedef image_resample_type<source_type, subdiv_adaptor_type> span_gen_type; span_gen_type sg(source, subdiv_adaptor, filter); sg.blur(m_blur.value()); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); } break; } case 5: { typedef agg::span_interpolator_persp_exact<> interpolator_type; typedef agg::span_subdiv_adaptor<interpolator_type> subdiv_adaptor_type; interpolator_type interpolator(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2); subdiv_adaptor_type subdiv_adaptor(interpolator); if(interpolator.is_valid()) { typedef image_resample_type<source_type, subdiv_adaptor_type> span_gen_type; span_gen_type sg(source, subdiv_adaptor, filter); sg.blur(m_blur.value()); agg::render_scanlines_aa(g_rasterizer, g_scanline, rb_pre, sa, sg); } break; } } double tm = elapsed_time(); pixf.apply_gamma_inv(m_gamma_lut); char buf[64]; agg::gsv_text t; t.size(10.0); agg::conv_stroke<agg::gsv_text> pt(t); pt.width(1.5); sprintf(buf, "%3.2f ms", tm); t.start_point(10.0, 70.0); t.text(buf); g_rasterizer.add_path(pt); r.color(agg::rgba(0,0,0)); agg::render_scanlines(g_rasterizer, g_scanline, r); //-------------------------- agg::render_ctrl(g_rasterizer, g_scanline, rb, m_trans_type); agg::render_ctrl(g_rasterizer, g_scanline, rb, m_gamma); agg::render_ctrl(g_rasterizer, g_scanline, rb, m_blur); }
int main(int argc, char *argv[]) { char *fileName0 = defaultFile0, *fileName1 = defaultFile1, *fileName2 = defaultFile2; glutInit(&argc, argv); if (argc > 1) { fileName0 = fileName1 = argv[1]; } if (argc > 2) { fileName2 = argv[2]; } if (argc > 3) { fileName1 = fileName2; fileName2 = argv[3]; } if (argc > 4) { if (argc == 6 || argc == 7) { key[0] = atof(argv[argc - 3]); key[1] = atof(argv[argc - 2]); key[2] = atof(argv[argc - 1]); } else { show_usage(); exit(1); } } printf("Matte file is %s\n", fileName0); printf("Image file 1 is %s\n", fileName1); printf("Image file 2 is %s\n", fileName2); printf("Key is (%f %f %f)\n", key[0], key[1], key[2]); img0 = load_img(fileName0, &w0, &h0); img1 = load_img(fileName1, &w1, &h1); img2 = load_img(fileName2, &w2, &h2); #define MAX(a, b) ((a) > (b) ? (a) : (b)) w = MAX(MAX(w0, w1), w2); h = MAX(MAX(h0, h1), h2); glutInitWindowSize(2 * w, 2 * h); glutInitWindowPosition(0, 0); glutInitDisplayMode(GLUT_RGBA | GLUT_ACCUM | GLUT_ALPHA); glutCreateWindow(argv[0]); glutDisplayFunc(draw); glutKeyboardFunc(keyPress); glutReshapeFunc(reshape); glutMouseFunc(button); /* * A hack to see if the color matrix is supported */ while (glGetError() != GL_NO_ERROR); glMatrixMode(GL_COLOR); if (glGetError() != GL_NO_ERROR) { printf("This demo requires OpenGL 1.2 or the color matrix extension.\n"); exit(0); } glMatrixMode(GL_MODELVIEW); init(); reshape(w, h); glutMainLoop(); return 0; }
bool IpolLSDUpdater::run( MP mp ) { MP lst_img = mp[ "_children[ 0 ]._children" ]; // La liste des images const int nb_img = lst_img.size(); // Le nombre d'images for(int i = 0; i < nb_img; ++i) { MP img = lst_img[i]; // La i-eme image QString name = img["_name"]; if(img.type() == "ImgItem"){ /// Load ImgItem into a QImage QString name = img[ "_name" ]; QImage tmp_input; load_img(img,tmp_input); /// Save it into a processable file QString tmp_input_name = name + ".pgm"; tmp_input.save(tmp_input_name,"PGM"); QString tmp_output_name = "LSD_" + name + ".pgm"; std::stringstream commandes; commandes << "../IpolLSDPlugin/ServerPlugin/src_lsd/lsd"; commandes << " -s " << (double) mp["scale.val"]; commandes << " -c " << (double) mp["sigma_coef.val"]; commandes << " -q " << (double) mp["quant.val"]; commandes << " -a " << (double) mp["ang_th.val"]; commandes << " -e " << (double) mp["log_eps.val"]; commandes << " -d " << (double) mp["density_th.val"]; commandes << " -b " << (int) mp["n_bins.val"]; commandes << " -W " << (double) mp["width.val"]; commandes << " -R \"" << tmp_output_name.toStdString() << "\""; commandes << " \"" << tmp_input_name.toStdString() << "\""; commandes << " results.txt"; /// Unused results file //commandes << " > log.txt"; /// for error management std::string cmd = commandes.str(); int output = std::system(cmd.c_str()); //qDebug() << cmd.c_str(); //qDebug() << "Returned " << output; if(not output) { /// Retrieve image data into a ImgItem QImage tmp_output(tmp_output_name); MP new_img = MP::new_obj("ImgItem"); new_treeitem(new_img , "LSD_" + name); new_img["img"] = MP::new_obj("Img"); save_img(new_img["img"], tmp_output); /// Add result image to output set mp["_output[0]._children"] << new_img; } else { add_message( mp, ET_Error, "Error while running the application" ); } /// clean temporary files QFile::remove(tmp_input_name); QFile::remove(tmp_output_name); QFile::remove("results.txt"); } else { add_message( mp, ET_Error, "Unable to find image file in tree" ); } } add_message( mp, ET_Info, "Ipol LSD -> OK" ); qDebug() << "Ipol LSD just finish"; }