diff --git a/exp/kerokero/prepare_data.py b/exp/kerokero/prepare_data.py --- a/exp/kerokero/prepare_data.py +++ b/exp/kerokero/prepare_data.py @@ -2,19 +2,25 @@ import os import sys import re import random +import logging as log import numpy as np import cv2 as cv +import config as cfg sys.path.append("..") sys.path.append("../../src") -from annotations import DataFile,computeBoundingBox,Corners,EPoint +from annotations import DataFile,computeBoundingBox,Corners,EPoint,Board from geometry import Line from kerokero.transformation_matrices import getIdentity,getRotation,getTranslation,getScale,getMirroring,getProjection random.seed(361) +class Stats: + counts=[0,0,0,0] + + class Sample: SIDE=224 @@ -61,6 +67,7 @@ class Sample: img=cv.cvtColor(self.img,cv.COLOR_GRAY2BGR) for c in self.grid: cv.circle(img,(int(c.x),int(c.y)),3,[0,255,0],-1) + img=cv.resize(img,(self.SIDE*2,self.SIDE*2)) show(img) @@ -70,7 +77,7 @@ def traverseDirs(root): d=stack.pop() contents=sorted(os.scandir(d),key=lambda f: f.name,reverse=True) if any(f.name=="annotations.json.gz" for f in contents): - print(d) + log.info(d) yield d for f in contents: if f.is_dir(): stack.append(f.path) @@ -82,6 +89,9 @@ def harvestDir(path): files=sorted(filter(imgFilter,os.scandir(path)),key=lambda f: f.name) boards=annotations["."] for f in files: + grade=annotations.get(f.name,[Board()])[0].grade + Stats.counts[grade]+=1 + if not Board.UNSET