Skip to content

Instantly share code, notes, and snippets.

@czming
Last active August 28, 2022 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czming/b5a8652d145a695ba463c941cdcea384 to your computer and use it in GitHub Desktop.
Save czming/b5a8652d145a695ba463c941cdcea384 to your computer and use it in GitHub Desktop.
Converts the sparse vector of aruco markers to a single integer representing pick markers - place markers #aits
# pick bin dimensions in the vector [aruco_marker[:72], color_bins[72:92], optical_flow_avg[92:94], hand_loc[94:96]]
pick_bins = [i for i in range(24 * 2)]
place_bins = [i for i in range(24 * 2, 36 * 2)]
for i in range(1,41):
with open(f"htk_inputs_aruco/picklist_{i}.txt") as infile:
infile = infile.readlines()
for line in infile:
line = line.split()
aruco_markers = line[:72]
aruco_pick_place_counter = 0
for x_index in range(0, 72, 2):
x = float(aruco_markers[x_index])
if x != 0:
if x_index in pick_bins:
# +1 for pick bin
aruco_pick_place_counter += 1
if x_index in place_bins:
# -1 for place bin
aruco_pick_place_counter -= 1
new_line = [str(aruco_pick_place_counter)] + line[72:]
with open(f"htk_inputs_aruco/picklist_{i}_binned_aruco.txt", "a") as outfile:
outfile.write(" ".join(new_line))
outfile.write("\n")
print (f"picklist_{i}.txt")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment