mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-11 06:47:14 +02:00
save numpy files frame by frame (#37)
Co-authored-by: Bechir <bechir.brahem420@gmail.com>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
|
||||
set(EXAMPLE_LIST "json_example;logger_example;numpy_example;multiport_example;raw_example;mythen_example")
|
||||
set(EXAMPLE_LIST "json_example;logger_example;numpy_read_example;multiport_example;raw_example")
|
||||
set(EXAMPLE_LIST "${EXAMPLE_LIST};mythen_example;numpy_write_example")
|
||||
foreach(example ${EXAMPLE_LIST})
|
||||
add_executable(${example} ${example}.cpp)
|
||||
target_link_libraries(${example} PUBLIC aare PRIVATE aare_compiler_flags)
|
||||
|
27
examples/numpy_write_example.cpp
Normal file
27
examples/numpy_write_example.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
// Your First C++ Program
|
||||
#include "aare/File.hpp"
|
||||
#include "aare/Frame.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#define AARE_ROOT_DIR_VAR "PROJECT_ROOT_DIR"
|
||||
|
||||
|
||||
int main() {
|
||||
auto path = std::filesystem::path("/tmp/test.npy");
|
||||
auto dtype = aare::DType(typeid(uint32_t));
|
||||
FileConfig cfg = {path, dtype, 100, 100};
|
||||
File npy(path, "w",cfg);
|
||||
Frame f(100, 100, dtype.bitdepth());
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
f.set<uint32_t>(i/100, i%100,i);
|
||||
}
|
||||
|
||||
npy.write(f);
|
||||
f.set<uint32_t>(0,0,77);
|
||||
npy.write(f);
|
||||
npy.write(f);
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user