Class DataHelper

Class Documentation

class DataHelper

Simple class to do data manipulation, contains helper function to update json files in dataset.

Public Functions

DataHelper() = default

constructor

~DataHelper() = default

Destructor.

inline Status CreateAlbum(const std::string &in_dir, const std::string &out_dir)

Create an Album dataset while taking in a path to a image folder Creates the output directory if doesn’t exist.

参数
  • in_dir[in] Image folder directory that takes in images

  • out_dir[in] Directory containing output json files

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<std::string> &value, const std::string &out_file = "")

Update a json file field with a vector of string values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional input for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<bool> &value, const std::string &out_file = "")

Update a json file field with a vector of bool values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<int8_t> &value, const std::string &out_file = "")

Update a json file field with a vector of int8 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<uint8_t> &value, const std::string &out_file = "")

Update a json file field with a vector of uint8 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<int16_t> &value, const std::string &out_file = "")

Update a json file field with a vector of int16 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<uint16_t> &value, const std::string &out_file = "")

Update a json file field with a vector of uint16 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<int32_t> &value, const std::string &out_file = "")

Update a json file field with a vector of int32 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<uint32_t> &value, const std::string &out_file = "")

Update a json file field with a vector of uint32 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<int64_t> &value, const std::string &out_file = "")

Update a json file field with a vector of int64 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<uint64_t> &value, const std::string &out_file = "")

Update a json file field with a vector of uint64 values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<float> &value, const std::string &out_file = "")

Update a json file field with a vector of float values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateArray(const std::string &in_file, const std::string &key, const std::vector<double> &value, const std::string &out_file = "")

Update a json file field with a vector of double values.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value array to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const std::string &value, const std::string &out_file = "")

Update a json file field with a string value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const bool &value, const std::string &out_file = "")

Update a json file field with a bool value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const int8_t &value, const std::string &out_file = "")

Update a json file field with an int8 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const uint8_t &value, const std::string &out_file = "")

Update a json file field with an uint8 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const int16_t &value, const std::string &out_file = "")

Update a json file field with an int16 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const uint16_t &value, const std::string &out_file = "")

Update a json file field with an uint16 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const int32_t &value, const std::string &out_file = "")

Update a json file field with an int32 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const uint32_t &value, const std::string &out_file = "")

Update a json file field with an uint32 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const int64_t &value, const std::string &out_file = "")

Update a json file field with an int64 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const uint64_t &value, const std::string &out_file = "")

Update a json file field with an uint64 value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const float &value, const std::string &out_file = "")

Update a json file field with a float value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

inline Status UpdateValue(const std::string &in_file, const std::string &key, const double &value, const std::string &out_file = "")

Update a json file field with a double value.

参数
  • in_file – The input file name to read in

  • key – Key of field to write to

  • value – Value to write to file

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

template<typename T>
inline Status WriteBinFile(const std::string &in_file, const std::vector<T> &data)

Template function to write tensor to file.

参数
  • in_file[in] File to write to

  • data[in] Array of type T values

返回

Status The status code returned

template<typename T>
inline Status WriteBinFile(const std::string &in_file, T *data, size_t length)

Write pointer to bin, use pointer to avoid memcpy.

说明

The value of lengthmust be equal to the length ofdata`

参数
  • in_file[in] File name to write to

  • data[in] Pointer to data

  • length[in] Length of values to write from pointer

返回

Status The status code returned

size_t DumpData(const unsigned char *tensor_addr, const size_t &tensor_size, void *addr, const size_t &buffer_size)

Helper function to copy content of a tensor to buffer.

说明

This function iterates over the tensor in bytes, since

参数
  • tensor_addr[in] The memory held by a tensor

  • tensor_size[in] The amount of data in bytes in tensor_addr, e.g. tensor->SizeInBytes()

  • addr[out] The address to copy tensor data to

  • buffer_size[in] The buffer size of addr

返回

The size of the tensor (bytes copied

inline Status RemoveKey(const std::string &in_file, const std::string &key, const std::string &out_file = "")

Helper function to delete key in json file.

说明

This function will return okay even if key not found

参数
  • in_file[in] Json file to remove key from

  • key[in] The key to remove

  • out_file – Optional parameter for output file path, will write to input file if not specified

返回

Status The status code returned

void Print(std::ostream &out) const

A print method typically used for debugging.

参数

out – - The output stream to write output to