This commit is contained in:
2024-02-21 12:13:27 +01:00
parent 6cbf1bcbf2
commit 9144c5b231
2 changed files with 22 additions and 12 deletions
+12 -6
View File
@@ -156,11 +156,15 @@ class tutel():
#x and y are swapped, because
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
else: x = (self.top_right[0],self.top_left[0])
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
else: y = (self.bottom_left[1],self.top_left[1])
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
else: x = (self.top_left[0],self.bottom_left[0])
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
else: y = (self.bottom_right[1],self.bottom_left[1])
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
depth_values = []
for i in range(x[0], x[1]):
@@ -168,13 +172,15 @@ class tutel():
if depth_image[j][i] > self.maxMinDepth:
depth_values.append(depth_image[j][i])
for k in depth_values:
#print(str(max(depth_values)) + " !!!!!!!!!!!!!!!!!!!")
if k > (max(depth_values) - 10):
#print("hello world!")
self.last_depth += k
self.number_of_operations += 1
self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
self.last_depth = [0, self.last_depth/self.number_of_operations][self.number_of_operations > 0]
print(self.depth_counter, self.last_depth, self.number_of_operations)
self.number_of_operations = 0
cv2.imshow("Tutel_Depth", depth_image)
#cv2.imshow("Tutel_Depth", depth_image)
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
self.depth_counter += 1
if self.depth_counter > 0:
+10 -6
View File
@@ -156,20 +156,24 @@ class tutel():
#x and y are swapped, because
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
else: x = (self.top_right[0],self.top_left[0])
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
else: y = (self.bottom_left[1],self.top_left[1])
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
else: x = (self.top_left[0],self.bottom_left[0])
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
else: y = (self.bottom_right[1],self.bottom_left[1])
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
depth_values = []
for i in range(x[0], x[1]):
for j in range(y[0], y[1]):
if depth_image[j][i] > self.maxMinDepth:
if depth_image[j][i] > 100:
depth_values.append(depth_image[j][i])
self.last_depth = max(depth_values)
print(self.depth_counter, self.last_depth)
cv2.imshow("Tutel_Depth", depth_image)
#cv2.imshow("Tutel_Depth", depth_image)
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
self.depth_counter += 1
if self.depth_counter > 0: