# HG changeset patch # User Laman # Date 2018-12-20 22:03:39 # Node ID 79c410b194c6b70822123d14fe9c3b4c2dcce823 # Parent 1d1fd2ae49bff0276322d521a98794d1497a167c sampler takes command line arguments diff --git a/exp/color_sampler.py b/exp/color_sampler.py --- a/exp/color_sampler.py +++ b/exp/color_sampler.py @@ -15,11 +15,15 @@ from analyzer.epoint import EPoint from analyzer.corners import Corners +dirname=sys.argv[1] +annotations=sys.argv[2] + + class Sampler: def __init__(self): - self.dirname="../images" - self.annotations=DataFile("annotations.json.gz") - self.filenames=[f for f in os.listdir(self.dirname) if f.endswith(".jpg")] + self.dirname=dirname + self.annotations=DataFile(annotations) + self.filenames=[f for f in sorted(os.listdir(self.dirname)) if f.endswith(".jpg")] self.k=0 self.img=None @@ -129,6 +133,7 @@ class Sampler: class DataFile(MutableMapping): + """self._data: {filename: [EPoint,EPoint,EPoint,EPoint]}""" def __init__(self,filename): self.filename=filename try: @@ -157,4 +162,5 @@ class DataFile(MutableMapping): def __len__(self): return len(self._data) -s=Sampler() +if __name__=="__main__": + s=Sampler()