]> Skullheadx's Git Forge - qrcodescanner.git/commitdiff
fixed critical error where qr outputted was not using mask
authorSkullheadx <admonty1@gmail.com>
Thu, 21 Nov 2024 00:08:05 +0000 (19:08 -0500)
committerSkullheadx <admonty1@gmail.com>
Thu, 21 Nov 2024 00:08:05 +0000 (19:08 -0500)
camera.cpp
output.pbm
qrgenerator.cpp
test.txt [deleted file]

index 7acdf96e59624d06d750446d818491d0fe681c5c..4f979f27bf4bf1cc83898a5d586bb76c39baf8f8 100644 (file)
@@ -5,6 +5,7 @@
 
 void print(std::vector<bool> &vec);
 void print(std::vector<std::vector<bool>> &symbol);
+void print_bytes(std::vector<bool> &vec);
 void vec_xor(std::vector<bool> &v1, const std::vector<bool> v2);
 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);
@@ -33,8 +34,17 @@ int main(){
        print(symbol);
 
        std::vector<bool> 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<bool> 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<bool> &vec){
        std::cout << std::endl;
 }
 
+void print_bytes(std::vector<bool> &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<bool> &v1, const std::vector<bool> v2){
        for (std::size_t i{0}; i < v1.size(); ++i){
                v1[i] = v1[i] ^ v2[i];
index dbea2aa7a9a1027f716766fb515b59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 0 1 1 1 
-1 0 1 1 1 0 1 0 1 1 0 1 1 0 0 0 1 0 0 0 0 
-1 0 1 1 1 0 1 0 0 1 1 0 0 0 0 0 0 0 0 0 0 
-1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 
-1 0 0 0 0 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 
-1 1 1 1 1 1 1 0 1 0 0 0 1 0 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 
index 49ef0d90c7e5bd081b05315d571d00deedc028e0..7a550ae3ca9fd8d432928bbefd7144093baa79c3 100644 (file)
@@ -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<std::vector<std::vector<bool>>> mask_patterns(8, std::vector<std::vector<bool>>(21, std::vector<bool> (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 (file)
index e69de29..0000000