drone-rigide/workspace/src/detect_targets/scripts/test_find_targets.py

20 lines
484 B
Python
Raw Normal View History

2019-02-15 14:49:30 +00:00
import matplotlib.pyplot as pl
from matplotlib.patches import Rectangle
from find_targets import find_targets
fig, ax = pl.subplots(1)
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)
ax.plot([H[1], L[1], R[1]], [H[0], L[0], R[0]], 'o', color='red')
pl.show()