Leptonica 1.68
C Image Processing Library

barcodetest.c

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 /*
00017  * barcodetest.c
00018  *
00019  *      barcodetest filein
00020  *
00021  *  For each barcode in the image, if the barcode format is supported,
00022  *  this deskews and crops it, and then decodes it twice:
00023  *      (1) as is (deskewed)
00024  *      (2) after 180 degree rotation
00025  */
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include "allheaders.h"
00030 #include "readbarcode.h"
00031 
00032 
00033 main(int    argc,
00034      char **argv)
00035 {
00036 char        *filein;
00037 PIX         *pixs;
00038 SARRAY      *saw1, *saw2, *saw3, *sad1, *sad2, *sad3;
00039 static char  mainName[] = "barcodetest";
00040 
00041     if (argc != 2)
00042         exit(ERROR_INT(" Syntax:  barcodetest filein", mainName, 1));
00043 
00044     filein = argv[1];
00045     if ((pixs = pixRead(filein)) == NULL)
00046         exit(ERROR_INT("pixs not made", mainName, 1));
00047             
00048     sad1 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WIDTHS, &saw1, 0);
00049     sarrayWrite("/tmp/junksaw1", saw1);
00050     sarrayWrite("/tmp/junksad1", sad1);
00051     sarrayDestroy(&saw1);
00052     sarrayDestroy(&sad1);
00053 
00054     pixRotate180(pixs, pixs);
00055     sad2 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WIDTHS, &saw2, 0);
00056     sarrayWrite("/tmp/junksaw2", saw2);
00057     sarrayWrite("/tmp/junksad2", sad2);
00058     sarrayDestroy(&saw2);
00059     sarrayDestroy(&sad2);
00060 
00061 /*    sad3 = pixProcessBarcodes(pixs, L_BF_ANY, L_USE_WINDOW, &saw3, 1);
00062     sarrayWrite("/tmp/junksaw3", saw3);
00063     sarrayWrite("/tmp/junksad3", sad3);
00064     sarrayDestroy(&saw3);
00065     sarrayDestroy(&sad3); */
00066 
00067     pixDestroy(&pixs);
00068     exit(0);
00069 }
00070 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines