Spreads for single camera

Johannes Baiter's Spreads and SpreadPi are the latest control systems and postprocessors for DIY scanning. http://spreads.readthedocs.org

Moderator: peterZ

Post Reply
gareth
Posts: 11
Joined: 18 Jul 2014, 07:56
Number of books owned: 0
Country: UK

Spreads for single camera

Post by gareth »

I'm working away at getting spreads useable for the cardboard-box scanner use case since I'm still negotiating space for a two-camera setup.

Spreads is happy enough capturing in single camera mode now so I have some data to work with as I try to hone the workflow. The way I've shot the first book is:
  • Shoot all the odd numbered pages, front to back of the book
  • Turn the book over
  • Shoot all the even numbered pages, back to front of the book
So, having identified 'x' as the first of the even numbered pages I shot (not n/2 as I skipped some front matter), I need to write some code to:
  • Rotate pages 1 through x-1 90 degrees clockwise
  • Rotate pages x through n 90 degrees anti-clockwise
  • reverse the order of pages x through n then interleave them with 1 through x-1 as in a faro shuffle
It seems to me that a post-processing plugin to spreads is the right place to do this - any thoughts before I plough on?

Cheers
Gareth
duerig
Posts: 388
Joined: 01 Jun 2014, 17:04
Number of books owned: 1000
Country: United States of America

Re: Spreads for single camera

Post by duerig »

That sounds right. One thing to watch out for is that Spreads may have been inserting EXIF metadata into all of the shots to tag them as 'rotated'. So if your rotation seems wonky, I'd check that possibility first.
gareth
Posts: 11
Joined: 18 Jul 2014, 07:56
Number of books owned: 0
Country: UK

Re: Spreads for single camera

Post by gareth »

duerig wrote:That sounds right. One thing to watch out for is that Spreads may have been inserting EXIF metadata into all of the shots to tag them as 'rotated'. So if your rotation seems wonky, I'd check that possibility first.
Oh, that's interesting - I had noticed that the autorotate plugin used the EXIF to rotate but I didn't realise that spreads itself was inserting the metadata at capture.

In that case, one could refactor the problem into
  • Change the metadata for pages x through n to rotate through a further 180 degrees.
  • Run the autorotate plugin across the entire set of pages
  • reverse the order of pages x through n then interleave them with 1 through x-1 as in a faro shuffle
Are plugins capable of reordering the pages in a set? All of the ones I looked at in the sources are per-page functions on a 1-1 mapping. And can plugin ordering dependencies be expressed?
gareth
Posts: 11
Joined: 18 Jul 2014, 07:56
Number of books owned: 0
Country: UK

Re: Spreads for single camera

Post by gareth »

I haven't made any plugin progress on this but I've posted a standalone script I've been using in my workflow at the moment here, in case it's of any use to anyone else:

https://gist.github.com/gareth8118/c792fe58ed4065821968

Code: Select all

#!/usr/bin/env python

import shutil
import argparse


def interleave_pages(startindex, stopindex, startpage, srcpath, dstpath):
    """Remap a series of pages to interleaved destinations.
    """
    if startindex < stopindex:
        increment = 1
    else:
        increment = -1

    page = startpage

    for index in xrange(startindex, stopindex+increment, increment):
        srcfile = "%03d.jpg" % (index)
        dstfile = "%03d_from_%03d.jpg" % (page, index)
        print "Creating %s" % (dstfile)
        shutil.copy(srcpath + '/' + srcfile, dstpath + '/' + dstfile)
        page += 2


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('srcpath',
                        help="Path to the input images")
    parser.add_argument('dstpath',
                        help="Path to the output images")
    parser.add_argument('startindex',
                        type=int,
                        help="index of the starting page image")
    parser.add_argument('stopindex',
                        type=int,
                        help="index of the ending page image")
    parser.add_argument('startpage',
                        type=int,
                        help="output index of the page "
                             "corresponding to startindex")
    args = parser.parse_args()
    interleave_pages(args.startindex,
                     args.stopindex,
                     args.startpage,
                     args.srcpath,
                     args.dstpath)


if __name__ == '__main__':
    main()
Post Reply