From: <enl...@li...> - 2002-02-28 19:35:28
|
Enlightenment CVS committal Author : gilbertt Project : misc Module : camE Dir : misc/camE Modified Files: AUTHORS example.camErc webcam.c Log Message: Another fine patch from David H Muir <dh...@li...> Adds the ability to archive thumbnails of the cam image when archiving is enabled. Config options are: archive_thumbnails_create = <int> (0- disable, 1- enable) archive_thumbnails_dir = <string> (dest. directory) archive_thumbnails_width = <int> (width of thumbnails) archive_thumbnails_height = <int> (height of thumbnails) =================================================================== RCS file: /cvsroot/enlightenment/misc/camE/AUTHORS,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- AUTHORS 10 Jul 2001 23:09:04 -0000 1.5 +++ AUTHORS 28 Feb 2002 19:35:24 -0000 1.6 @@ -10,3 +10,9 @@ Greg Gilbert <gr...@tr...> Cropping and scaling options + +David H Muir <dh...@li...> + only archive shots after so many taken + +missen <mi...@mi...> + ftp keepalive =================================================================== RCS file: /cvsroot/enlightenment/misc/camE/example.camErc,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- example.camErc 27 Feb 2002 19:23:38 -0000 1.20 +++ example.camErc 28 Feb 2002 19:35:24 -0000 1.21 @@ -85,6 +85,11 @@ # determines how many shots are taken before a pic is archived # (1 == every pic, 0 == don't archive) archive_shot_every = 1 +# create archive thumbnails enable/disable flag and give width/height +archive_thumbnails_dir = /opt/images/webcam/thumbnails +archive_thumbnails_create = 1 +archive_thumbnails_width = 120 +archive_thumbnails_height = 90 # jpeg quality (you can save as png etc too, but then quality does squat) quality = 80 input = 0 =================================================================== RCS file: /cvsroot/enlightenment/misc/camE/webcam.c,v retrieving revision 1.55 retrieving revision 1.56 diff -u -3 -r1.55 -r1.56 --- webcam.c 27 Feb 2002 19:23:38 -0000 1.55 +++ webcam.c 28 Feb 2002 19:35:24 -0000 1.56 @@ -93,7 +93,11 @@ char *ttf_dir = "/usr/X11R6/lib/X11/fonts/TrueType"; char *archive_ext = "jpg"; char *grab_archive = NULL; -int archive_shot_every = 1; /* default to archive every shot */ +int archive_shot_every = 1; /* default to archive every shot */ +char *archive_thumbnails_dir = NULL; +int archive_thumbnails_create = 0; /* default is not to create archive thumbnails */ +int archive_thumbnails_width = 120; +int archive_thumbnails_height = 90; char *grab_blockfile = NULL; char *upload_blockfile = NULL; char *grab_postprocess = NULL; @@ -274,24 +278,24 @@ wb.mode = PWC_WB_AUTO; wb.manual_red = 50; wb.manual_blue = 50; - if(!strcasecmp(pwc_wb_mode, "auto")) { + if (!strcasecmp(pwc_wb_mode, "auto")) { wb.mode = PWC_WB_AUTO; - } else if(!strcasecmp(pwc_wb_mode, "indoor")) { + } else if (!strcasecmp(pwc_wb_mode, "indoor")) { wb.mode = PWC_WB_INDOOR; - } else if(!strcasecmp(pwc_wb_mode, "outdoor")) { + } else if (!strcasecmp(pwc_wb_mode, "outdoor")) { wb.mode = PWC_WB_OUTDOOR; - } else if(!strcasecmp(pwc_wb_mode, "fluorescent")) { + } else if (!strcasecmp(pwc_wb_mode, "fluorescent")) { wb.mode = PWC_WB_FL; - } else if(!strcasecmp(pwc_wb_mode, "manual")) { + } else if (!strcasecmp(pwc_wb_mode, "manual")) { wb.mode = PWC_WB_MANUAL; wb.manual_red = 65535 * ((float) pwc_wb_red / 100); wb.manual_blue = 65535 * ((float) pwc_wb_blue / 100); } else { log("unknown pwc white balance mode '%s' ignored\n", pwc_wb_mode); } - + if (ioctl(grab_fd, VIDIOCPWCSAWB, &wb) < 0) - perror("trying to set pwc white balance mode"); + perror("trying to set pwc white balance mode"); } /* set image source and TV norm */ @@ -633,27 +637,43 @@ archive_jpeg(Imlib_Image im) { char buffer[1028]; + char thumbnail_buffer[1028]; char date[128]; time_t t; struct tm *tm; - struct stat st; static int shot_counter = 0; + Imlib_Image thumbnail_image; shot_counter++; - if (grab_archive && archive_shot_every - && shot_counter >= archive_shot_every) { + if (grab_archive && archive_shot_every + && shot_counter >= archive_shot_every) { time(&t); tm = localtime(&t); strftime(date, 127, "%Y-%m-%d_%H%M%S", tm); - do { - snprintf(buffer, sizeof(buffer), "%s/webcam_%s.%s", grab_archive, date, - archive_ext); - } - while (stat(buffer, &st) == 0); + snprintf(buffer, sizeof(buffer), "%s/webcam_%s.%s", grab_archive, date, + archive_ext); save_image(im, buffer); shot_counter = 0; + /* + * if archive thumbnails are enabled we save them here, + * same filenames just in "archive_thumbnails_directory" directory + * files are saved in the same format as archive + */ + if (archive_thumbnails_create && archive_thumbnails_width + && archive_thumbnails_height) { + snprintf(thumbnail_buffer, sizeof(buffer), "%s/webcam_%s.%s", + archive_thumbnails_dir, date, archive_ext); + thumbnail_image = + gib_imlib_create_cropped_scaled_image(im, 0, 0, + gib_imlib_image_get_width(im), + gib_imlib_image_get_height(im), + archive_thumbnails_width, + archive_thumbnails_height, 1); + save_image(thumbnail_image, thumbnail_buffer); + gib_imlib_free_image_and_decache(thumbnail_image); + } } } @@ -835,7 +855,7 @@ } fstat(fileno(infile), &st); - if(!post_commands) { + if (!post_commands) { snprintf(buf, sizeof(buf), "rnfr %s", tmp); post_commands = curl_slist_append(post_commands, buf); snprintf(buf, sizeof(buf), "rnto %s", remote); @@ -846,11 +866,11 @@ if (connections < 1) { curl_handle = curl_easy_init(); connections++; - + passwd_string = gib_strjoin(":", ftp_user, ftp_pass, NULL); curl_easy_setopt(curl_handle, CURLOPT_USERPWD, passwd_string); free(passwd_string); - + /* set URL to save to */ url_string = gib_strjoin("/", "ftp:/", ftp_host, ftp_dir, tmp, NULL); curl_easy_setopt(curl_handle, CURLOPT_URL, url_string); @@ -858,7 +878,7 @@ /* no progress meter please */ curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1); - + /* shut up completely */ if (ftp_debug) curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1); @@ -866,10 +886,10 @@ curl_easy_setopt(curl_handle, CURLOPT_MUTE, 1); curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1); - + if (!ftp_passive) curl_easy_setopt(curl_handle, CURLOPT_FTPPORT, ftp_interface); - + curl_easy_setopt(curl_handle, CURLOPT_POSTQUOTE, post_commands); } @@ -1186,6 +1206,8 @@ title_text = val; if (NULL != (val = cfg_get_str("grab", "archive_ext"))) archive_ext = val; + if (NULL != (val = cfg_get_str("grab", "archive_thumbnails_dir"))) + archive_thumbnails_dir = val; if (NULL != (val = cfg_get_str("grab", "logfile"))) logfile = val; if (NULL != (val = cfg_get_str("grab", "ttf_dir"))) @@ -1286,6 +1308,12 @@ scale_height = i; if (-1 != (i = cfg_get_int("grab", "archive_shot_every"))) archive_shot_every = i; + if (-1 != (i = cfg_get_int("grab", "archive_thumbnails_create"))) + archive_thumbnails_create = i; + if (-1 != (i = cfg_get_int("grab", "archive_thumbnails_width"))) + archive_thumbnails_width = i; + if (-1 != (i = cfg_get_int("grab", "archive_thumbnails_height"))) + archive_thumbnails_height = i; if (-1 != (i = cfg_get_int("grab", "pwc_wb_red"))) pwc_wb_red = i; if (-1 != (i = cfg_get_int("grab", "pwc_wb_blue"))) |