Ejemplo n.º 1
0
int main()
{
	init_window("Blurcode", 320, 80);
	CvCapture *capture = init_camera();
	IplImage *input = query_frame(capture);
	AppData data;
	CvSize size = cvSize(input->width / 2, input->height / 2);
	create_images(&data, size, 3);
	CvSize debug_size = cvSize(COLUMNS * size.width, ROWS * size.height);
	data.debug = cvCreateImage(debug_size, IPL_DEPTH_8U, 3);
	printf("camera=%dx%d zoomed=%dx%d debug=%dx%d\n",
		   input->width, input->height, size.width, size.height,
		   data.debug->width, data.debug->height);
	int delay = 100;
	while ((cvWaitKey(delay) & 255) != 27) {
		delay = 10;
		input = query_frame(capture);
		cvCvtColor(input, input, CV_BGR2RGB);
		// Horizontal flip (mirror display)
		cvFlip(input, input, 1);
		cvResize(input, data.rgb, CV_INTER_AREA);
		cvSplit(data.rgb, data.red, NULL, NULL, NULL);
		cvSmooth(data.red, data.red, CV_GAUSSIAN, 3, 3, 0, 0);
		decode(&data, ANGLE_OF_VIEW, "input trace", NULL, NULL);
		cvResetImageROI(data.debug);
		cvCvtColor(data.debug, data.debug, CV_RGB2BGR);
		cvShowImage("Blurcode", data.debug);
	}
	cvReleaseCapture(&capture);
	cvReleaseImage(&data.debug);
	release_images(&data);
	cvDestroyWindow("Blurcode");
	return 0;
}
Ejemplo n.º 2
0
    void LineJoinButtonBox::set_size ( SIZE size )
    {
      ::Gtk::ToggleButton* button;

      create_images ( size );

      while ( this->get_children().size() > 0 )
        this->remove ( ** ( this->get_children().begin() ) );

      m_buttons.clear();

      m_tooltips.enable();

      for ( unsigned int i = Cairo::LINE_JOIN_MITER; i <= Cairo::LINE_JOIN_BEVEL; i++ )
      {
        button = ::Gtk::manage ( new ::Gtk::ToggleButton() );
        button->add ( * ( m_images[i] ) );
        m_tooltips.set_tip ( *button, line_join_string[i] );
        button->signal_toggled().connect ( sigc::bind ( sigc::mem_fun ( *this, &LineJoinButtonBox::set_selected ), ( Cairo::LineJoin ) i ) );
        m_buttons.push_back ( button );
        this->pack_start ( *button, ::Gtk::PACK_SHRINK );
      }

      this->set_selected ( m_selected );

      this->show_all();
    }
Ejemplo n.º 3
0
void DialogTest(void)
{
  create_images();

  new_dialog(0, "IupDialog as a main window,\n"
                "all decorations.\n"
                "rastersize+centered.");
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
    SDL_Surface *screen, *background,
                *pause_text, *press_enter_text, *game_over_text;

    const SDL_VideoInfo *video_info;
    Uint32 frame_start, frame_end = 0, game_frame_end = 0;

    systems_init();

    screen = SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE|SDL_DOUBLEBUF);
    video_info = SDL_GetVideoInfo();

    create_images(&press_enter_text, &pause_text, &game_over_text, &background);
    create_entities();

    for(;;) {
        start_frame(&frame_start, &frame_end);

        if(check_SDL_events())
            break;

        draw_background(background, screen, video_info);

        update_entities(game_frame_end  );

        if(is_paused()) {
            if(is_game_over()) {
                draw_centered(screen, video_info, game_over_text);
            } else if(is_started()) {
                draw_centered(screen, video_info, pause_text);
            } else {
                draw_centered(screen, video_info, press_enter_text);
            }
        }

        SDL_Flip(screen);

        finish_frame(&frame_start, &frame_end, &game_frame_end);
    }

    SDL_FreeSurface(background);
    SDL_FreeSurface(pause_text);
    SDL_FreeSurface(press_enter_text);

    systems_shutdown();
    return 0;
}
Ejemplo n.º 5
0
static GwyContainer*
x3p_load(const gchar *filename,
         G_GNUC_UNUSED GwyRunType mode,
         GError **error)
{
    GwyContainer *container = NULL;
    X3PFile x3pfile;
    unzFile zipfile;

    zipfile = gwyminizip_unzOpen(filename);
    if (!zipfile) {
        g_set_error(error, GWY_MODULE_FILE_ERROR,
                    GWY_MODULE_FILE_ERROR_SPECIFIC,
                    _("Minizip cannot open the file as a ZIP file."));
        return NULL;
    }

    gwy_clear(&x3pfile, 1);
    if (!x3p_parse_main(zipfile, &x3pfile, error))
        goto fail;

    if (!x3pfile.ndata) {
        err_NO_DATA(error);
        goto fail;
    }

    if (!x3pfile.datapos) {
        if (!read_binary_data(&x3pfile, zipfile, error))
            goto fail;
    }

    container = gwy_container_new();
    if (x3pfile.feature_type == X3P_FEATURE_SUR)
        create_images(&x3pfile, container);
    else if (x3pfile.feature_type == X3P_FEATURE_PRF)
        create_profiles(&x3pfile, container);
    else {
        g_assert_not_reached();
    }

fail:
    gwy_debug("calling unzClose()");
    unzClose(zipfile);
    x3p_file_free(&x3pfile);

    return container;
}
Ejemplo n.º 6
0
int main(int argc, char* argv[])
{
//  IupOpen(&argc, &argv);
IupOpen(NULL, NULL);
  create_images();

  new_dialog(0, "IupDialog as a main window,\n"
                "all decorations.\n"
                "rastersize+centered.");

  IupMainLoop();

  destroy_images();

  IupClose();

  return 0;
}
Ejemplo n.º 7
0
int main(int argc, char **argv)
{
	if (argc < 2) {
		fprintf(stderr, "usage: picture [options] <infile> ...\n");
		fprintf(stderr, "options:  --test    run test suite\n");
		fprintf(stderr,
				"          --force   don't skip existing output files\n");
		return 1;
	}
	char basename[100];
	char outfilename[200];
	char linkfilename[200];
	bool force = false;
	AppData data;
	null_images(&data);
	for (int n = 1; n < argc; n++) {
		if (strcmp(argv[n], "--test") == 0) {
			printf("Running dir8 test suite...\n");
			dir8_test();
			printf("Running dir16 test suite...\n");
			dir16_test();
			printf("Running checksums test suite...\n");
			checksums_test();
			continue;
		} else if (strcmp(argv[n], "--force") == 0) {
			force = true;
			continue;
		}
		char *infilename = argv[n];
		char *slash = strrchr(infilename, '/');
		if (!slash)
			slash = infilename - 1;
		strcpy(basename, slash + 1);
		char *ext = strrchr(basename, '.');
		if (ext)
			ext[0] = 0;
		strcpy(outfilename, "output/");
		strcat(outfilename, basename);
		strcat(outfilename, ".png");
		strcpy(linkfilename, "digits/");
		strcat(linkfilename, basename);
		if (!force) {
			FILE *fp = fopen(outfilename, "r");
			if (fp) {			// Skip existing output file.
				fclose(fp);
				continue;
			}
		}
		printf("%s => %s\n", infilename, outfilename);
		IplImage *input = cvLoadImage(infilename, CV_LOAD_IMAGE_COLOR);
		if (!input) {
			fprintf(stderr, "could not read %s\n", infilename);
			return 1;
		}
		int zoom = max(1, max(input->width, input->height) / 600);
		if (data.red == NULL ||
			data.red->width != input->width / zoom ||
			data.red->height != input->height / zoom) {
			if (data.red)
				release_images(&data);
			if (data.debug)
				cvReleaseImage(&data.debug);
			CvSize zoom_size =
				cvSize(input->width / zoom, input->height / zoom);
			create_images(&data, zoom_size, 4);
			CvSize debug_size = cvSize(COLUMNS * input->width / zoom,
									   ROWS * input->height / zoom);
			printf("debug_size=%dx%d\n", debug_size.width,
				   debug_size.height);
			data.debug = cvCreateImage(debug_size, IPL_DEPTH_8U, 3);
		}
		// printf("Resizing input from %dx%d to %dx%d...\n",
		// input->width, input->height, data.rgb->width, data.rgb->height);
		cvCvtColor(input, input, CV_BGR2RGB);
		cvResize(input, data.rgb, CV_INTER_AREA);
		cvSplit(data.rgb, data.red, NULL, NULL, NULL);
		// debug_image(&data, data.rgb);
		bool success = decode(&data, ANGLE_OF_VIEW,
							  "gnuplot threshold trace simulator1 simulator3",
							  NULL, NULL);
		if (success) {
			unlink(linkfilename);
			symlink(data.digits, linkfilename);
			printf("digits=%s\n", data.digits);
		}
		cvResetImageROI(data.debug);
		cvCvtColor(data.debug, data.debug, CV_RGB2BGR);
		if (cvSaveImage(outfilename, data.debug) == 0) {
			fprintf(stderr, "could not save output file\n");
			return 1;
		}
	}
	if (data.red)
		release_images(&data);
	if (data.debug)
		cvReleaseImage(&data.debug);
	return 0;
}