Last active
August 28, 2022 21:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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