CTfLiteClass._h_old 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #ifndef __CFINDTEMPLATE
  3. #define __CFINGTEMPLATE
  4. #define TFLITE_MINIMAL_CHECK(x) \
  5. if (!(x)) { \
  6. fprintf(stderr, "Error at %s:%d\n", __FILE__, __LINE__); \
  7. exit(1); \
  8. }
  9. //#include "CAccessSD.h"
  10. #include "CFindTemplate.h"
  11. #include "tensorflow/lite/micro/kernels/all_ops_resolver.h"
  12. #include "tensorflow/lite/micro/micro_error_reporter.h"
  13. #include "tensorflow/lite/micro/micro_interpreter.h"
  14. #include "tensorflow/lite/schema/schema_generated.h"
  15. #include "tensorflow/lite/version.h"
  16. #include "tensorflow/lite/micro/kernels/micro_ops.h"
  17. #include "esp_err.h"
  18. #include "esp_log.h"
  19. //extern CAccessSDClass accessSD;
  20. class CTfLiteClass
  21. {
  22. protected:
  23. // CAccessSDClass *accessSD;
  24. tflite::ErrorReporter* error_reporter;
  25. const tflite::Model* model;
  26. tflite::MicroInterpreter* interpreter;
  27. // TfLiteTensor* input = nullptr;
  28. TfLiteTensor* output = nullptr;
  29. static tflite::ops::micro::AllOpsResolver *resolver;
  30. tflite::MicroOpResolver<5> micro_op_resolver;
  31. int kTensorArenaSize;
  32. uint8_t *tensor_arena;
  33. float* input;
  34. int input_i;
  35. int im_height, im_width, im_channel;
  36. long GetFileSize(std::string filename);
  37. unsigned char* ReadFileToCharArray(std::string _fn);
  38. public:
  39. // CTfLiteClass(CAccessSDClass *_accessSD);
  40. CTfLiteClass();
  41. ~CTfLiteClass();
  42. void LoadModel(std::string _fn);
  43. void MakeAllocate();
  44. void GetInputTensorSize();
  45. bool LoadInputImage(std::string _fn);
  46. void Invoke();
  47. void GetOutPut();
  48. int GetOutClassification();
  49. int GetClassFromImage(std::string _fn);
  50. float GetOutputValue(int nr);
  51. void GetInputDimension(bool silent);
  52. };
  53. #endif