-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_features.py
More file actions
21 lines (19 loc) · 811 Bytes
/
extract_features.py
File metadata and controls
21 lines (19 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import argparse, cv2, pandas as pd
from pathlib import Path
from facial_compassion_project import extract_landmark_features
def main(images: Path, out: Path):
rows = []
for img_path in images.glob("*.[jp][pn]g"):
feats = extract_landmark_features(cv2.imread(str(img_path)))
if feats:
rows.append({"image_id": img_path.name, **feats.__dict__})
pd.DataFrame(rows).to_csv(out, index=False)
print(f"Wrote {len(rows)} rows to {out}")
if __name__ == "__main__":
p = argparse.ArgumentParser()
p.add_argument("--images", type=Path, required=True,
help="Folder with face images")
p.add_argument("--out", type=Path, required=True,
help="Destination CSV")
args = p.parse_args()
main(args.images, args.out)