Parcourir la source

convert all rawls file

Jérôme BUISINE il y a 3 ans
Parent
commit
94d2141c18
2 fichiers modifiés avec 33 ajouts et 3 suppressions
  1. 0 3
      rawls/rawls.cpp
  2. 33 0
      run/convert_all_rawls.py

+ 0 - 3
rawls/rawls.cpp

@@ -292,11 +292,8 @@ std::tuple<unsigned, unsigned, unsigned, float*> rawls::getDataRAWLS(std::string
             std::getline(rf, line); // avoid data size line
 
             rf.read((char *) &width, sizeof(unsigned));
-            rf.get(c);
             rf.read((char *) &height, sizeof(unsigned));
-            rf.get(c);
             rf.read((char *) &nbChanels, sizeof(unsigned));
-            rf.get(c);
         }
     }
 

+ 33 - 0
run/convert_all_rawls.py

@@ -0,0 +1,33 @@
+import os
+import argparse
+import glob
+
+def main():
+
+    parser = argparse.ArgumentParser(description="Convert rawls file into png")
+
+    parser.add_argument('--folder', type=str, help='folder with all rawls files', required=True)
+    parser.add_argument('--output', type=str, help='folder with all png files', required=True)
+
+    args = parser.parse_args()
+
+    p_folder = args.folder
+    p_output = args.output
+
+    images_path = glob.glob(f"{p_folder}/**/**/*.rawls")
+
+    for img in sorted(images_path):
+
+        output_path = img.replace('.rawls', '.png')
+        output_path = output_path.replace(p_folder, p_output)
+
+        output_folder, _ = os.path.split(output_path)
+
+        if not os.path.exists(output_folder):
+            os.makedirs(output_folder)
+        
+        os.system(f'./build/main/rawls_convert --image {img} --outfile {output_path}')
+    
+
+if __name__ == "__main__":
+    main()