Data2DCodec.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * TI Voxel Lib component.
  3. *
  4. * Copyright (c) 2014 Texas Instruments Inc.
  5. *
  6. */
  7. #ifndef VOXEL_DATA_2D_CODEC_H
  8. #define VOXEL_DATA_2D_CODEC_H
  9. #include "Common.h"
  10. #include "DFT.h"
  11. namespace Voxel
  12. {
  13. /**
  14. * \defgroup Flt Filter related classes
  15. * @{
  16. */
  17. /**
  18. * @brief This class is used for compressing and decompressing 16-bit signed data.
  19. *
  20. * Primary application of this is for 2D phase offset data compression to store in
  21. * permanent memory of depth camera
  22. *
  23. */
  24. class VOXEL_EXPORT Data2DCodec
  25. {
  26. struct EightBitOffset
  27. {
  28. int r, c;
  29. int8_t offset;
  30. int index;
  31. EightBitOffset(int r, int c, int8_t offset, int index): r(r), c(c), offset(offset), index(index) {}
  32. };
  33. int _quantization;
  34. public:
  35. typedef Vector<ByteType> ByteArray;
  36. typedef Vector<uint8_t> ArrayBool2D;
  37. typedef int16_t Array2DElementType;
  38. typedef Vector<Array2DElementType> Array2D;
  39. Data2DCodec(int quantization = 4): _quantization(quantization) {}
  40. bool compress(const Array2D &in, const ArrayBool2D &invalidPixels, ByteArray &out);
  41. bool decompress(const ByteArray &in, Array2D &out);
  42. bool writeGrayBMPImage(const String &fileName, const Array2D &a, const uint16_t rows, const uint16_t columns);
  43. bool writeGrayBMPImage(const String &fileName, const Complex2D &c);
  44. virtual ~Data2DCodec() {}
  45. };
  46. /**
  47. * @}
  48. */
  49. }
  50. #endif