Add example of how to call the script to generate an annotated image

This commit is contained in:
GISDev01 2017-12-05 11:47:26 -05:00 committed by Brandon Amos
parent 563668586b
commit 80ca76eea5
1 changed files with 4 additions and 6 deletions

View File

@ -15,8 +15,7 @@
# limitations under the License. # limitations under the License.
# TODO: This file is incomplete. # Example usage: ./util/annotate-image.py /data/path_to_your_image.jpg outerEyesAndNose
import os import os
import sys import sys
@ -34,7 +33,7 @@ openfaceModelDir = os.path.join(modelDir, 'openface')
def main(args): def main(args):
align = NaiveDlib(args.dlibFacePredictor) align = AlignDlib(args.dlibFacePredictor)
bgrImg = cv2.imread(args.img) bgrImg = cv2.imread(args.img)
if bgrImg is None: if bgrImg is None:
@ -45,10 +44,9 @@ def main(args):
if bb is None: if bb is None:
raise Exception("Unable to find a face: {}".format(args.img)) raise Exception("Unable to find a face: {}".format(args.img))
landmarks = align.align(rgbImg, bb) landmarks = align.findLandmarks(rgbImg, bb)
if landmarks is None: if landmarks is None:
raise Exception("Unable to align image: {}".format(args.img)) raise Exception("Unable to find landmarks within image: {}".format(args.img))
# alignedFace = align.alignImg("affine", args.size, rgbImg, bb, landmarks)
bl = (bb.left(), bb.bottom()) bl = (bb.left(), bb.bottom())
tr = (bb.right(), bb.top()) tr = (bb.right(), bb.top())