Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modularity approach added #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 44 additions & 40 deletions ArucoGeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,49 @@
import cv2
import numpy as np

# Define marker size and dictionary
aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)
# It allows for a maximum of 250 markers. The 6x6 refers to the size of the individual markers in terms of bits.

marker_size = 200
# Aruco marker size of 200 pixel

# Create an image to draw the ArUco markers
image_size = 800
image = np.ones((image_size, image_size, 3), dtype=np.uint8) * 255
# 3 represents three color channel BGR
# Setting all pixel values to 255 results in white color

positions = {
0: (100, 100),
1: (image_size - 100, 100),
2: (image_size - 100, image_size - 100),
3: (100, image_size - 100),
4: (200, 200),
5: (600, 600),
6: (300, 300),
7: (400, 400),
8: (500, 300),
9: (300, 500),
10: (600, 200),
11: (200, 600),
# marker_id: position includes (x,y) coordinates
}

for marker_id, position in positions.items():
marker_image = cv2.aruco.drawMarker(aruco_dict, marker_id, marker_size)
# x, y = position
def aruco_marker_generator(marker_id, marker_size):

# Ensure marker fits within canvas boundaries
# Assign the marker to the corresponding section in the image
image = cv2.cvtColor(marker_image, cv2.COLOR_GRAY2BGR)
cv2.imwrite("images/Aurco/Aurco_{}.png".format(str(marker_id)), image)
cv2.imshow(str(marker_id), image)
# Define marker size and dictionary
# It allows for a maximum of 250 markers. The 6x6 refers to the size of the individual markers in terms of bits.
aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)

# Display the generated ArUco markers
cv2.waitKey(0)
cv2.destroyAllWindows()
# Generate aruco marker
marker_image = cv2.aruco.drawMarker(aruco_dict, marker_id, marker_size)
# Assign the marker to the corresponding section in the image
marker_image = cv2.cvtColor(marker_image, cv2.COLOR_GRAY2BGR)
return marker_image

if __name__== "__main__" :
marker_size = 200
# Aruco marker size of 200 pixel

# Create an image to draw the ArUco markers
image_size = 800
image = np.ones((image_size, image_size, 3), dtype=np.uint8) * 255
# 3 represents three color channel BGR
# Setting all pixel values to 255 results in white color

positions = {
0: (100, 100),
1: (image_size - 100, 100),
2: (image_size - 100, image_size - 100),
3: (100, image_size - 100),
4: (200, 200),
5: (600, 600),
6: (300, 300),
7: (400, 400),
8: (500, 300),
9: (300, 500),
10: (600, 200),
11: (200, 600),
# marker_id: position includes (x,y) coordinates
}

for marker_id, position in positions.items():
marker_iamge = aruco_marker_generator(marker_id, marker_size)
cv2.imwrite("images/Aurco/Aurco_{}.png".format(str(marker_id)), marker_iamge)
cv2.imshow(str(marker_id), marker_iamge)

# Display the generated ArUco markers
cv2.waitKey(0)
cv2.destroyAllWindows()
13 changes: 5 additions & 8 deletions Board_Placement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cv2
import numpy as np
from ArucoGeneration import aruco_marker_generator

# Create an image to place ArUco markers
aurco_size = 50 # also equals grid size in px
Expand All @@ -9,12 +10,7 @@
canvas = np.ones((image_size, image_size, 3), dtype=np.uint8) * 255
# canvas size of 1100*1100 px

# Aruco marker generation
def generate_aruco_image(marker_id, marker_size=50):
aruco_dict = cv2.aruco.Dictionary_get(cv2.aruco.DICT_6X6_250)
marker_image = cv2.aruco.drawMarker(aruco_dict, marker_id, marker_size)
marker_image_bgr = cv2.cvtColor(marker_image, cv2.COLOR_GRAY2BGR)
return marker_image_bgr


# Positions for markers 0-3 from top-left to bottom-right corners and waste collection 4 & 5
positions = {
Expand All @@ -28,7 +24,8 @@ def generate_aruco_image(marker_id, marker_size=50):

# Generate markers with IDs 0-5 and place them on the canvas
for marker_id, position in positions.items():
marker = generate_aruco_image(marker_id)
# Aruco marker generation
marker = aruco_marker_generator(marker_id, marker_size=50)
x, y = position
canvas[y:y + 50, x:x + 50] = marker

Expand All @@ -55,7 +52,7 @@ def generate_aruco_image(marker_id, marker_size=50):
# Generate markers with IDs 6 - 9 and place them in playable grid
for marker_id, positions_list in positions_bot_waste_y.items():
for position in positions_list:
marker = generate_aruco_image(marker_id)
marker = aruco_marker_generator(marker_id ,marker_size=50)
x, y = position
canvas[y:y + aurco_size, x:x + aurco_size] = marker

Expand Down
Binary file added __pycache__/ArucoGeneration.cpython-312.pyc
Binary file not shown.