Helper Utilities#
-
struct InputHelperOptions#
The options for InputHelper.
Public Members
-
std::string sample_set_name = {}#
The name of sample_set, which will be the name of the main dataset of the project when it is empty or using the default value.
-
std::string input_tool_id = {}#
The Input tool name. If set to empty or using the default value, the importer will automatically look for the name of the Input tool in the project. If there is no Input tool or multiple Input tools in the project, an exception will be thrown. If the given tool name is not empty, you need to ensure that the tool exists and its type is “Input”, otherwise an exception will also be thrown.
-
bool auto_deduplication = true#
Whether to remove duplicate images automatically. When this option is set to true, the InputHelper will automatically removes duplicate images that are identical based on the fingerprint of the image, and images that have been previously imported into the dataset will not be re-imported too.
-
util::IProgressCallback *callback = nullptr#
The progress callback for importing the image.
-
size_t parallel_size = 0#
The number of threads to import images in parallel. The default value is 0. When set to 0, the executor will make an intelligent decision on the number of threads to parallelize. Generally, the default value of 0 is sufficient.
-
Tags tags = {}#
All samples imported by the InputHelper will be tagged with the given tags.
-
std::string sample_set_name = {}#
-
class InputHelper#
Utility for helping importing images into Input tool.
The common usage:
Get more option details in the InputHelperOptions.visionflow::helper::InputHelperOptions options; options.input_tool_id = "InputTool"; visionflow::helper::InputHelper helper(project_ptr, options); helper.add_images({image_files_path}); receipts = helper.commit(); for(const auto &receipt : receipts) { if(!receipt.is_success) { std::cout << receipt.error_message << std::endl; } }
Public Functions
-
const InputHelperOptions &options() const#
Get the final options information.
- Returns:
const InputHelperOptions&
-
void add_image(const std::string &image_file)#
Record the image you want to add.
- Parameters:
image_file – An image of a file
-
void add_image(const std::vector<std::string> &image_files)#
Record the image you want to add.
- Parameters:
image_files – An image of multiple files
-
void add_images(const std::vector<std::string> &images_files)#
Record the images you want to add.
- Parameters:
images_files – Multiple images, each consisting of a file.
-
void add_images(const std::vector<std::vector<std::string>> &images_files)#
Record the images you want to add.
- Parameters:
images_files – Multiple images composed of multiple files.
-
const std::vector<InputHelper::Receipt> &commit()#
Adds the currently recorded image to input tool.
Note
1.The image needs to meet the input parameter requirements. 2.When an image is added, channel 4 is converted into channel 3 and channel 2 is converted into channel 1.
- Returns:
const std::vector<InputHelper::Receipt>& Receipt information returned after importing the images, ordered by the order in which the images were added.
-
struct Receipt#
Receipt information returned after importing the images.
Public Members
-
std::vector<std::string> image_files#
File path in image.
-
bool is_success = false#
Check whether the image is successfully imported.
-
uint32_t sample_id#
Import image returns sample_id, if failed sample_id is 0.
-
std::string error_message#
Error infomation, json format, always contains “type” and “message” fields.
some common error will be like:
The image is duplicated with someone in the dataset or add same image multiple times:
Note that the “duplicate_sample” field will be 0 if the image is duplicated with someone added into this InputHelper instance multiple times.{ "type": "ImageDuplicated", "message": "The image already exists in the dataset.", "duplicate_sample": 123 }
The image visual size is not match with the parameter requirements:
{ "type", "InvalidImageVisualSize", "message": "The visual_size is required to be {}, but get {}." }
Other errors, always contains “type” and “message” fields.
-
std::vector<std::string> image_files#
-
const InputHelperOptions &options() const#