Commit 884c0e35 authored by YvanM's avatar YvanM

Fix "--sortbycsv" option which was sorting by surname instead of name.

parent 4716f87f
...@@ -166,7 +166,9 @@ if args.crop: ...@@ -166,7 +166,9 @@ if args.crop:
"detected. The first one will be used, others are available " "detected. The first one will be used, others are available "
"in \"cropped\" directory") "in \"cropped\" directory")
for face_number,face in enumerate(faces): # from my tests, when multiple faces are detected, the last one is
# usually the good one, so we reverse the list
for face_number,face in enumerate(reversed(faces)):
# makes the square around face a bit bigger to ease recognition # makes the square around face a bit bigger to ease recognition
coordinates = enlargeFace(img.auto_orient().get_size(), face) coordinates = enlargeFace(img.auto_orient().get_size(), face)
...@@ -212,6 +214,7 @@ if args.names: ...@@ -212,6 +214,7 @@ if args.names:
if len(line) == 3 and line[2] == "NOPIC": if len(line) == 3 and line[2] == "NOPIC":
missingPics.append(lineNumber) missingPics.append(lineNumber)
# eventually insert avatar in place of missing pictures # eventually insert avatar in place of missing pictures
for index in missingPics: for index in missingPics:
picsList.insert(index, defaultPic) picsList.insert(index, defaultPic)
...@@ -248,9 +251,7 @@ with tempfile.TemporaryDirectory() as tempDir: ...@@ -248,9 +251,7 @@ with tempfile.TemporaryDirectory() as tempDir:
cmd.append(picsList[i]) cmd.append(picsList[i])
else: else:
# or sorted using surnames in CSV # or sorted using surnames in CSV
print("namesList: " + str(namesList)) order = sorted(range(len(namesList)), key=lambda k: namesList[k].split("\n",1)[1])
order = sorted(range(len(namesList)), key=lambda k: namesList[k])
print("order: " + str(order))
for i in order: for i in order:
cmd.append("-label") cmd.append("-label")
cmd.append(namesList[i]) cmd.append(namesList[i])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment