⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capture.c

📁 小程序,但是有点用出处的.进攻参考.请多多提意见.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************//* *      capture.c  --  reader for the fps200usb driver * *      Copyright (C) 2002, 2003  Cristiano Rodrigues de Carvalho  *                                (crc@cefala.org) *      Developed at the Federal University of Minas Gerais (www.ufm.br) *      Laboratory of the Center for Research in Speech, Acoustics,  *      Language and Music (www.cefala.org) * *      The Author thanks CNPq - Brazil for the financial support * *      This program is free software; you can redistribute it and/or modify *      it under the terms of the GNU General Public License as published by *      the Free Software Foundation; either version 2 of the License, or *      (at your option) any later version. * *      This program is distributed in the hope that it will be useful, *      but WITHOUT ANY WARRANTY; without even the implied warranty of *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *      GNU General Public License for more details. * *      You should have received a copy of the GNU General Public License *      along with this program; if not, write to the Free Software *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * * History: *  01/08/2003: first release * *//*****************************************************************************/#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <linux/unistd.h>#include <errno.h>#include <sys/ioctl.h>#include <string.h>#include <sys/times.h>#include <time.h>#include "fps200ctl.h"#define VERSION "0.1"unsigned char buffer[128*1024]; /* more than enough to read an image (with headers) */int *buffer_mean=NULL;int size_buffer_mean=0;int calculate_mean=0;/* parameters sequences */enum {  PAR_NUMFRAMES,  PAR_MEAN,  PAR_BACKGROUND,  PAR_DEVNAME,  PAR_RECT,  PAR_STDOUT,  PAR_FORCEPGM,  PAR_FORCEBMP,  PAR_FORCERAW,  PAR_VERSION,  PAR_HELP,  PAR_LICENSE,};const char *arg_list[]={  "--numframes", "--mean", "--background", "--dev", "--rect", "--stdout",   "--pgm", "--bmp", "--raw",  "--version",  "--help", "--license", ""};const char *arg_info[]={  "number of frames to be retrieved (default=1)\n"  "   example: --numframes 2",  "use the number of frames specified to calculate one average\n"  "image that will be saved.",  "use the specified image (raw) as the background image. This image is"  "then subtracted from the capture image to remove noise artefacts."  "name of the device to be used for reading (default=/dev/fps200)\n"  "   example: --dev /dev/fps200",  "sets the dimension of the image in the format x y width height\n"  "   example: --rect 0 0 256 300",  "redirect output to stdout instead of to a file",  "force the output format to be pgm (Portable Graymap Format)",  "force the output format to be bmp (Microsoft(TM) Bitmap Format)",  "force the output format to be raw (Raw format without headings)",  "prints the version of the program and exit",  "shows this help message and exits",  "shows the software license and exits",};struct {  int nframes;  int toStdout;  int forceFileFormat;  int fileFormat;  char *dev;  char *background;  char *fname;  struct fps200_dimension rect;} par;const char *fileFormatName[]={"PGM", "RAW", "BMP", "UNKNOWN"};#define FILE_FORMAT_UNKNOWN 3/* ---------------------------------------------------------------- */void license(void){  printf(     "This program is free software; you can redistribute it and/or modify\n"     "it under the terms of the GNU General Public License as published by\n"     "the Free Software Foundation; either version 2 of the License, or\n"     "(at your option) any later version.\n"     "\n"     "This program is distributed in the hope that it will be useful,\n"     "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"     "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"     "GNU General Public License for more details.\n"     "\n"     "You should have received a copy of the GNU General Public License\n"     "along with this program; if not, write to the Free Software\n"     "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"     );}/* ---------------------------------------------------------------- */void usage(void){  int i;  printf("Copyright (C) 2002,2003 - Cristiano Rodrigues de Carvalho(crc@cefala.org)\n"	 "Center for Research in Speech, Acoustics, Language and Music (www.cefala.org)\n"	 "Federal University of Minas Gerais (www.ufmg.br)\n"	 "The Author thanks CNPq - Brazil for the financial support."	 "\n\n\n"	 "Description:\n"	 "This software retrieves the image from the FPS200 Verificom's\n"	 "Fingerprint Sensor through the use of the non-official linux driver.\nIt was developed to serve as a template for development of fingerprint\nrecognition applications and an example of the driver usage but can be usefull\nfor many users as a final application.\n"	 "\n"	 "usage: capture [options] file\n"	 "  file: the name of the destination file.\n"	 "        The file format is assumed based on the file extension.\n"	 "        The available extensions are:\n"	 "         .pgm for Portable Graymap Format\n"	 "         .bmp for Microsoft(TM) Bitmap\n"	 "         .raw for raw data\n"	 "        You can specify more than one frame only for the pgm and\n"	 "        the raw format.\n"	 "\n"	 "Details about the RAW format:\n"	 " Each sample is one byte and the image is written from\n"	 " left to right, top to bottom resulting in 76800 bytes for the\n"	 " full image.\n"	 " To read the raw image in octave, for instance, you can use:\n"	 "  fid=fopen('image.raw', 'r');\n"	 "  im=fread(fid, inf, 'uchar');\n"	 "  fclose(fid);\n"	 "  x = reshape(im, 256, 300)';\n"	 "  imagesc(x, 1);\n"	 "\n"	 " You can also acquires images directly to octave issuing the commands\n"	 "  fid=popen('./capture --raw --stdout', 'r');\n"	 "  im=fread(fid, inf, 'uchar');\n"	 "  pclose(fid);\n"	 "  x = reshape(im, 256, 300)';\n"	 "  imagesc(x, 1);\n"	 "\n"	 "Details about the multi-frame file: \n"	 " When you specify more than one frame the images are simply\n"	 " concatenated in the file. This way you can view the file\n"	 " with the display program and advance frames pressing space.\n"	 "\n"	 "options: \n"	 );  i = 0;  while(strlen(arg_list[i])){    printf(" %s: %s\n", arg_list[i], arg_info[i]);    i++;  }}/* ---------------------------------------------------------------- */int parse_args(int argc, char *argv[]){  int i, npar;  if (argc < 2){    usage();    return -1;  }  npar = argc-1;  for (i=1; i < argc; i++){    if (strcmp(arg_list[PAR_NUMFRAMES], argv[i]) == 0){      if ((i+1) < argc){	par.nframes = atoi(argv[++i]);	npar--;      }      else{	fprintf(stderr, "Error: you must specify a number for the %s arg\n", 		arg_list[PAR_NUMFRAMES]);	return -1;      }    }    else    if (strcmp(arg_list[PAR_MEAN], argv[i]) == 0){      calculate_mean = 1;    }    else    if (strcmp(arg_list[PAR_BACKGROUND], argv[i]) == 0){      if ((i+1) < argc){	par.background = argv[++i];	npar--;      }      else{	fprintf(stderr, "Error: you must specify a file name for"		" the %s arg\n", arg_list[PAR_BACKGROUND]);	return -1;      }    }    else    if (strcmp(arg_list[PAR_DEVNAME], argv[i]) == 0){      if ((i+1) < argc){	par.dev = argv[++i];	npar--;      }      else{	fprintf(stderr, "Error: you must specify a file name for"		" the %s arg\n", arg_list[PAR_DEVNAME]);	return -1;      }    }    else    if (strcmp(arg_list[PAR_HELP], argv[i]) == 0){      usage();      return -1;    }    if (strcmp(arg_list[PAR_RECT], argv[i]) == 0){      if ((i+4) < argc){	par.rect.x = atoi(argv[i+1]);	par.rect.y = atoi(argv[i+2]);	par.rect.width = atoi(argv[i+3]);	par.rect.height = atoi(argv[i+4]);	i+=4;      }      else{	fprintf(stderr, "Error: you must specify the dimension"		" of the image\n");	return -1;      }	    }    if (strcmp(arg_list[PAR_LICENSE], argv[i]) == 0){      license();      return -1;    }    if (strcmp(arg_list[PAR_STDOUT], argv[i]) == 0)      par.toStdout = 1;    if (strcmp(arg_list[PAR_FORCEPGM], argv[i]) == 0){      par.forceFileFormat = 1;      par.fileFormat = FPS200_FILEFORMAT_PGM;    }    if (strcmp(arg_list[PAR_FORCEBMP], argv[i]) == 0){      par.forceFileFormat = 1;      par.fileFormat = FPS200_FILEFORMAT_BMP;    }    if (strcmp(arg_list[PAR_FORCERAW], argv[i]) == 0){      par.forceFileFormat = 1;      par.fileFormat = FPS200_FILEFORMAT_RAW;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -