On Do, 2015-10-01 at 18:03 +0000, Terrence Kovacs wrote: > Thanks for the quick response. > Yes it is a simplex document. > Unfortunately the patch you sent threw this:
Ah, yes. I forgot about the "ignore" flag that needs to be set. The image file name and page number do not matter at all then. Your fix is much better actually. You might want to also pass the copy=False to add_image, so that you don't get duplicates of the TIFFs copied into your project directory all the time. :) Benjamin > [tkovacs@sunspot new]$ ./sdaps-recognize.py tenq tenq_scan.tif > TIFFOpen: tenq/../DUMMY: No such file or directory. > Traceback (most recent call last): > File "./sdaps-recognize.py", line 74, in > survey.questionnaire.recognize.recognize() > File "/usr/lib64/python2.7/site-packages/sdaps/recognize/buddies.py", line > 479, in recognize > res = self.identify(clean=False) > File "/usr/lib64/python2.7/site-packages/sdaps/recognize/buddies.py", line > 465, in identify > self.obj.sheet.recognize.recognize() > File "/usr/lib64/python2.7/site-packages/sdaps/recognize/buddies.py", line > 55, in recognize > image.surface.load() > File "/usr/lib64/python2.7/site-packages/sdaps/surface.py", line 51, in load > True if self.obj.rotated else False > AssertionError: The image surface could not be created! Broken or non 1bit > tiff file? > > after some tinkering I resorted to importing add_image from sdaps.add which > does the correct magic. > > $ diff ../sdaps-1.1.10/custom-scripts/sdaps-recognize.py sdaps-recognize.py > 31a32 > > from sdaps.add import add_image > 54,62d54 > < > < def add_image(survey, tiff, page): > < img = model.sheet.Image() > < survey.sheet.add_image(img) > < # SDAPS assumes a relative path from the survey directory > < img.filename = os.path.relpath(os.path.abspath(tiff), survey.survey_dir) > < img.orig_name = tiff > < img.tiff_page = page > < > 67,70c59 > < add_image(survey, *images.pop(0)) > < > < if survey.defs.duplex: > < add_image(survey, *images.pop(0)) > --- > > add_image(survey, images.pop(0)[0], survey.defs.duplex) > > > Terrence Kovacs > Research Systems Engineer > Physics and Astronomy Department > Dartmouth College > Wilder 341, 603-646-9303 > > ________________________________________ > From: Benjamin Berg <[email protected]> > Sent: Wednesday, September 30, 2015 5:04 PM > To: Terrence Kovacs; [email protected] > Subject: Re: custom script sdap-recognize.py > > Hi, > > hm, interesting. My guess would be that you have a simplex document? > Probably never tested the script in that case. > > Short explanation. SDAPS basically assumes internally that all surveys > are printed and scanned in duplex mode. To handle simplex mode the > "sdaps add" command inserts a special dummy page so that exactly this > failure does not happen. > > If you scanned in simplex mode then apply the attached patch. If you > scanned in duplex mode, then just run the second add_image there > unconditionally instead. > > Benjamin > > > On Mi, 2015-09-30 at 20:47 +0000, Terrence Kovacs wrote: > > I have a sdaps tenq survey which I can run: > > [tkovacs@sunspot new]$ sdaps tenq recognize > > --------------------------------------------------------------------- > > --------- > > - SDAPS -- recognize > > --------------------------------------------------------------------- > > --------- > > 6 sheets > > > ################################################################| > > 100% 00:00:01 > > 0.219686 seconds per sheet > > > > without issue but the custom script throws an error. Am I doing > > something wrong? > > > > [tkovacs@sunspot new]$ ./sdaps-recognize.py tenq tenq_scan.tif > > Traceback (most recent call last): > > File "./sdaps-recognize.py", line 73, in > > survey.questionnaire.recognize.recognize() > > File "/usr/lib64/python2.7/site > > -packages/sdaps/recognize/buddies.py", line 479, in recognize > > res = self.identify(clean=False) > > File "/usr/lib64/python2.7/site > > -packages/sdaps/recognize/buddies.py", line 465, in identify > > self.obj.sheet.recognize.recognize() > > File "/usr/lib64/python2.7/site > > -packages/sdaps/recognize/buddies.py", line 85, in recognize > > self.duplex_copy_image_attr(failed_pages, 'rotated', _("Neither > > %s, %i or %s, %i has a known rotation!")) > > File "/usr/lib64/python2.7/site > > -packages/sdaps/recognize/buddies.py", line 292, in > > duplex_copy_image_attr > > second = self.obj.images[i + 1] > > IndexError: list index out of range > > > > Terrence Kovacs > > Research Systems Engineer > > Physics and Astronomy Department > > Dartmouth College > > Wilder 341, 603-646-9303 >
signature.asc
Description: This is a digitally signed message part
