From: Skullheadx Date: Wed, 20 Nov 2024 23:36:48 +0000 (-0500) Subject: Retrieve all codewords from encoding region of the QR code X-Git-Url: http://git.skullheadx.com/nixos/static/projects/suckless.html?a=commitdiff_plain;h=e312edaa2dc7c0a8b0db05966efa7c4a7c8ff468;p=qrcodescanner.git Retrieve all codewords from encoding region of the QR code --- diff --git a/camera.cpp b/camera.cpp index 634cc52..7acdf96 100644 --- a/camera.cpp +++ b/camera.cpp @@ -9,6 +9,7 @@ void vec_xor(std::vector &v1, const std::vector v2); unsigned int distance(std::vector &v1, const std::vector &v2); void read_words_from_file(char const *filename, std::vector> &symbol); void retrieve_codewords(std::vector> &symbol, std::vector &codewords, bool is_upwards, std::size_t row, std::size_t col); +void retrieve_special_codewords(std::vector> &symbol, std::vector &codewords, bool is_upwards, int row, int col); std::vector get_format_info(std::vector> &symbol); void decode_mask(std::vector> &symbol, std::size_t mask_pattern); @@ -195,6 +196,7 @@ void decode_mask(std::vector> &symbol, std::size_t mask_patter } } } + void retrieve_codewords(std::vector> &symbol, std::vector &codewords, bool is_upwards, int row, int col){ if (is_upwards){ for (int r{row + 3}; r >= row; --r){ @@ -213,25 +215,28 @@ void retrieve_codewords(std::vector> &symbol, std::vector> &symbol, std::vector &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 get_codewords_from_symbol(std::vector> &symbol){ std::vector codewords{}; int c{}, r{}; @@ -250,83 +255,38 @@ std::vector get_codewords_from_symbol(std::vector> &symb 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 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<