Spaces:
Running
Running
turhancan97
commited on
Commit
•
fd97df3
1
Parent(s):
ad37bfd
parameters change
Browse files
app.py
CHANGED
@@ -17,16 +17,16 @@ def drawAxis(img, p_, q_, color, scale):
|
|
17 |
# Here we lengthen the arrow by a factor of scale
|
18 |
q[0] = p[0] - scale * hypotenuse/3 * cos(angle)
|
19 |
q[1] = p[1] - scale * hypotenuse/3 * sin(angle)
|
20 |
-
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color,
|
21 |
|
22 |
# create the arrow hooks
|
23 |
p[0] = q[0] + 9 * cos(angle + pi / 4)
|
24 |
p[1] = q[1] + 9 * sin(angle + pi / 4)
|
25 |
-
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color,
|
26 |
|
27 |
p[0] = q[0] + 9 * cos(angle - pi / 4)
|
28 |
p[1] = q[1] + 9 * sin(angle - pi / 4)
|
29 |
-
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color,
|
30 |
## [visualization1]
|
31 |
|
32 |
|
@@ -49,11 +49,11 @@ def getOrientation(pts, img):
|
|
49 |
|
50 |
## [visualization]
|
51 |
# Draw the principal components
|
52 |
-
cv2.circle(img, cntr, 3, (255, 0, 255),
|
53 |
p1 = (cntr[0] + 0.02 * eigenvectors[0,0] * eigenvalues[0,0], cntr[1] + 0.02 * eigenvectors[0,1] * eigenvalues[0,0])
|
54 |
p2 = (cntr[0] - 0.02 * eigenvectors[1,0] * eigenvalues[1,0], cntr[1] - 0.02 * eigenvectors[1,1] * eigenvalues[1,0])
|
55 |
-
drawAxis(img, cntr, p1, (
|
56 |
-
drawAxis(img, cntr, p2, (
|
57 |
|
58 |
angle = atan2(eigenvectors[0,1], eigenvectors[0,0]) # orientation in radians
|
59 |
## [visualization]
|
|
|
17 |
# Here we lengthen the arrow by a factor of scale
|
18 |
q[0] = p[0] - scale * hypotenuse/3 * cos(angle)
|
19 |
q[1] = p[1] - scale * hypotenuse/3 * sin(angle)
|
20 |
+
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color, 3, cv2.LINE_AA)
|
21 |
|
22 |
# create the arrow hooks
|
23 |
p[0] = q[0] + 9 * cos(angle + pi / 4)
|
24 |
p[1] = q[1] + 9 * sin(angle + pi / 4)
|
25 |
+
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color, 3, cv2.LINE_AA)
|
26 |
|
27 |
p[0] = q[0] + 9 * cos(angle - pi / 4)
|
28 |
p[1] = q[1] + 9 * sin(angle - pi / 4)
|
29 |
+
cv2.line(img, (int(p[0]), int(p[1])), (int(q[0]), int(q[1])), color, 3, cv2.LINE_AA)
|
30 |
## [visualization1]
|
31 |
|
32 |
|
|
|
49 |
|
50 |
## [visualization]
|
51 |
# Draw the principal components
|
52 |
+
cv2.circle(img, cntr, 3, (255, 0, 255), 10)
|
53 |
p1 = (cntr[0] + 0.02 * eigenvectors[0,0] * eigenvalues[0,0], cntr[1] + 0.02 * eigenvectors[0,1] * eigenvalues[0,0])
|
54 |
p2 = (cntr[0] - 0.02 * eigenvectors[1,0] * eigenvalues[1,0], cntr[1] - 0.02 * eigenvectors[1,1] * eigenvalues[1,0])
|
55 |
+
drawAxis(img, cntr, p1, (255, 255, 0), 1)
|
56 |
+
drawAxis(img, cntr, p2, (255, 255, 0), 4)
|
57 |
|
58 |
angle = atan2(eigenvectors[0,1], eigenvectors[0,0]) # orientation in radians
|
59 |
## [visualization]
|