- workaround number of Ids must be known prior board generation
This commit is contained in:
@@ -14,20 +14,31 @@ class BoardDetector(abc.ABC):
|
|||||||
t_vecs = None
|
t_vecs = None
|
||||||
obj_points_list = []
|
obj_points_list = []
|
||||||
img_points_list = []
|
img_points_list = []
|
||||||
|
rs = None
|
||||||
|
board_id = None
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def __init__(self, name: str, board_id: str, n_syms: int):
|
def __init__(self, name: str, board_id: str, n_syms: int):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
self.board_id = board_id
|
||||||
msg_size = len(board_id)
|
msg_size = len(board_id)
|
||||||
n_rs = n_syms - msg_size
|
n_rs = n_syms - msg_size
|
||||||
rs = RSCodec(n_rs, c_exp=7)
|
self.rs = RSCodec(n_rs, c_exp=7)
|
||||||
|
|
||||||
msg = bytes(f"{board_id}", 'utf-8')
|
msg = bytes(f"{board_id}", 'utf-8')
|
||||||
byte_string = rs.encode(msg)
|
byte_string = self.rs.encode(msg)
|
||||||
self.ids = np.array([x for x in byte_string])
|
self.ids = np.array([x for x in byte_string])
|
||||||
print(f"{name}: markers: {self.ids}")
|
print(f"{name}: markers: {self.ids}")
|
||||||
|
|
||||||
|
def decode(self, ids: np.array):
|
||||||
|
print(ids)
|
||||||
|
try:
|
||||||
|
msg = self.rs.decode(ids)
|
||||||
|
return msg[0:len(self.board_id)]
|
||||||
|
except ReedSolomonError:
|
||||||
|
return None
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def get_board_name(self) -> str:
|
def get_board_name(self) -> str:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user