108 | | 1. Generate the XML files from the user defined data requirements and then use XSL-FO (eXtensible Stylesheet Language - Formatting Object) to work with the XML documents to tailor the document appearance for printing. A XSL-FO processor, Apache FOP has to be used to generate PDFs out of it. |
109 | | |
110 | | 2. The required data be exported into reST format from the XML files generated by the SahanaPy framework and the package rst2pdf could be used to generate pdfs. rst2pdf uses reportlab which enables us not only to logicaly format the data to be printed but also helps us keep the co-ordinates of the printed data with reference to the bottom left point taken as origin. |
111 | | |
112 | | rst2pdf uses a styling sheet to format the reST data and thus should be provided a stylesheet (a json file with several elements in it) which should be generated along with the .rst files. This helps us format the data properly as it contains the parameters to the reportlab module to personalize the printable forms. |
113 | | |
114 | | The second approach is much preferrable in the sense that the entire code base is in python and we can obtain the data that can later help us in reading the data. |
| 109 | 1. Generate the XML files from the user defined data requirements and then use XSL-FO (eXtensible Stylesheet Language - Formatting Object) to work with the XML documents to tailor the document appearance for printing. A XSL-FO processor, Apache FOP has to be used to generate PDFs out of it. Well this does not give enough flexibility to print all the information we need. Thus we ruled it out. |
| 110 | |
| 111 | 2. The required data be exported into reST format from the XML files generated by the SahanaPy framework and the package rst2pdf could be used to generate pdfs. rst2pdf uses reportlab which enables us not only to logicaly format the data to be printed but also helps us keep the co-ordinates of the printed data with reference to the bottom left point taken as origin. This proved to be very roundabout way. |
| 112 | |
| 113 | 3. The way the GSoC 2010 participant has approached this problem is to parse the XML file down the tree and using reportlab to generate the pdf file. So a parser has been implemented and th |
118 | | To minimize the task of recognizing the handwriting recognition, most of the general data (like gender, location etc.) can be printed in the forms with corresponding checkboxes. The rest of the data like name and age has to be handwritten for which providing checkboxes isnt practical has to be recognized. |
119 | | |
120 | | Each custom form generated can be given an unique ID either by just printing the unique ID logically in the form of a barcodes. |
| 117 | To minimize the task of recognizing the handwriting, most of the general data (like gender, location etc.) can be printed in the forms with corresponding checkboxes. The rest of the data like name and age has to be handwritten for which providing checkboxes isnt practical has to be recognized. |
| 118 | |
| 119 | Each custom form generated can be given an unique ID either by just printing the unique ID logically in the form of a bar codes. |
| 120 | |
| 121 | The forms could be generated using the xforms2pdf.py which is located in the scripts folder using the syntax as mentioned below. Incase the pdfname is not mentioned, it uses the <uuid>.pdf format to save the files. The default storage location is the ocrforms folder in the main directory structure if the path is not mentioned. |
| 122 | |
| 123 | {{{ |
| 124 | Usage: python xforms2pdf.py <xforminput> <OPTIONAL -> pdfoutput> |
| 125 | }}} |
| 156 | |
| 157 | == GSoC 2010 code layout == |
| 158 | {{{ |
| 159 | config <- Global config file |
| 160 | |
| 161 | images: <- A possible storage area for the images |
| 162 | |
| 163 | layoutfiles: <- Default storage area for the layout info of the forms generated |
| 164 | |
| 165 | ocrforms: <- Default storage area for the xml forms |
| 166 | |
| 167 | parseddata: <- Stores the parsed data |
| 168 | |
| 169 | README <- Explains the howto |
| 170 | |
| 171 | |
| 172 | sahanahcr: |
| 173 | |-dataHandler.py <- A class to parse the images and dump the data |
| 174 | |-formHandler.py <- A class to handle the xforms and print them to pdf |
| 175 | |-functions.py <- A module with all the necessary functions for this entire ocr module |
| 176 | |-parseform.py <- A script to parse the forms |
| 177 | |-printForm.py <- A class to handle the reportlab api to print forms |
| 178 | |-regions.py <- A Class which describes a region in an image |
| 179 | |-upload.py <- A script to upload the files |
| 180 | |-urllib2_file.py <- A module which augments urllib2's functionality to upload files |
| 181 | |-xforms2pdf.py <- Converts xforms to pdfs and uses the classes from formhandler and printform |
| 182 | |
| 183 | |
| 184 | tessdata: <- A folder where the necessary training info is stored to parse the scanned forms |
| 185 | |-configs |
| 186 | |-tessconfigs |
| 187 | |
| 188 | training: |
| 189 | |-generatetrainingform.py <- Generates the training form |
| 190 | |-train.py <- Trains the engine and stores the training data in the tessdata folder |
| 191 | |-datafiles: <- Contains the input to generate training form and also the training form layout info files |
| 192 | |-printedpdfs: <- Printed trainging forms reside here |
| 193 | |
| 194 | }}} |