From: Skullheadx Date: Thu, 21 Nov 2024 00:08:05 +0000 (-0500) Subject: fixed critical error where qr outputted was not using mask X-Git-Url: http://git.skullheadx.com/index.css?a=commitdiff_plain;h=c95769c6a685307d28419bec2f5b309f2ce1e798;p=qrcodescanner.git fixed critical error where qr outputted was not using mask --- diff --git a/camera.cpp b/camera.cpp index 7acdf96..4f979f2 100644 --- a/camera.cpp +++ b/camera.cpp @@ -5,6 +5,7 @@ void print(std::vector &vec); void print(std::vector> &symbol); +void print_bytes(std::vector &vec); 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); @@ -33,8 +34,17 @@ int main(){ print(symbol); std::vector codewords = get_codewords_from_symbol(symbol); - print(codewords); + //print(codewords); + print_bytes(codewords); + //std::cout << "Number of codewords: " << codewords.size() / 8.0 << std::endl; + std::vector data_codewords(codewords.begin(), codewords.begin() + 16 * 8), error_correction_codewords(codewords.begin() + 16 * 8, codewords.end()); + + std::cout << "Number of data codewords: " << data_codewords.size() / 8.0 << std::endl; + std::cout << "Number of error correction codewords: " << error_correction_codewords.size() / 8.0 << std::endl; + //print_bytes(data_codewords); + + return 0; } @@ -56,6 +66,14 @@ void print(std::vector &vec){ std::cout << std::endl; } +void print_bytes(std::vector &vec){ + for (std::size_t i{0}; i < vec.size(); ++i){ + if (i != 0 && i % 8 == 0){std::cout << ' ';} + std::cout << vec[i]; + } + std::cout << std::endl; +} + void vec_xor(std::vector &v1, const std::vector v2){ for (std::size_t i{0}; i < v1.size(); ++i){ v1[i] = v1[i] ^ v2[i]; diff --git a/output.pbm b/output.pbm index dbea2aa..48a169f 100644 --- a/output.pbm +++ b/output.pbm @@ -1,23 +1,23 @@ P1 21 21 -1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1 -1 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 1 -1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1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1 1 1 1 1 1 1 +0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 +1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 +1 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 +1 1 1 0 1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 1 0 +1 0 1 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 1 0 0 +1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 0 0 0 1 0 1 +0 0 0 0 0 0 0 0 1 1 0 1 1 1 0 1 0 1 0 0 1 +1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0 +1 0 0 0 0 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0 1 +1 0 1 1 1 0 1 0 1 1 1 1 0 0 1 0 0 0 1 0 1 +1 0 1 1 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 1 0 +1 0 1 1 1 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 +1 0 0 0 0 0 1 0 0 0 1 0 1 1 1 1 0 0 0 1 0 +1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 diff --git a/qrgenerator.cpp b/qrgenerator.cpp index 49ef0d9..7a550ae 100644 --- a/qrgenerator.cpp +++ b/qrgenerator.cpp @@ -419,7 +419,7 @@ int main() { //std::cout << "x=" << x << ",y=" << y << std::endl; grid = symbol_placement_down(grid, x, y, character_symbol_horiz4); - //print_grid(grid); + print_grid(grid); std::vector>> mask_patterns(8, std::vector>(21, std::vector (21, 0))); @@ -503,10 +503,11 @@ int main() { for (std::size_t ind{}; ind < 8; ++ind){ for (std::size_t i{}; i < 21; ++i){ for (std::size_t j{}; j < 21; ++j){ - mask_pattern_results[ind][i][j] = (mask_pattern_results[ind][i][j] && grid[i][j]); // CHANGE test_grid BACK TO grid for REAL USE - if (mask_patterns[ind][i][j]){ - mask_pattern_results[ind][i][j] = !mask_pattern_results[ind][i][j]; - } + mask_pattern_results[ind][i][j] = grid[i][j] ^ mask_patterns[ind][i][j]; + //mask_pattern_results[ind][i][j] = (mask_pattern_results[ind][i][j] && grid[i][j]); // CHANGE test_grid BACK TO grid for REAL USE + //if (mask_patterns[ind][i][j]){ + // mask_pattern_results[ind][i][j] = !mask_pattern_results[ind][i][j]; + //} } } } @@ -525,6 +526,7 @@ int main() { //mask_pattern_bits = {1,0,1}; // REMOVE TESTinG PurposES ONLy print_grid(mask_pattern_results[mask_pattern]); + grid = mask_pattern_results[mask_pattern]; std::cout << "best mask pattern: " << mask_pattern << std::endl; for (auto i : mask_pattern_bits){std::cout << i;} std::cout << std::endl; diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29..0000000