OpenPose  1.7.0
The first real-time multi-person system to jointly detect human body, hand, facial, and foot keypoints
fileStream.hpp
Go to the documentation of this file.
1 #ifndef OPENPOSE_FILESTREAM_FILE_STREAM_HPP
2 #define OPENPOSE_FILESTREAM_FILE_STREAM_HPP
3 
7 
8 namespace op
9 {
10  OP_API std::string dataFormatToString(const DataFormat dataFormat);
11 
12  OP_API DataFormat stringToDataFormat(const std::string& dataFormat);
13 
14  // Save custom float format
15  // Example to read it in Python, assuming a (18 x 300 x 500) size Array
16  // x = np.fromfile(heatMapFullPath, dtype=np.float32)
17  // assert x[0] == 3 # First parameter saves the number of dimensions (18x300x500 = 3 dimensions)
18  // shape_x = x[1:1+int(x[0])]
19  // assert len(shape_x[0]) == 3 # Number of dimensions
20  // assert shape_x[0] == 18 # Size of the first dimension
21  // assert shape_x[1] == 300 # Size of the second dimension
22  // assert shape_x[2] == 500 # Size of the third dimension
23  // arrayData = x[1+int(round(x[0])):]
24  OP_API void saveFloatArray(const Array<float>& array, const std::string& fullFilePath);
25 
26  // Save/load json, xml, yaml, yml
28  const std::vector<Matrix>& opMats, const std::vector<std::string>& cvMatNames,
29  const std::string& fileNameNoExtension, const DataFormat dataFormat);
30 
32  const Matrix& opMat, const std::string cvMatName, const std::string& fileNameNoExtension,
33  const DataFormat dataFormat);
34 
35  OP_API std::vector<Matrix> loadData(
36  const std::vector<std::string>& cvMatNames, const std::string& fileNameNoExtension,
37  const DataFormat dataFormat);
38 
40  const std::string& cvMatName, const std::string& fileNameNoExtension, const DataFormat dataFormat);
41 
42  // Json - Saving as *.json not available in OpenCV versions < 3.0, this function is a quick fix
44  const Array<float>& keypoints, const std::vector<std::vector<std::array<float,3>>>& candidates,
45  const std::string& keypointName, const std::string& fileName, const bool humanReadable);
46 
47  // It will save a bunch of Array<float> elements
49  const std::vector<std::pair<Array<float>, std::string>>& keypointVector,
50  const std::vector<std::vector<std::array<float,3>>>& candidates, const std::string& fileName,
51  const bool humanReadable);
52 
53  // Save/load image
55  const Matrix& matrix, const std::string& fullFilePath,
56  const std::vector<int>& openCvCompressionParams
58 
59  OP_API Matrix loadImage(const std::string& fullFilePath, const int openCvFlags = getCvLoadImageAnydepth());
60 
61  OP_API std::vector<std::array<Rectangle<float>, 2>> loadHandDetectorTxt(const std::string& txtFilePath);
62 }
63 
64 #endif // OPENPOSE_FILESTREAM_FILE_STREAM_HPP
#define OP_API
Definition: macros.hpp:18
OP_API std::vector< std::array< Rectangle< float >, 2 > > loadHandDetectorTxt(const std::string &txtFilePath)
OP_API int getCvImwritePngCompression()
OP_API DataFormat stringToDataFormat(const std::string &dataFormat)
OP_API int getCvLoadImageAnydepth()
OP_API Matrix loadImage(const std::string &fullFilePath, const int openCvFlags=getCvLoadImageAnydepth())
OP_API void saveImage(const Matrix &matrix, const std::string &fullFilePath, const std::vector< int > &openCvCompressionParams={getCvImwriteJpegQuality(), 100, getCvImwritePngCompression(), 9})
OP_API std::string dataFormatToString(const DataFormat dataFormat)
OP_API std::vector< Matrix > loadData(const std::vector< std::string > &cvMatNames, const std::string &fileNameNoExtension, const DataFormat dataFormat)
OP_API void saveData(const std::vector< Matrix > &opMats, const std::vector< std::string > &cvMatNames, const std::string &fileNameNoExtension, const DataFormat dataFormat)
OP_API void saveFloatArray(const Array< float > &array, const std::string &fullFilePath)
OP_API int getCvImwriteJpegQuality()
DataFormat
Definition: enumClasses.hpp:7
OP_API void savePeopleJson(const Array< float > &keypoints, const std::vector< std::vector< std::array< float, 3 >>> &candidates, const std::string &keypointName, const std::string &fileName, const bool humanReadable)