Refectored Workspace
This commit is contained in:
@@ -28,15 +28,15 @@ ball = Ball()
|
||||
def Color_Detection(blue, green, red):
|
||||
if blue > 220 and green < 50 and red < 50:
|
||||
return 'Blue'
|
||||
if blue < 50 and green > 200 and red > 200:
|
||||
elif blue < 50 and green > 200 and red > 200:
|
||||
return 'Yellow'
|
||||
if blue > 200 and green < 50 and red > 200:
|
||||
elif blue > 200 and green < 50 and red > 200:
|
||||
return 'Purple'
|
||||
if blue < 50 and green > 220 and red < 50:
|
||||
elif blue < 50 and green > 220 and red < 50:
|
||||
return 'Green'
|
||||
if blue < 50 and green < 200 and red > 220:
|
||||
elif blue < 50 and green < 200 and red > 220:
|
||||
return 'Orange'
|
||||
return 'Unidentified'
|
||||
return f'Unidentified Color R:{red}, G:{green}, B:{blue}'
|
||||
|
||||
def IdentifyCircles(img, circle):
|
||||
global ball
|
||||
@@ -49,7 +49,6 @@ def IdentifyCircles(img, circle):
|
||||
robotList.append(Robot([x, y], color))
|
||||
elif color == 'Green' or color == 'Purple':
|
||||
robotMarks.append([x, y, color])
|
||||
print('ROBOT FOUND')
|
||||
elif color == 'Orange':
|
||||
ball = Ball([x, y])
|
||||
|
||||
@@ -76,8 +75,8 @@ def annotate_image(img):
|
||||
for robot in robotList:
|
||||
team_color = "B" if robot.team == 'Blue' else "Y"
|
||||
cv2.putText(img, f'{team_color}', (robot.pos[0] + 20, robot.pos[1] - 40), cv2.FONT_HERSHEY_SIMPLEX, .75, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(img, f'ID{robot.ID}', (robot.pos[0] + 20, robot.pos[1] - 20), cv2.FONT_HERSHEY_SIMPLEX, .75, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(img, f'{robot.pos}', (robot.pos[0] + 20, robot.pos[1]), cv2.FONT_HERSHEY_SIMPLEX, .75, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(img, f'\nID{robot.ID}', (robot.pos[0] + 20, robot.pos[1] - 20), cv2.FONT_HERSHEY_SIMPLEX, .75, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(img, f'{robot.pos }', (robot.pos[0] + 20, robot.pos[1]), cv2.FONT_HERSHEY_SIMPLEX, .75, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
|
||||
if ball:
|
||||
cv2.putText(img, f'Ball {ball.pos}', (ball.pos[0] + 20, ball.pos[1] + 20), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2, cv2.LINE_AA)
|
||||
@@ -92,7 +91,7 @@ def main():
|
||||
ball = None
|
||||
|
||||
# Load and process the video
|
||||
video_path = "/Users/mannpatel/Desktop/Project/Computer Vision/Test2.mp4"
|
||||
video_path = "/Users/mannpatel/Desktop/Robocup/Assets/Video/Test2.mp4"
|
||||
cap = cv2.VideoCapture(video_path)
|
||||
|
||||
while cap.isOpened():
|
||||
@@ -116,10 +115,10 @@ def main():
|
||||
|
||||
assignIDmarks()
|
||||
|
||||
for robot in robotList:
|
||||
print(f'There is a {robot.team} robot with these ID circles:')
|
||||
for mark in robot.circles:
|
||||
print(mark)
|
||||
# for robot in robotList:
|
||||
# print(f'There is a {robot.team} robot with these ID circles:')
|
||||
# for mark in robot.circles:
|
||||
# print(mark)
|
||||
|
||||
if ball:
|
||||
print(f'Ball found at {ball.pos}')
|
||||
|
||||
Reference in New Issue
Block a user