mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-13 07:47:13 +02:00
save numpy files frame by frame (#37)
Co-authored-by: Bechir <bechir.brahem420@gmail.com>
This commit is contained in:
@ -29,5 +29,5 @@ if(AARE_TESTS)
|
||||
|
||||
)
|
||||
target_sources(tests PRIVATE ${TestSources} )
|
||||
target_link_libraries(tests PRIVATE core )
|
||||
target_link_libraries(tests PRIVATE core utils)
|
||||
endif()
|
@ -1,45 +1,48 @@
|
||||
#pragma once
|
||||
#include "aare/utils/logger.hpp"
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace aare {
|
||||
|
||||
enum class endian
|
||||
{
|
||||
enum class endian {
|
||||
#ifdef _WIN32
|
||||
little = 0,
|
||||
big = 1,
|
||||
big = 1,
|
||||
native = little
|
||||
#else
|
||||
little = __ORDER_LITTLE_ENDIAN__,
|
||||
big = __ORDER_BIG_ENDIAN__,
|
||||
big = __ORDER_BIG_ENDIAN__,
|
||||
native = __BYTE_ORDER__
|
||||
#endif
|
||||
};
|
||||
|
||||
class DType {
|
||||
static_assert(sizeof(long)==sizeof(int64_t), "long should be 64bits");
|
||||
static_assert(sizeof(long) == sizeof(int64_t), "long should be 64bits");
|
||||
|
||||
public:
|
||||
enum TypeIndex { INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, ERROR };
|
||||
|
||||
enum TypeIndex { INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, FLOAT, DOUBLE, ERROR };
|
||||
|
||||
uint8_t bitdepth() const;
|
||||
|
||||
explicit DType(const std::type_info &t);
|
||||
explicit DType(std::string_view sv);
|
||||
//not explicit to allow conversions form enum to DType
|
||||
DType(DType::TypeIndex ti);
|
||||
|
||||
// not explicit to allow conversions form enum to DType
|
||||
DType(DType::TypeIndex ti);
|
||||
|
||||
bool operator==(const DType &other) const noexcept;
|
||||
bool operator!=(const DType &other) const noexcept;
|
||||
bool operator==(const std::type_info &t) const;
|
||||
bool operator!=(const std::type_info &t) const;
|
||||
|
||||
// bool operator==(DType::TypeIndex ti) const;
|
||||
// bool operator!=(DType::TypeIndex ti) const;
|
||||
std::string str() const;
|
||||
|
||||
|
||||
private:
|
||||
TypeIndex m_type{TypeIndex::ERROR};
|
||||
|
||||
};
|
||||
|
||||
} // namespace aare
|
@ -29,6 +29,7 @@ class Frame {
|
||||
ssize_t rows() const { return m_rows; }
|
||||
ssize_t cols() const { return m_cols; }
|
||||
ssize_t bitdepth() const { return m_bitdepth; }
|
||||
inline ssize_t size() const { return m_rows * m_cols * m_bitdepth / 8; }
|
||||
std::byte *_get_data() { return m_data; }
|
||||
Frame &operator=(Frame &other) {
|
||||
m_rows = other.rows();
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
namespace aare {
|
||||
|
||||
|
||||
DType::DType(const std::type_info &t) {
|
||||
if (t == typeid(int8_t))
|
||||
m_type = TypeIndex::INT8;
|
||||
@ -32,6 +33,32 @@ DType::DType(const std::type_info &t) {
|
||||
"Could not construct data type. Type not supported.");
|
||||
}
|
||||
|
||||
uint8_t DType::bitdepth()const {
|
||||
switch (m_type) {
|
||||
case TypeIndex::INT8:
|
||||
case TypeIndex::UINT8:
|
||||
return 8;
|
||||
case TypeIndex::INT16:
|
||||
case TypeIndex::UINT16:
|
||||
return 16;
|
||||
case TypeIndex::INT32:
|
||||
case TypeIndex::UINT32:
|
||||
return 32;
|
||||
case TypeIndex::INT64:
|
||||
case TypeIndex::UINT64:
|
||||
return 64;
|
||||
case TypeIndex::FLOAT:
|
||||
return 32;
|
||||
case TypeIndex::DOUBLE:
|
||||
return 64;
|
||||
case TypeIndex::ERROR:
|
||||
return 0;
|
||||
default:
|
||||
throw std::runtime_error(LOCATION+"Could not get bitdepth. Type not supported.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DType::DType(DType::TypeIndex ti):m_type(ti){}
|
||||
|
||||
DType::DType(std::string_view sv) {
|
||||
|
@ -34,6 +34,7 @@ void Frame::set(int row, int col, T data) {
|
||||
}
|
||||
|
||||
template void Frame::set(int row, int col, uint16_t data);
|
||||
template void Frame::set(int row, int col, uint32_t data);
|
||||
|
||||
|
||||
// std::vector<std::vector<DataType>> Frame<DataType>::get_array() {
|
||||
|
Reference in New Issue
Block a user