Exemple #1
0
int videodev_start (void) {
	printf("videocapture: init\n");
	dev_name = "/dev/video0";
	generate_YCbCr_to_RGB_lookup();
	open_device();
	if (video_ok == 0) {
		return 0;
	}
	init_device();
	if (video_ok == 0) {
		return 0;
	}
	buffer_sdl = (uint8_t*)malloc(WIDTH*HEIGHT*3);
	data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, WIDTH, HEIGHT, 24, WIDTH * 3, mask32(0), mask32(1), mask32(2), 0);
	start_capturing();
	return 0;
}
int main(int argc, char **argv)
{
  dev_name = "/dev/video0";

   setpriority(PRIO_PROCESS, 0, -10);
  generate_YCbCr_to_RGB_lookup();

  open_device();
  init_device();

  atexit(SDL_Quit);
  if (SDL_Init(SDL_INIT_VIDEO) < 0)
      return 1;

  SDL_WM_SetCaption(filter_names[filter_no], NULL);


  buffer_sdl = (uint8_t*)malloc(WIDTH*HEIGHT*3);

  SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_HWSURFACE);

  data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, WIDTH, HEIGHT,
                                     24, WIDTH * 3,
                                     mask32(0), mask32(1), mask32(2), 0);

  SDL_SetEventFilter(sdl_filter);

  start_capturing();
  mainloop();
  stop_capturing();

  uninit_device();
  close_device();

  SDL_FreeSurface(data_sf);
  free(buffer_sdl);

  exit(EXIT_SUCCESS);

  return 0;
}
int main(int argc, char **argv)
{
    dev_name = "/dev/video0";

    for (;;)
    {
        int index;
        int c;

        c = getopt_long(argc, argv, short_options, long_options, &index);

        if (-1 == c)
            break;

        switch (c)
        {
        case 0:                /* getopt_long() flag */
            break;

        case 'd':
            dev_name = optarg;
            break;

        case 'h':
            usage(stdout, argc, argv);
            exit(EXIT_SUCCESS);

        case 'm':
            io = IO_METHOD_MMAP;
            break;

        case 'r':
            io = IO_METHOD_READ;
            break;

        case 'u':
            io = IO_METHOD_USERPTR;
            break;

        case 'x':
            WIDTH = atoi(optarg);
            break;

        case 'y':
            HEIGHT = atoi(optarg);
            break;

        default:
            usage(stderr, argc, argv);
            exit(EXIT_FAILURE);
        }
    }

    generate_YCbCr_to_RGB_lookup();

    open_device();
    init_device();

    atexit(SDL_Quit);
    if (SDL_Init(SDL_INIT_VIDEO) < 0)
        return 1;

    SDL_WM_SetCaption("SDL Video viewer", NULL);

    buffer_sdl = (uint8_t*)malloc(WIDTH*HEIGHT*3);

    SDL_SetVideoMode(WIDTH, HEIGHT, 24, SDL_HWSURFACE);

    data_sf = SDL_CreateRGBSurfaceFrom(buffer_sdl, WIDTH, HEIGHT,
                                       24, WIDTH * 3,
                                       mask32(0), mask32(1), mask32(2), 0);

    SDL_SetEventFilter(sdl_filter);

    start_capturing();
    mainloop();
    stop_capturing();

    uninit_device();
    close_device();

    SDL_FreeSurface(data_sf);
    free(buffer_sdl);

    exit(EXIT_SUCCESS);

    return 0;
}