Changeset - 79c410b194c6
[Not reviewed]
default
0 1 0
Laman - 6 years ago 2018-12-20 22:03:39

sampler takes command line arguments
1 file changed with 10 insertions and 4 deletions:
0 comments (0 inline, 0 general)
exp/color_sampler.py
Show inline comments
 
@@ -12,17 +12,21 @@ from colorsys import rgb_to_hsv
 
from PIL import Image,ImageTk
 

	
 
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
 
		self.photo=None
 

	
 
		self.letter="_"
 
@@ -126,12 +130,13 @@ class Sampler:
 
			self.canvas.create_line(b.x,b.y,c.x,c.y,fill="#00ff00",tags="mark")
 
			self.canvas.create_line(c.x,c.y,d.x,d.y,fill="#00ff00",tags="mark")
 
			self.canvas.create_line(d.x,d.y,a.x,a.y,fill="#00ff00",tags="mark")
 

	
 

	
 
class DataFile(MutableMapping):
 
	"""self._data: {filename: [EPoint,EPoint,EPoint,EPoint]}"""
 
	def __init__(self,filename):
 
		self.filename=filename
 
		try:
 
			with gzip.open(filename,mode="rt",encoding="utf8") as f:
 
				self._data=json.load(f,object_hook=self.deserialize)
 
		except OSError:
 
@@ -154,7 +159,8 @@ class DataFile(MutableMapping):
 
	def __setitem__(self, key, val): self._data[key]=val
 
	def __delitem__(self, key): del self._data[key]
 
	def __iter__(self): return iter(self._data)
 
	def __len__(self): return len(self._data)
 

	
 

	
 
s=Sampler()
 
if __name__=="__main__":
 
	s=Sampler()
0 comments (0 inline, 0 general)