re-implement equipment with masks
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/venv/
|
||||||
@@ -20,7 +20,7 @@ HSV_DEFAULT = HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0)
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
EMITTER_TO_USE = EMITTER_RING
|
EMITTER_TO_USE = EMITTER_STAFF
|
||||||
SPAWN_COUNT = 15
|
SPAWN_COUNT = 15
|
||||||
# initialize the user-class
|
# initialize the user-class
|
||||||
config = UserConfigs()
|
config = UserConfigs()
|
||||||
|
|||||||
18
vision.py
18
vision.py
@@ -41,10 +41,22 @@ class Vision:
|
|||||||
idx_1d = np.argpartition(result.flatten(), -find_num)[-find_num:]
|
idx_1d = np.argpartition(result.flatten(), -find_num)[-find_num:]
|
||||||
idx_2d = np.unravel_index(idx_1d, result.shape)
|
idx_2d = np.unravel_index(idx_1d, result.shape)
|
||||||
|
|
||||||
rectangles = []
|
tresh_coord = []
|
||||||
for i in range(0, len(idx_2d[0]), 1):
|
for i in range(0, len(idx_2d[0]), 1):
|
||||||
y = int(idx_2d[0][i])
|
y = int(idx_2d[0][i])
|
||||||
x = int(idx_2d[1][i])
|
x = int(idx_2d[1][i])
|
||||||
|
res1 = result[y][x]
|
||||||
|
tresh_coord.append([res1, [y, x]])
|
||||||
|
|
||||||
|
tresh_coord.sort(reverse=True)
|
||||||
|
|
||||||
|
rectangles = []
|
||||||
|
for tc in tresh_coord:
|
||||||
|
y = int(tc[1][0])
|
||||||
|
x = int(tc[1][1])
|
||||||
|
#for i in range(0, len(idx_2d[0]), 1):
|
||||||
|
#y = int(idx_2d[0][i])
|
||||||
|
#x = int(idx_2d[1][i])
|
||||||
rect = [x, y, needle_w, needle_h]
|
rect = [x, y, needle_w, needle_h]
|
||||||
# Add every box to the list twice in order to retain single (non-overlapping) boxes
|
# Add every box to the list twice in order to retain single (non-overlapping) boxes
|
||||||
rectangles.append(rect)
|
rectangles.append(rect)
|
||||||
@@ -64,8 +76,10 @@ class Vision:
|
|||||||
#screenshot_pos_img = self.draw_rectangles(screenshot_pos, rectangles)
|
#screenshot_pos_img = self.draw_rectangles(screenshot_pos, rectangles)
|
||||||
#cv.imshow("screenshot_pos", screenshot_pos)
|
#cv.imshow("screenshot_pos", screenshot_pos)
|
||||||
#cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
if _maxVal2 >= 0.9:
|
if _maxVal2 >= 0.85:
|
||||||
keep_rects.append(rect)
|
keep_rects.append(rect)
|
||||||
|
if len(keep_rects) >= 5:
|
||||||
|
return keep_rects
|
||||||
|
|
||||||
if len(keep_rects) > max_results:
|
if len(keep_rects) > max_results:
|
||||||
keep_rects = keep_rects[:max_results]
|
keep_rects = keep_rects[:max_results]
|
||||||
|
|||||||
Reference in New Issue
Block a user