Daniel Reetz, the founder of the DIY Book Scanner community, has recently started making videos of prototyping and shop tips. If you are tinkering with a book scanner (or any other project) in your home shop, these tips will come in handy. https://www.youtube.com/channel/UCn0gq8 ... g_8K1nfInQ

PPM tools from mhr

General discussion about software packages and releases, new software you've found, and threads by programmers and script writers.
Post Reply
mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

PPM tools from mhr

Post by mhr » 17 Sep 2013, 09:13

I opened a new topic to have a unique place for my PPM tools.

ppmunwarp is described in http://www.diybookscanner.org/forum/vie ... =19&t=2589.
ppmwhitebalance is described in http://www.diybookscanner.org/forum/vie ... =19&t=2891.

This is version 1.6 of the tool chain:
ppm_rose_tools_v1.6.zip
Source code of version 1.6 of ppm_rose_tools
(48.32 KiB) Downloaded 213 times
Here are the 64bit executables for Windows 7:
ppm_rose_tools_v1.6_win64bit.zip
Binaries for Windows 7 64 bit of ppm_rose_tools version 1.6
(200.32 KiB) Downloaded 177 times

mhr
Posts: 37
Joined: 07 May 2012, 10:12
E-book readers owned: onyx-boox-m92 sony-trs-t1
Number of books owned: 500
Country: Germany

Re: PPM tools from mhr

Post by mhr » 17 Sep 2013, 09:18

Starting with version 1.6 there is a third tool ppmrectlist in this tool set,
which is described in detail in the tutorial http://www.diybookscanner.org/forum/vie ... =19&t=2916.

abmartin
Posts: 79
Joined: 15 Sep 2010, 15:33
Number of books owned: 2000
Country: USA
Location: Ohio

Re: PPM tools from mhr

Post by abmartin » 04 Oct 2013, 17:04

Thanks again for the updates! I really need to try them out!!!

What I really wish I could find is a really large gray card so I don't have to worry about the crop issue. I love the idea of having something that can help with uneven lighting. I may just try some poster board and just do the math to figure out its exact colors ater calibrating with one of the small cards I have.

Anyone know of a source of gray cards that would be platen-sized? The biggest I know are about 8"x10."

pablitoclavito
Posts: 39
Joined: 12 Sep 2012, 16:54
E-book readers owned: Iliad
Number of books owned: 200
Country: Spain

Re: PPM tools from mhr

Post by pablitoclavito » 22 Feb 2014, 21:25

Hi
I compiled this before, but i have reinstalled Linux in another machine and I don't know how to do it now

I downloaded ppm_rose_tools_v1.6.zip
Source code of version 1.6 of ppm_rose_tools

Extracted all the files (is it important the folder where I extract them?)
I wrote in a terminal (as superuser)
g++ -o ppmunwarp ppmunwarp.cc

and i got this error message

Code: Select all

/tmp/ccV6Zmlj.o: In function `main':
ppmunwarp.cc:(.text+0x21): undefined reference to `Handler(int, char**, Parameter&)'
/tmp/ccV6Zmlj.o: In function `ParameterUnwarp::Define()':
ppmunwarp.cc:(.text+0x57): undefined reference to `Parameter::AddFlag(char const*, int&, char const*, char const*)'
ppmunwarp.cc:(.text+0x84): undefined reference to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)'
ppmunwarp.cc:(.text+0xb1): undefined reference to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)'
ppmunwarp.cc:(.text+0xde): undefined reference to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)'
ppmunwarp.cc:(.text+0x10b): undefined reference to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)'
ppmunwarp.cc:(.text+0x138): undefined reference to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)'
/tmp/ccV6Zmlj.o:ppmunwarp.cc:(.text+0x165): more undefined references to `Parameter::AddString(char const*, char const*&, char const*, char const*, char const*)' follow
/tmp/ccV6Zmlj.o: In function `ParameterUnwarp::Define()':
ppmunwarp.cc:(.text+0x1ab): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x1f1): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x251): undefined reference to `Parameter::AddDouble(char const*, double&, double, double, double, char const*, char const*)'
ppmunwarp.cc:(.text+0x2d0): undefined reference to `Parameter::AddDouble(char const*, double&, double, double, double, char const*, char const*)'
ppmunwarp.cc:(.text+0x316): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x35c): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x3a2): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x3e8): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x42e): undefined reference to `Parameter::AddInt(char const*, int&, int, int, int, int, char const*, char const*)'
ppmunwarp.cc:(.text+0x43f): undefined reference to `Parameter::ExtraUsage(char const*)'
/tmp/ccV6Zmlj.o: In function `ParameterUnwarp::Check()':
ppmunwarp.cc:(.text+0x4f8): undefined reference to `Parameter::Usage(int)'
ppmunwarp.cc:(.text+0x529): undefined reference to `Parameter::Usage(int)'
ppmunwarp.cc:(.text+0x639): undefined reference to `Parameter::Usage(int)'
/tmp/ccV6Zmlj.o: In function `Grid::Read(char const*, _IO_FILE*)':
ppmunwarp.cc:(.text+0xa6c): undefined reference to `Error(char const*, ...)'
ppmunwarp.cc:(.text+0xcc6): undefined reference to `Error(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Grid::Write(char const*, _IO_FILE*)':
ppmunwarp.cc:(.text+0xd2f): undefined reference to `Error(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Mesh::FindIndices()':
ppmunwarp.cc:(.text+0x3e7a): undefined reference to `Print(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Picture::FilterRedPoints()':
ppmunwarp.cc:(.text+0x4332): undefined reference to `Print(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Picture::Calibrate(Grid&)':
ppmunwarp.cc:(.text+0x53b0): undefined reference to `Print(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::Reset(long, long)':
ppmunwarp.cc:(.text+0x544c): undefined reference to `Error(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::Read(char const*, _IO_FILE*)':
ppmunwarp.cc:(.text+0x57cc): undefined reference to `Error(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::Write(char const*, _IO_FILE*)':
ppmunwarp.cc:(.text+0x595f): undefined reference to `Error(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::SetFlattenedPictureSize(Grid&)':
ppmunwarp.cc:(.text+0x5ccd): undefined reference to `Print(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::Calculate(Grid&, int, int, double, double)':
ppmunwarp.cc:(.text+0x66d0): undefined reference to `Print(char const*, ...)'
ppmunwarp.cc:(.text+0x671f): undefined reference to `Print(char const*, ...)'
/tmp/ccV6Zmlj.o: In function `Deformation::Flatten(Picture&, Picture&)':
ppmunwarp.cc:(.text+0x69ac): undefined reference to `Image::Reset(long, long, long)'
ppmunwarp.cc:(.text+0x6a50): undefined reference to `Interpolation1::Set(double)'
ppmunwarp.cc:(.text+0x6a80): undefined reference to `Interpolation1::Set(double)'
ppmunwarp.cc:(.text+0x6a9d): undefined reference to `Interpolation2<int>::operator()(int*)'
ppmunwarp.cc:(.text+0x6aff): undefined reference to `Interpolation1::Set(double)'
ppmunwarp.cc:(.text+0x6b20): undefined reference to `Interpolation2<int>::operator()(int*)'
ppmunwarp.cc:(.text+0x6b86): undefined reference to `Interpolation1::Set(double)'
ppmunwarp.cc:(.text+0x6bbd): undefined reference to `Interpolation2<unsigned short>::operator()(unsigned short*)'
/tmp/ccV6Zmlj.o: In function `Main()':
ppmunwarp.cc:(.text+0x6d2d): undefined reference to `Image::Read(char const*, _IO_FILE*)'
ppmunwarp.cc:(.text+0x6d4a): undefined reference to `Image::Read(char const*, _IO_FILE*)'
ppmunwarp.cc:(.text+0x6f88): undefined reference to `Image::Read(char const*, _IO_FILE*)'
ppmunwarp.cc:(.text+0x6fa5): undefined reference to `Image::Read(char const*, _IO_FILE*)'
/tmp/ccV6Zmlj.o: In function `Image::Image()':
ppmunwarp.cc:(.text._ZN5ImageC2Ev[_ZN5ImageC5Ev]+0x2f): undefined reference to `Image::Reset(long, long, long)'
/tmp/ccV6Zmlj.o: In function `Image::~Image()':
ppmunwarp.cc:(.text._ZN5ImageD2Ev[_ZN5ImageD5Ev]+0x23): undefined reference to `Image::Reset(long, long, long)'
/tmp/ccV6Zmlj.o: In function `Picture::Write(char const*, _IO_FILE*)':
ppmunwarp.cc:(.text._ZN7Picture5WriteEPKcP8_IO_FILE[_ZN7Picture5WriteEPKcP8_IO_FILE]+0x2b): undefined reference to `Image::Write(char const*, _IO_FILE*, char const*)'
collect2: error: ld returned 1 exit status
Any help?
Thank you

abmartin
Posts: 79
Joined: 15 Sep 2010, 15:33
Number of books owned: 2000
Country: USA
Location: Ohio

Re: PPM tools from mhr

Post by abmartin » 23 Feb 2014, 11:30

Pablitoclavito,

MHR has simplified the building process since there are now three different programs to compile. Just run the command:
make

That will build all the binaries. You can then put them where you want or you can run "make install" which will put them in MHR's default.

If you run into other issues compiling software, I wrote a post-install script in another thread that you could use or just read the appropriate sections as a guide. It's commented well-enough. (I need to update it to reflect the changes in spreads, but I'd rather wait until closer to release)

pablitoclavito
Posts: 39
Joined: 12 Sep 2012, 16:54
E-book readers owned: Iliad
Number of books owned: 200
Country: Spain

Re: PPM tools from mhr

Post by pablitoclavito » 23 Feb 2014, 20:56

Thank you for your prompt response

I could compile ppmunwarp

Then proceeded to do a test with 2 photos+calibration photo.
But I ran your script as I used to do and, again, I found that anything was done
(0 bytes calibration.bin and the preprocess.log file, but no resulting calibrated photos)

Code: Select all

Your camera images are now being prepared for Scantailor

No color correction will be done
Preparing images for ppmunwarp by converting JPG to ppm
done

Calculating geometry calibration data from image: calibration.ppm
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
done

Correcting geometry.  This will take some time...
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
done

Calculating DPI from image: calibration_corrected.ppm
Usage: ppmunwarp [options] [--] [inpname or stdin]

Options:
--version           Print program version.
-h                  Print program usage.
-q                  Suppress normal program messages.
-c                  Enforce calibration mode.
-cc       (inpname) Set input PPM picture with calibration points.
-m        <name>    Set output PPM picture with checked calibration points.
-cp       <name>    Set file name for textual calibration point list.
-d        (stdout)  Set file name for binary deformation grid.
-i        (inpname) Set input file name.
-o        (stdout)  Set ouput file name.
-gm       (1)       Set additional margin around calibration points.
-gs       (2)       Set scale factor for deformation grid.
-gx       (5.08)    Set grid points per inch in x- and y-direction.
-gy       (5.08)    Set grid points per inch in y-direction.
-pc       (ff0000)  Point color for calibration point detection.
-ph       (85)      Infeasible hue range  [%%] (point detection).
-ps       (50)      Minimal    saturation [%%] (point detection).
-pv       (50)      Minimal    luminance  [%%] (point detection).
-od       (0)       Output color depth, zero means same as input depth.

Simple calibration:  ppmunwarp [-m check.ppm] calib.ppm > deform.bin
Simple unwarping:    ppmunwarp -d deform.bin skewed.ppm > unwarped.ppm
Calculated PPI is: 

ImageMagick will now prepare images for Scantailor...
mogrify.im6: invalid argument for option `-units': -density @ error/mogrify.c/MogrifyImageCommand/4325.
done

Deleting temporary files...
done

Your images are ready for Scantailor
Thank you

abmartin
Posts: 79
Joined: 15 Sep 2010, 15:33
Number of books owned: 2000
Country: USA
Location: Ohio

Re: PPM tools from mhr

Post by abmartin » 25 Feb 2014, 20:04

The first failure is that it's not calibrating properly. From what I can see, it's trying to convert JPG (case sensitive) to ppm files. At the end of the script, it deletes the PPM files, so the first thing I'd check is that it is actually making those conversions in the first place etiher by commenting out the cleanup section or just watching the file manager when you run the script. Also check the name of the calibration image. It's looking for calibration.JPG. If you are doing it differently, change the configuration as appropriate.

If it isn't an issue with the file name or a failure of imagemagick (check that it's installed too), it wouid be better to continue this discussion in the thread for the script rather than hijacking this one.

Post Reply