2019-02-15 14:49:30 +00:00
|
|
|
import matplotlib.pyplot as pl
|
|
|
|
from matplotlib.patches import Rectangle
|
|
|
|
|
2019-03-11 14:24:29 +00:00
|
|
|
from find_targets import find_targets, normalize_coordinates
|
2019-02-15 14:49:30 +00:00
|
|
|
|
2019-03-11 14:24:29 +00:00
|
|
|
ax = pl.subplot(211)
|
2019-02-15 14:49:30 +00:00
|
|
|
img = pl.imread('image.jpeg')
|
|
|
|
|
|
|
|
|
|
|
|
H, L, R, objects = find_targets(img, return_slices=True)
|
|
|
|
|
|
|
|
for o in objects:
|
|
|
|
x, y = o
|
|
|
|
r = Rectangle((y.start, x.start), y.stop-y.start, x.stop-x.start, linewidth=1,edgecolor='r',facecolor='none')
|
|
|
|
ax.add_patch(r)
|
|
|
|
ax.imshow(img)
|
2019-03-11 14:24:29 +00:00
|
|
|
ax.plot([H[0], L[0], R[0]], [H[1], L[1], R[1]], 'o', color='red')
|
|
|
|
|
|
|
|
ax = pl.subplot(212)
|
|
|
|
|
|
|
|
w = len(img[0])
|
|
|
|
h = len(img)
|
|
|
|
|
|
|
|
H = normalize_coordinates(H, w, h)
|
|
|
|
L = normalize_coordinates(L, w, h)
|
|
|
|
R = normalize_coordinates(R, w, h)
|
|
|
|
ax.plot([H[0], L[0], R[0]], [H[1], L[1], R[1]], 'o', color='red')
|
|
|
|
ax.grid()
|
|
|
|
ax.set_title("Positions normalisées")
|
|
|
|
|
2019-02-15 14:49:30 +00:00
|
|
|
|
|
|
|
pl.show()
|