Errata

Programming Computer Vision with Python

Errata for Programming Computer Vision with Python

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page 21
4th line of first source code block

and example source morphology.py :
the method 'measurements.label()' in :
m = 1*(im < 128l)
labels, numObjects = measurements.label( im )
throws exception "data type not supported" in
c:\Python27\lib\site-packages\scipy\ndimage\measurements.py, 167
im is a matrix of 0's and 1's.

When using the statement
im = ( im < 128 )
the program does work as expected. Here, im is a boolean array containing values True and False.
This same type of array is returned by the line
im = morphology.binary_opening(im, ones((9, 5)), iterations=2)
in the (original) second part of the example.

I am running Windows 7 64bit, python 2.7.3 32-bit, and scipy 0.11.0, numpy 1.6.2 (from the matching binary installer)

Note from the Author or Editor:
On my Mac with OS X 10.8.2, Python 2.7.2 I get the exact same result (45 and 48 objects) for all three versions:
im = 1*(im<128)
im = 1.0*(im<128)
im = (im<128)

Perhaps this is a platform specific problem? I will add note in future versions.

Frans van der Klip  Dec 19, 2012 
Printed, PDF, ePub
Page 30
Last row of example, bottom of the page.

The Harris response function code is missing a square of the trace in the denominator.

The line
return Wdet / Wtr
should be
return Wdet / (Wtr*Wtr)

The code online has been updated.
https://github.com/jesolem/PCV

Jan Erik Solem
Jan Erik Solem
 
Jan 23, 2013 
Printed
Page 31
At the middle of the page, in function get_harris_points()

In the sentence
index = argsort(candidate_values)
The function argsort() sorts candidate_values in ASCENDING order.

However, the text says, [sort them in descending order].
Therefore, the sentence
index = argsort(candiate_values)
should be revised as

index = argsort(candidate_values)[::-1]

Note: Oreilly seems not so actively to answer the errata. There are so many submitted errata remained unconfirmed long time. Some of errata are questions from reader.

Note from the Author or Editor:
You are right. The sorting is reversed. I have fixed this in the online code and will update the text for the next revision.

As for being slow to respond to errata and comments the fault is entirely mine (=Jan Erik Solem) and not O'Reilly's. Been too busy the last few months, sorry.

ColorRGB  Jul 02, 2013 
Printed
Page 40
the center of the code

matchscores = zeros((desc1_size[0],1),'int')

should be

matchscores = zeros(desc1_size[0],'int')

Note from the Author or Editor:
Both versions work but your suggestion is better.

aikawa  Feb 17, 2013 
Printed
Page 48
the last line in the code

The code:
g.write_png('graph.jpg', prog='neato')
writes graph.jpg as a PNG file. This should be:
g.write_png('graph.png', prog='neato')

Note from the Author or Editor:
This is correct. There is a typo in the text and the line should be changed to:
g.write_png('graph.png', prog='neato')

aikawa  Mar 10, 2013 
Printed
Page 63
6th line

The body text says 'turningtorso_points.txt', but, it is referred as 'turningtorso1_ponts.txt' in the code on P.64,

Note from the Author or Editor:
Yes. Line 6 on page 63 is missing a "1" in the filename. Should be "turningtorso1_points.txt".

aikawa  Mar 10, 2013 
Printed
Page 76
Fourth row from bottom

The index "j+1" should be "4".

Replace
im1 = array(Image.open(imname[j+1]))
with
im1 = array(Image.open(imname[4]))

Jan Erik Solem
Jan Erik Solem
 
May 06, 2013 
Printed
Page 88
10th line down

When running code in book, program stops and I get the following error:

box_trans = homography.normalize(dot(H,box_cam1))
ValueError: setting an array element with a sequence.

Runs fine up to this point.

Note from the Author or Editor:
This is indeed a mistake. The line 8 lines down on p87 that reads:
H = homography.H_from_ransac(fp,tp,model)
should read:
H, inliers = homography.H_from_ransac(fp,tp,model)

Updated example code is available on
https://github.com/jesolem/PCV/blob/master/examples/ar_cube.py

Doug Blanding  Sep 27, 2012 
Printed
Page 91
code

aspect = (width*fy)/(height*fx)

will truncate the value if the all values are integer.
This should be:

aspect = float(width*fy)/(height*fx)

Note from the Author or Editor:
This could indeed be a problem if someone has integer focal lengths (unlikely). The suggested improvement:

aspect = float(width*fy)/(height*fx)

should be used.

aikawa  Feb 17, 2013 
Printed
Page 150
code

import vlfeat as sift

should be

import sift

Note from the Author or Editor:
Yes. The module was called vlfeat but changed name during the book review process. The suggestion
import sift
is correct.

aikawa  Feb 23, 2013 
Printed
Page 152,154
code

from pysqlite2 import dbapi2 as sqlite

should be now:

from sqlite3 import dbapi2 as sqlite

Note from the Author or Editor:
Agree. This should be changed in future versions of the text/code.

aikawa  Feb 23, 2013 
Printed
Page 154
code

The comment says "go through all images", but the code below it loops only the first 100 images.

for i in range(nbr_images)[:100]:

should be

for i in range(nbr_images):

Note from the Author or Editor:
Yes. There is a typo there. The suggested
for i in range(nbr_images):
is correct.

aikawa  Mar 13, 2013 
Printed
Page 175
Line 7, 8 from top

There are two misprints in these two lines.
The 'test_labels' should be simply 'labels'.

Note from the Author or Editor:
Yes. There is a typo there. On both lines, this should be "labels" instead of "test_labels".

ColorRGB  Feb 21, 2013 
Printed, PDF, ePub, Mobi,
Page 182
Code example at the bottom of the page

The tiny helper function convert_labels is missing from this example.

def convert_labels(labels,transl):
""" Convert between strings and numbers. """
return [transl[l] for l in labels]

Jan Erik Solem
Jan Erik Solem
 
Feb 10, 2013 
Printed
Page 186
Line 4 in the first paragraph

Figure 8-8 should be Figure 8-7

Note from the Author or Editor:
Yes. The reference on the fourth line on p 186 should be to Figure 8-7.

ColorRGB  Feb 26, 2013 
Printed
Page 212,213
P212: at the end of the first code; P213: at the end of the code

Bothe codes teriminated normally when run on the MSDOS command line. However they can not terminated when run in IDLE(Python GUI) and PyScripter.

Adding the following function at the end of the code can solve this problem for most of platform.

cv2.destroyAllWindows()

Note from the Author or Editor:
Thanks. A comment should be added in future versions of the text.

ColorRGB  Feb 28, 2013