Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 24th, 2011  |  syntax: C  |  size: 3.75 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. --- uvccapture-0.5/Makefile     2011-04-17 20:26:22.000000000 +1000
  2. +++ uvccapture-0.5.1/Makefile   2011-09-24 22:28:52.000000000 +1000
  3. @@ -1,7 +1,7 @@
  4.  CC=gcc
  5.  CPP=g++
  6.  APP_BINARY=uvccapture
  7. -VERSION = 0.4
  8. +VERSION = 0.5.1
  9.  PREFIX=/usr/local/bin
  10.  
  11.  WARNINGS = -Wall
  12.  
  13. diff -u uvccapture-0.5/uvccapture.c uvccapture-0.5.1/uvccapture.c
  14. --- uvccapture-0.5/uvccapture.c 2011-04-22 18:19:57.000000000 +1000
  15. +++ uvccapture-0.5.1/uvccapture.c       2011-09-23 22:25:19.000000000 +1000
  16. @@ -58,6 +58,8 @@
  17.    fprintf (stderr, "-o<filename>\tOutput filename(default: snap.jpg)\n");
  18.    fprintf (stderr, "-d<device>\tV4L2 Device(default: /dev/video0)\n");
  19.    fprintf (stderr,
  20. +          "-b\t\tRun in the background\n");
  21. +  fprintf (stderr,
  22.            "-x<width>\tImage Width(must be supported by device)\n");
  23.    fprintf (stderr,
  24.            "-y<height>\tImage Height(must be supported by device)\n");
  25. @@ -73,11 +75,13 @@
  26.    fprintf (stderr, "-m\t\tToggles capture mode to YUYV capture\n");
  27.    fprintf (stderr,
  28.            "-D<integer>\tPre-delay before capture\n");
  29. /*  fprintf (stderr, "Camera Settings:\n");
  30. +  fprintf (stderr,
  31. +          "-W\t\tConstantly capture images during the pre-delay loop\n");
  32. +  fprintf (stderr, "Camera Settings:\n");
  33.    fprintf (stderr, "-B<integer>\tBrightness\n");
  34.    fprintf (stderr, "-C<integer>\tContrast\n");
  35.    fprintf (stderr, "-S<integer>\tSaturation\n");
  36.    fprintf (stderr, "-G<integer>\tGain\n");*/
  37.    exit (8);
  38.  }
  39.  
  40. @@ -299,6 +303,8 @@
  41.    unsigned char* imageWithDHT = NULL;
  42.    int imageWithDHTSize = 0;
  43.    int preDelay = 0;
  44. +  boolean backGround = FALSE;
  45. +  boolean preDelayCapture = FALSE;
  46.  
  47.    (void) signal (SIGINT, sigcatch);
  48.    (void) signal (SIGQUIT, sigcatch);
  49. @@ -325,6 +331,10 @@
  50.        snprintf(outputfile, MAXFILENAMELENGTH, "%s", &argv[1][2]);
  51.        break;
  52.  
  53. +    case 'b':
  54. +      backGround = TRUE;
  55. +      break;
  56. +
  57.      case 'd':
  58.        videodevice = &argv[1][2];
  59.        break;
  60. @@ -357,6 +367,10 @@
  61.        post_capture_command_wait = 1;
  62.        break;
  63.  
  64. +    case 'W':
  65. +      preDelayCapture = TRUE;
  66. +      break;
  67. +
  68.      case 'B':
  69.        brightness = atoi (&argv[1][2]);
  70.        break;
  71. @@ -410,6 +424,10 @@
  72.      if (post_capture_command[0])
  73.        fprintf (stderr, "Executing '%s' after each image capture\n",
  74.                post_capture_command[0]);
  75. +    if (backGround)
  76. +      fprintf (stderr, "Will switch to run in the background\n");
  77. +    else
  78. +      fprintf (stderr, "Will not switch to run in the background\n");
  79.    }
  80.    videoIn = (struct vdIn *) calloc (1, sizeof (struct vdIn));
  81.    if (init_videoIn
  82. @@ -456,17 +474,45 @@
  83.    } else if (verbose >= 1) {
  84.      fprintf (stderr, "Camera gain level is %d\n",
  85.              v4l2GetControl (videoIn, V4L2_CID_GAIN));
  86.    }*/
  87.    ref_time = time (NULL);
  88.  
  89. +  if(backGround)
  90. +  {
  91. +    if(verbose > 0)
  92. +      fprintf (stderr, "starting the daemonising process\n");
  93. +
  94. +    verbose = 0;
  95. +    pid_t pid = fork();
  96. +    if(pid < 0)
  97. +    {
  98. +      fprintf (stderr, "Unable to daemonise the process\n");
  99. +      exit(EXIT_FAILURE);
  100. +    }
  101. +    if (pid > 0)
  102. +      exit(EXIT_SUCCESS);
  103. +
  104. +    close(STDIN_FILENO);
  105. +    close(STDOUT_FILENO);
  106. +    close(STDERR_FILENO);
  107. +  }
  108. +
  109.    while (run) {
  110. -    if( preDelay ) {
  111. -      // allowing camera to adjust exposure
  112. -      uvcGrab(videoIn);
  113. -      videoIn->getPict = 0;
  114. -      if (verbose >= 0)
  115. +    if (preDelay) {
  116. +      if (verbose > 0)
  117.          fprintf (stderr, "Pre-delay: %d, sleeping...\n", preDelay);
  118. -      sleep(preDelay);
  119. +
  120. +      for (int i = 0; i < preDelay; i++) {
  121. +        if(run == 0)
  122. +          break;
  123. +        // allowing camera to adjust exposure
  124. +        if (i == 0 || preDelayCapture) {
  125. +          uvcGrab(videoIn);
  126. +          videoIn->getPict = 0;
  127. +        }
  128. +
  129. +        sleep(1);
  130. +      }
  131.      }
  132.  
  133.      if (verbose >= 2)
clone this paste RAW Paste Data