Skip to content

Commit

Permalink
Updating first edition (Cameo) code for Python 3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHowse committed Apr 27, 2019
1 parent a2bb227 commit 50a7b60
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion first_edition/appendix/cameo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, capture, previewWindowManager = None,
self._videoWriter = None

self._startTime = None
self._framesElapsed = long(0)
self._framesElapsed = 0
self._fpsEstimate = None

@property
Expand Down
2 changes: 1 addition & 1 deletion first_edition/chapter2/cameo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, capture, previewWindowManager = None,
self._videoWriter = None

self._startTime = None
self._framesElapsed = long(0)
self._framesElapsed = 0
self._fpsEstimate = None

@property
Expand Down
2 changes: 1 addition & 1 deletion first_edition/chapter3/cameo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, capture, previewWindowManager = None,
self._videoWriter = None

self._startTime = None
self._framesElapsed = long(0)
self._framesElapsed = 0
self._fpsEstimate = None

@property
Expand Down
2 changes: 1 addition & 1 deletion first_edition/chapter4/cameo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, capture, previewWindowManager = None,
self._videoWriter = None

self._startTime = None
self._framesElapsed = long(0)
self._framesElapsed = 0
self._fpsEstimate = None

@property
Expand Down
8 changes: 4 additions & 4 deletions first_edition/chapter4/cameo/trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ def update(self, image):
x, y, w, h = faceRect

# Seek an eye in the upper-left part of the face.
searchRect = (x+w/7, y, w*2/7, h/2)
searchRect = (x+w//7, y, w*2//7, h//2)
face.leftEyeRect = self._detectOneObject(
self._eyeClassifier, image, searchRect, 64)

# Seek an eye in the upper-right part of the face.
searchRect = (x+w*4/7, y, w*2/7, h/2)
searchRect = (x+w*4//7, y, w*2//7, h//2)
face.rightEyeRect = self._detectOneObject(
self._eyeClassifier, image, searchRect, 64)

# Seek a nose in the middle part of the face.
searchRect = (x+w/4, y+h/4, w/2, h/2)
searchRect = (x+w//4, y+h//4, w//2, h//2)
face.noseRect = self._detectOneObject(
self._noseClassifier, image, searchRect, 32)

# Seek a mouth in the lower-middle part of the face.
searchRect = (x+w/6, y+h*2/3, w*2/3, h/3)
searchRect = (x+w//6, y+h*2//3, w*2//3, h//3)
face.mouthRect = self._detectOneObject(
self._mouthClassifier, image, searchRect, 16)

Expand Down
2 changes: 1 addition & 1 deletion first_edition/chapter4/cameo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ def isGray(image):
def widthHeightDividedBy(image, divisor):
"""Return an image's dimensions, divided by a value."""
h, w = image.shape[:2]
return (w/divisor, h/divisor)
return (w//divisor, h//divisor)
2 changes: 1 addition & 1 deletion first_edition/chapter5/cameo/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, capture, previewWindowManager = None,
self._videoWriter = None

self._startTime = None
self._framesElapsed = long(0)
self._framesElapsed = 0
self._fpsEstimate = None

@property
Expand Down

0 comments on commit 50a7b60

Please sign in to comment.