Skip to content

Commit 990b9a9

Browse files
committed
Created lines for detection
1 parent 52edf7e commit 990b9a9

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
246 Bytes
Binary file not shown.

scripts/detect-trees.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@
4949
line_end = (800, 500)
5050

5151
line_color = (255, 0, 0)
52+
alt_line_color = (0, 0, 255)
5253
line_thickness = 2
5354
#---------------------------------------------------------
5455

56+
# Global variable to count trees -------------------------
57+
treeNum = 0
58+
#---------------------------------------------------------
59+
5560
# Load the network----------------------------------------
5661
#net = cv2.dnn.readNetFromDarknet(config, weights)
5762
net = cv2.dnn.readNetFromDarknet(config, weights)
@@ -114,8 +119,13 @@
114119
c_x, c_y = c[0], c[1]
115120
cv2.circle(img, (c_x, c_y), radius=2, color=(0, 255, 255), thickness=2)
116121
cv2.line(img, line_start, line_end, line_color, line_thickness)
117-
cv2.putText(img, str(i), (100, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (128, 120, 68), 2)
118122

123+
#if(c_y > 500):
124+
# treeNum = treeNum + 1
125+
126+
#cv2.putText(img, str(treeNum), (100, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (128, 120, 68), 2)
127+
128+
cv2.line(img, (c_x, c_y), (c_x, 500), alt_line_color, line_thickness)
119129
# Display the resulting frame
120130
cv2.imshow('image',img)
121131
out.write(img)

scripts/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
def get_centroid(x1, y1, x2, y2):
22
return int((x1+x2)/2) ,int((y1 + y2)/2)
3+
4+
def is_lower_than_line(l_start_x, l_start_y, l_end_x, l_end_y, pt_x, pt_y):
5+
d = ((pt_x - l_start_x)*(l_end_y - l_start_y)) - ((pt_y - l_start_y)*(l_end_x - l_start_x))
6+
if d < 0:
7+
return 0
8+
9+
elif d == 0:
10+
return 1
11+
12+
else :
13+
return 2

0 commit comments

Comments
 (0)