Changeset - 9c78e6f2e2ea
[Not reviewed]
default
0 2 0
Laman - 6 years ago 2019-05-14 10:28:31

fixed data generation, color sampler showing filename
2 files changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
exp/color_sampler.py
Show inline comments
 
@@ -45,13 +45,15 @@ class Sampler:
 
		self.colorLabel.configure(text="HSV: ({0}, {1}, {2})".format(round(h*360),s,v))
 

	
 
	def printSample(self):
 
		print("\t".join(map(str, (self.filenames[self.k],*self.pos,self.letter,*self.hsv))))
 

	
 
	def showImage(self):
 
		self.img=Image.open(os.path.join(self.dirname,self.filenames[self.k]))
 
		filename=self.filenames[self.k]
 
		self.img=Image.open(os.path.join(self.dirname,filename))
 
		self.root.title(filename)
 
		(w,h)=self.img.size
 
		self.photo=ImageTk.PhotoImage(self.img)
 
		self.canvas.delete("all")
 
		self.canvas.create_image(0,0,image=self.photo,anchor="nw")
 
		self.canvas.configure(width=w,height=h)
 

	
 
@@ -107,13 +109,13 @@ class Sampler:
 
			self._dirty=False
 

	
 
	def _flush(self):
 
		self.annotations[self.filename]=[b for b in self._boards if not b.isEmpty()]
 

	
 
	def _createGUI(self):
 
		root=tk.Tk()
 
		self.root=root=tk.Tk()
 
		frame=tk.Frame(root)
 
		frame.grid(column=0,row=0,sticky=(N,S,E,W))
 

	
 
		self.canvas=tk.Canvas(frame)
 
		self.canvas.grid(row=1,column=0)
 

	
exp/kerokero/prepare_data.py
Show inline comments
 
import os
 
import sys
 
import re
 
import random
 
import itertools
 

	
 
import numpy as np
 
import cv2 as cv
 

	
 
sys.path.append("..")
 
sys.path.append("../../src")
 
@@ -37,13 +36,13 @@ class Sample:
 
		for mi in [t1,mir,proj,rot]:
 
			m=np.matmul(mi,m)
 
		m=np.matmul(self._computeCrop(m),m)
 
		img=cv.warpPerspective(self.img,m,(self.SIDE,self.SIDE))
 
		img=np.float32(img)/128-1
 
		grid=Corners(c.transform(m) for c in self.grid)
 
		grid=list(map(lambda p: 2*p/self.SIDE-EPoint(1,1), grid))
 
		grid=list(map(lambda p: list(2*p/self.SIDE-EPoint(1,1)), grid))
 
		return (img,grid)
 

	
 
	def _getCenter(self):
 
		(a,b,c,d)=self.grid
 
		p=Line.fromPoints(a,c)
 
		q=Line.fromPoints(b,d)
0 comments (0 inline, 0 general)