]> Skullheadx's Git Forge - qrcodescanner.git/commitdiff
print and import qr code from file
authorSkullheadx <admonty1@gmail.com>
Wed, 20 Nov 2024 00:26:28 +0000 (19:26 -0500)
committerSkullheadx <admonty1@gmail.com>
Wed, 20 Nov 2024 00:26:28 +0000 (19:26 -0500)
.DS_Store
69.png [new file with mode: 0644]
camera.cpp [new file with mode: 0644]
test.txt [new file with mode: 0644]

index 4c68ead3e4b0ee274ed2a41f231c03ea8b13ae3d..43b4569f8ffd05dee4f96d2d39bb7a4519236c3b 100644 (file)
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/69.png b/69.png
new file mode 100644 (file)
index 0000000..4c42ca8
Binary files /dev/null and b/69.png differ
diff --git a/camera.cpp b/camera.cpp
new file mode 100644 (file)
index 0000000..0d20f12
--- /dev/null
@@ -0,0 +1,44 @@
+#include <iostream>
+#include <fstream>
+#include <cassert>
+#include <vector>
+
+void read_words_from_file(char const *filename, std::vector<std::vector<bool>> &symbol);
+void print(std::vector<std::vector<bool>> &symbol);
+
+int main(){
+       std::vector<std::vector<bool>> symbol(21, std::vector<bool>(21,0));
+
+       read_words_from_file("output.pbm", symbol);
+       print(symbol);
+
+       
+       return 0;
+}
+
+
+void print(std::vector<std::vector<bool>> &symbol){
+       for (const auto &i : symbol){
+               for (auto j : i){
+                       std::cout << j;
+             }
+               std::cout << std::endl;
+       }
+}
+
+void read_words_from_file(char const *filename, std::vector<std::vector<bool>> &symbol) {
+       std::ifstream file{ filename };
+       if (!file.is_open()) {
+       std::cout << "[ERROR] " << filename << " not found or could not open file" << std::endl;
+       }
+       assert( file.is_open() );
+       
+       file.ignore(9);
+       std::size_t row{0};
+       for (std::string line; std::getline(file, line);++row){
+               for (std::size_t pos{0}; pos < line.size(); pos+=2){
+                       symbol[row][pos/2] = (line[pos] == '1');
+               }
+       }
+       file.close();
+}
diff --git a/test.txt b/test.txt
new file mode 100644 (file)
index 0000000..e69de29