Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

fileStream.hpp 2.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  1. #ifndef OPENPOSE_FILESTREAM_FILE_STREAM_HPP
  2. #define OPENPOSE_FILESTREAM_FILE_STREAM_HPP
  3. #include <openpose/core/common.hpp>
  4. #include <openpose/filestream/enumClasses.hpp>
  5. #include <openpose/utilities/openCv.hpp>
  6. namespace op
  7. {
  8. OP_API std::string dataFormatToString(const DataFormat dataFormat);
  9. OP_API DataFormat stringToDataFormat(const std::string& dataFormat);
  10. // Save custom float format
  11. // Example to read it in Python, assuming a (18 x 300 x 500) size Array
  12. // x = np.fromfile(heatMapFullPath, dtype=np.float32)
  13. // assert x[0] == 3 # First parameter saves the number of dimensions (18x300x500 = 3 dimensions)
  14. // shape_x = x[1:1+int(x[0])]
  15. // assert len(shape_x[0]) == 3 # Number of dimensions
  16. // assert shape_x[0] == 18 # Size of the first dimension
  17. // assert shape_x[1] == 300 # Size of the second dimension
  18. // assert shape_x[2] == 500 # Size of the third dimension
  19. // arrayData = x[1+int(round(x[0])):]
  20. OP_API void saveFloatArray(const Array<float>& array, const std::string& fullFilePath);
  21. // Save/load json, xml, yaml, yml
  22. OP_API void saveData(
  23. const std::vector<Matrix>& opMats, const std::vector<std::string>& cvMatNames,
  24. const std::string& fileNameNoExtension, const DataFormat dataFormat);
  25. OP_API void saveData(
  26. const Matrix& opMat, const std::string cvMatName, const std::string& fileNameNoExtension,
  27. const DataFormat dataFormat);
  28. OP_API std::vector<Matrix> loadData(
  29. const std::vector<std::string>& cvMatNames, const std::string& fileNameNoExtension,
  30. const DataFormat dataFormat);
  31. OP_API Matrix loadData(
  32. const std::string& cvMatName, const std::string& fileNameNoExtension, const DataFormat dataFormat);
  33. // Json - Saving as *.json not available in OpenCV verions < 3.0, this function is a quick fix
  34. OP_API void savePeopleJson(
  35. const Array<float>& keypoints, const std::vector<std::vector<std::array<float,3>>>& candidates,
  36. const std::string& keypointName, const std::string& fileName, const bool humanReadable);
  37. // It will save a bunch of Array<float> elements
  38. OP_API void savePeopleJson(
  39. const std::vector<std::pair<Array<float>, std::string>>& keypointVector,
  40. const std::vector<std::vector<std::array<float,3>>>& candidates, const std::string& fileName,
  41. const bool humanReadable);
  42. // Save/load image
  43. OP_API void saveImage(
  44. const Matrix& matrix, const std::string& fullFilePath,
  45. const std::vector<int>& openCvCompressionParams
  46. = {getCvImwriteJpegQuality(), 100, getCvImwritePngCompression(), 9});
  47. OP_API Matrix loadImage(const std::string& fullFilePath, const int openCvFlags = getCvLoadImageAnydepth());
  48. OP_API std::vector<std::array<Rectangle<float>, 2>> loadHandDetectorTxt(const std::string& txtFilePath);
  49. }
  50. #endif // OPENPOSE_FILESTREAM_FILE_STREAM_HPP
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...