Skip to content

Commit

Permalink
Add eccentricity and angle computation
Browse files Browse the repository at this point in the history
  • Loading branch information
uba committed Oct 29, 2024
1 parent 59f5264 commit 67e38dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/gallery/plot_fit-ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def plot(geoms):
plt.show()

geom = EXAMPLE_GEOMETRY
ellipse = fitEllipse(geom)

ellipse, eccentricity, theta = fitEllipse(geom)
print('Eccentricity {} and Angle {}'.format(eccentricity, theta))
plot([geom, ellipse])
8 changes: 7 additions & 1 deletion tathu/geometry/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,13 @@ def fitEllipse(polygon):
# Fit ellipse
(xc,yc), (a,b), theta = cv2.fitEllipse(coords)

return ellipse2polygon(xc, yc, a * 0.5, b * 0.5, -theta)
# Compute eccentricity
major_ax, minor_ax = a, b
if a < b: major_ax, minor_ax = b, a
eccentricity = np.sqrt(1 - ((minor_ax * minor_ax)/(major_ax * major_ax)))

return ellipse2polygon(xc, yc, a * 0.5, b * 0.5, -theta), eccentricity, theta


def getRadiusFromCircle(polygon):
# Extract coordinates to NumpyArray in order to user opencv2.minEnclosingCircle
Expand Down
13 changes: 12 additions & 1 deletion tathu/tracking/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,15 @@ def describe(self, image, systems):
# v component
descriptor = StatisticalDescriptor(stats=['mean'], prefix='v_')
descriptor.describe(v, systems)


class MaxValueGeolocationDescriptor():
'''
This class implements a descriptor that calculates geolocation
(i.e. latitude and longitude coordinates) of the maximum value
found within the system boundaries.
'''
def __init__(self):
pass

def describe(self, image, systems):
pass

0 comments on commit 67e38dd

Please sign in to comment.