unsigned int distance(std::vector<bool> &v1, const std::vector<bool> &v2);
void read_words_from_file(char const *filename, std::vector<std::vector<bool>> &symbol);
void retrieve_codewords(std::vector<std::vector<bool>> &symbol, std::vector<bool> &codewords, bool is_upwards, std::size_t row, std::size_t col);
+void retrieve_special_codewords(std::vector<std::vector<bool>> &symbol, std::vector<bool> &codewords, bool is_upwards, int row, int col);
std::vector<bool> get_format_info(std::vector<std::vector<bool>> &symbol);
void decode_mask(std::vector<std::vector<bool>> &symbol, std::size_t mask_pattern);
}
}
}
+
void retrieve_codewords(std::vector<std::vector<bool>> &symbol, std::vector<bool> &codewords, bool is_upwards, int row, int col){
if (is_upwards){
for (int r{row + 3}; r >= row; --r){
}
}
}
+
void retrieve_special_codewords(std::vector<std::vector<bool>> &symbol, std::vector<bool> &codewords, bool is_upwards, int row, int col){
if (is_upwards){
- for (int r{row + 3}; r >= row; --r){
+ for (int r{row + 4}; r >= row; --r){
for (int c{col + 1}; c >= col; --c){
+ if (r == 6){continue;}
//std::cout << r << ' ' << c << std::endl;
codewords.push_back(symbol[r][c]);
}
}
}
else {
- for (int r{row}; r <= row + 3; ++r){
+ for (int r{row}; r <= row + 4; ++r){
for (int c{col + 1}; c >= col; --c){
+ if (r == 6){continue;}
//std::cout << r << ' ' << c << std::endl;
codewords.push_back(symbol[r][c]);
}
}
}
}
-
+
std::vector<bool> get_codewords_from_symbol(std::vector<std::vector<bool>> &symbol){
std::vector<bool> codewords{};
int c{}, r{};
for (r = 17;r >= 21 - 3 * 4;r-=4){
retrieve_codewords(symbol, codewords, true, r, c);
}
- std::cout << r << ' ' << c << std::endl;
-/*
- // up special
- std::vector<bool> character_symbol_special1(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_special1) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_up_special(grid, x, y, character_symbol_special1);
+ //std::cout << r << ' ' << c << std::endl;
+ // up special
+ r = 4;
+ retrieve_special_codewords(symbol, codewords, true, r, c);
- y = 0;
- std::vector<bool> character_symbol_top1(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_top1) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_up(grid, x, y, character_symbol_top1);
-
- // down special
- x -= 2;
- y = 3;
- std::vector<bool> character_symbol_top2(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_top2) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_down(grid, x, y, character_symbol_top2);
+ r = 0;
+ retrieve_codewords(symbol, codewords, true, r, c);
+ c-=2;
+ retrieve_codewords(symbol, codewords, false, r, c);
-
- y = 6 +2;
- std::vector<bool> character_symbol_special2(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_special2) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_down_special(grid, x, y, character_symbol_special2);
-
+ // down special
+ r = 4;
+ retrieve_special_codewords(symbol, codewords, false, r, c);
- // printing down long col
- y += 4;
- for (;y < 21;y+=4){
- std::vector<bool> character_symbol(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_down(grid, x, y, character_symbol);
+ for (r=9;r < 20;r+=4){
+ retrieve_codewords(symbol, codewords, false, r, c);
}
- // fill in data that is between two finder patterns
- x -= 2;
- y = 9;
- std::vector<bool> character_symbol_horiz1(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_horiz1) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_up(grid, x, y, character_symbol_horiz1);
+ // data that is between two finder patterns before timing pattern
+ c -= 2;
+ r = 9;
+ retrieve_codewords(symbol, codewords, true, r, c);
- x -= 3;
- y = 12;
- std::vector<bool> character_symbol_horiz2(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_horiz2) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_down(grid, x, y, character_symbol_horiz2);
+ // data after timing pattern
+ c -= 3;
+ retrieve_codewords(symbol, codewords, false, r, c);
- x -= 2;
- y = 9;
- std::vector<bool> character_symbol_horiz3(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_horiz3) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_up(grid, x, y, character_symbol_horiz3);
+ c -= 2;
+ retrieve_codewords(symbol, codewords, true, r, c);
- x -= 2;
- y = 12;
- std::vector<bool> character_symbol_horiz4(codeword_message.begin() + codeword_counter * 8, codeword_message.begin() + (codeword_counter + 1) * 8);
- codeword_counter++;
- //for (auto i : character_symbol_horiz4) {std::cout << i;}std::cout<<std::endl;
- //std::cout << "x=" << x << ",y=" << y << std::endl;
- grid = symbol_placement_down(grid, x, y, character_symbol_horiz4);
- */
+ c -= 2;
+ retrieve_codewords(symbol, codewords, false, r, c);
return codewords;
}