2018-04-26 11:12:51 +00:00
|
|
|
import helpers
|
|
|
|
import numpy as np
|
|
|
|
import pickle
|
2018-04-29 13:09:15 +00:00
|
|
|
import random
|
|
|
|
from PIL import Image, ImageDraw,ImageTk
|
|
|
|
import pandas as pd
|
|
|
|
import seaborn as sns
|
|
|
|
import time
|
|
|
|
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
|
|
|
from matplotlib.figure import Figure
|
|
|
|
import sys
|
|
|
|
if sys.version_info[0] < 3:
|
|
|
|
import Tkinter as Tk
|
|
|
|
else:
|
|
|
|
import tkinter as Tk
|
2018-04-26 11:12:51 +00:00
|
|
|
|
|
|
|
screenDrawCorners = np.array([[10,60], [90, 60], [10, 110], [90, 110]])
|
|
|
|
coordinates = pickle.load(open("coordinates.p", "rb"))
|
|
|
|
print("Loaded coordinates: %s", helpers.coordinatesToSrc(coordinates))
|
|
|
|
print("Corners: %s", screenDrawCorners)
|
|
|
|
|
|
|
|
transform = helpers.create_perspective_transform(helpers.coordinatesToSrc(coordinates), screenDrawCorners)
|
|
|
|
|
|
|
|
a = [np.array([ 1312.15541183]), np.array([ 244.56278002])]
|
|
|
|
midpointTop = (coordinates['tr'] - coordinates['tl'])/2 + coordinates['tl']
|
|
|
|
midpointCenter = (coordinates['tr'] - coordinates['bl'])/2 + coordinates['bl']
|
|
|
|
print("Test point %s", a)
|
|
|
|
print("Transformed point %s", transform(a))
|
|
|
|
print("Test point %s", midpointTop )
|
|
|
|
print("Transformed point %s", transform(midpointTop))
|
|
|
|
print("Test point %s", midpointCenter )
|
2018-04-29 13:09:15 +00:00
|
|
|
print("Transformed point %s", transform(midpointCenter))
|
|
|
|
|
|
|
|
|
|
|
|
windowRoot = Tk.Tk()
|
|
|
|
windowSize = (1000,1000)
|
|
|
|
windowRoot.geometry('%dx%d+%d+%d' % (windowSize[0],windowSize[1],0,0))
|
|
|
|
figure = Figure(figsize=(16, 9), dpi=100)
|
|
|
|
t = np.arange(0.0, 3.0, 0.01)
|
|
|
|
s = np.sin(2*np.pi*t)
|
|
|
|
|
|
|
|
d = {'col1': [1, 2,4], 'col2': [3, 4,9]}
|
|
|
|
dataframe = pd.DataFrame(data=d)
|
|
|
|
print(dataframe['col1'])
|
|
|
|
a = figure.add_subplot(111)
|
|
|
|
# a = sns.jointplot(x="col1", y="col2", data=dataframe, kind="kde")
|
|
|
|
# g = sns.jointplot(x="col1", y="col2", data=dataframe, kind="kde")
|
|
|
|
# g = sns.JointGrid(x="col1", y="col2", data=dataframe)
|
|
|
|
|
|
|
|
|
|
|
|
a.set_title('Tk embedding')
|
|
|
|
a.set_xlabel('X axis label')
|
|
|
|
a.set_ylabel('Y label')
|
|
|
|
# canvas = Tk.Canvas(windowRoot,width=1000,height=1000)
|
|
|
|
canvas = FigureCanvasTkAgg(figure,master=windowRoot)
|
|
|
|
canvas.show()
|
|
|
|
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
|
|
|
|
|
|
|
|
for b in range(0,1000):
|
|
|
|
dataframe = dataframe.append({'col1':b,'col2':random.random()*100}, ignore_index=True)
|
|
|
|
a.clear()
|
|
|
|
# g.fig =
|
|
|
|
# a.plot(t*b, s)
|
|
|
|
# g = sns.jointplot(x="col1", y="col2", data=dataframe, kind="kde", size=1000)
|
|
|
|
# g = sns.kdeplot(dataframe['col1'], dataframe['col2'],ax=a, n_levels=30, shade=True, cmap="hsv")
|
|
|
|
g = sns.kdeplot(dataframe['col1'], dataframe['col2'],ax=a, n_levels=30, shade=True, cmap="rainbow")
|
|
|
|
# print(g, g.fig)
|
|
|
|
# g = g.plot_joint(sns.kdeplot, cmap="Blues_d")
|
|
|
|
# print(g.fig)
|
|
|
|
# canvas.figure = g.figure
|
|
|
|
canvas.draw()
|
|
|
|
windowRoot.update()
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
# Tk.mainloop()
|